Edit File by line
/home/barbar84/www/wp-inclu.../js
File: customize-views.js
/**
[0] Fix | Delete
* @output wp-includes/js/customize-views.js
[1] Fix | Delete
*/
[2] Fix | Delete
[3] Fix | Delete
(function( $, wp, _ ) {
[4] Fix | Delete
[5] Fix | Delete
if ( ! wp || ! wp.customize ) { return; }
[6] Fix | Delete
var api = wp.customize;
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* wp.customize.HeaderTool.CurrentView
[10] Fix | Delete
*
[11] Fix | Delete
* Displays the currently selected header image, or a placeholder in lack
[12] Fix | Delete
* thereof.
[13] Fix | Delete
*
[14] Fix | Delete
* Instantiate with model wp.customize.HeaderTool.currentHeader.
[15] Fix | Delete
*
[16] Fix | Delete
* @memberOf wp.customize.HeaderTool
[17] Fix | Delete
* @alias wp.customize.HeaderTool.CurrentView
[18] Fix | Delete
*
[19] Fix | Delete
* @constructor
[20] Fix | Delete
* @augments wp.Backbone.View
[21] Fix | Delete
*/
[22] Fix | Delete
api.HeaderTool.CurrentView = wp.Backbone.View.extend(/** @lends wp.customize.HeaderTool.CurrentView.prototype */{
[23] Fix | Delete
template: wp.template('header-current'),
[24] Fix | Delete
[25] Fix | Delete
initialize: function() {
[26] Fix | Delete
this.listenTo(this.model, 'change', this.render);
[27] Fix | Delete
this.render();
[28] Fix | Delete
},
[29] Fix | Delete
[30] Fix | Delete
render: function() {
[31] Fix | Delete
this.$el.html(this.template(this.model.toJSON()));
[32] Fix | Delete
this.setButtons();
[33] Fix | Delete
return this;
[34] Fix | Delete
},
[35] Fix | Delete
[36] Fix | Delete
setButtons: function() {
[37] Fix | Delete
var elements = $('#customize-control-header_image .actions .remove');
[38] Fix | Delete
if (this.model.get('choice')) {
[39] Fix | Delete
elements.show();
[40] Fix | Delete
} else {
[41] Fix | Delete
elements.hide();
[42] Fix | Delete
}
[43] Fix | Delete
}
[44] Fix | Delete
});
[45] Fix | Delete
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* wp.customize.HeaderTool.ChoiceView
[49] Fix | Delete
*
[50] Fix | Delete
* Represents a choosable header image, be it user-uploaded,
[51] Fix | Delete
* theme-suggested or a special Randomize choice.
[52] Fix | Delete
*
[53] Fix | Delete
* Takes a wp.customize.HeaderTool.ImageModel.
[54] Fix | Delete
*
[55] Fix | Delete
* Manually changes model wp.customize.HeaderTool.currentHeader via the
[56] Fix | Delete
* `select` method.
[57] Fix | Delete
*
[58] Fix | Delete
* @memberOf wp.customize.HeaderTool
[59] Fix | Delete
* @alias wp.customize.HeaderTool.ChoiceView
[60] Fix | Delete
*
[61] Fix | Delete
* @constructor
[62] Fix | Delete
* @augments wp.Backbone.View
[63] Fix | Delete
*/
[64] Fix | Delete
api.HeaderTool.ChoiceView = wp.Backbone.View.extend(/** @lends wp.customize.HeaderTool.ChoiceView.prototype */{
[65] Fix | Delete
template: wp.template('header-choice'),
[66] Fix | Delete
[67] Fix | Delete
className: 'header-view',
[68] Fix | Delete
[69] Fix | Delete
events: {
[70] Fix | Delete
'click .choice,.random': 'select',
[71] Fix | Delete
'click .close': 'removeImage'
[72] Fix | Delete
},
[73] Fix | Delete
[74] Fix | Delete
initialize: function() {
[75] Fix | Delete
var properties = [
[76] Fix | Delete
this.model.get('header').url,
[77] Fix | Delete
this.model.get('choice')
[78] Fix | Delete
];
[79] Fix | Delete
[80] Fix | Delete
this.listenTo(this.model, 'change:selected', this.toggleSelected);
[81] Fix | Delete
[82] Fix | Delete
if (_.contains(properties, api.get().header_image)) {
[83] Fix | Delete
api.HeaderTool.currentHeader.set(this.extendedModel());
[84] Fix | Delete
}
[85] Fix | Delete
},
[86] Fix | Delete
[87] Fix | Delete
render: function() {
[88] Fix | Delete
this.$el.html(this.template(this.extendedModel()));
[89] Fix | Delete
[90] Fix | Delete
this.toggleSelected();
[91] Fix | Delete
return this;
[92] Fix | Delete
},
[93] Fix | Delete
[94] Fix | Delete
toggleSelected: function() {
[95] Fix | Delete
this.$el.toggleClass('selected', this.model.get('selected'));
[96] Fix | Delete
},
[97] Fix | Delete
[98] Fix | Delete
extendedModel: function() {
[99] Fix | Delete
var c = this.model.get('collection');
[100] Fix | Delete
return _.extend(this.model.toJSON(), {
[101] Fix | Delete
type: c.type
[102] Fix | Delete
});
[103] Fix | Delete
},
[104] Fix | Delete
[105] Fix | Delete
select: function() {
[106] Fix | Delete
this.preventJump();
[107] Fix | Delete
this.model.save();
[108] Fix | Delete
api.HeaderTool.currentHeader.set(this.extendedModel());
[109] Fix | Delete
},
[110] Fix | Delete
[111] Fix | Delete
preventJump: function() {
[112] Fix | Delete
var container = $('.wp-full-overlay-sidebar-content'),
[113] Fix | Delete
scroll = container.scrollTop();
[114] Fix | Delete
[115] Fix | Delete
_.defer(function() {
[116] Fix | Delete
container.scrollTop(scroll);
[117] Fix | Delete
});
[118] Fix | Delete
},
[119] Fix | Delete
[120] Fix | Delete
removeImage: function(e) {
[121] Fix | Delete
e.stopPropagation();
[122] Fix | Delete
this.model.destroy();
[123] Fix | Delete
this.remove();
[124] Fix | Delete
}
[125] Fix | Delete
});
[126] Fix | Delete
[127] Fix | Delete
[128] Fix | Delete
/**
[129] Fix | Delete
* wp.customize.HeaderTool.ChoiceListView
[130] Fix | Delete
*
[131] Fix | Delete
* A container for ChoiceViews. These choices should be of one same type:
[132] Fix | Delete
* user-uploaded headers or theme-defined ones.
[133] Fix | Delete
*
[134] Fix | Delete
* Takes a wp.customize.HeaderTool.ChoiceList.
[135] Fix | Delete
*
[136] Fix | Delete
* @memberOf wp.customize.HeaderTool
[137] Fix | Delete
* @alias wp.customize.HeaderTool.ChoiceListView
[138] Fix | Delete
*
[139] Fix | Delete
* @constructor
[140] Fix | Delete
* @augments wp.Backbone.View
[141] Fix | Delete
*/
[142] Fix | Delete
api.HeaderTool.ChoiceListView = wp.Backbone.View.extend(/** @lends wp.customize.HeaderTool.ChoiceListView.prototype */{
[143] Fix | Delete
initialize: function() {
[144] Fix | Delete
this.listenTo(this.collection, 'add', this.addOne);
[145] Fix | Delete
this.listenTo(this.collection, 'remove', this.render);
[146] Fix | Delete
this.listenTo(this.collection, 'sort', this.render);
[147] Fix | Delete
this.listenTo(this.collection, 'change', this.toggleList);
[148] Fix | Delete
this.render();
[149] Fix | Delete
},
[150] Fix | Delete
[151] Fix | Delete
render: function() {
[152] Fix | Delete
this.$el.empty();
[153] Fix | Delete
this.collection.each(this.addOne, this);
[154] Fix | Delete
this.toggleList();
[155] Fix | Delete
},
[156] Fix | Delete
[157] Fix | Delete
addOne: function(choice) {
[158] Fix | Delete
var view;
[159] Fix | Delete
choice.set({ collection: this.collection });
[160] Fix | Delete
view = new api.HeaderTool.ChoiceView({ model: choice });
[161] Fix | Delete
this.$el.append(view.render().el);
[162] Fix | Delete
},
[163] Fix | Delete
[164] Fix | Delete
toggleList: function() {
[165] Fix | Delete
var title = this.$el.parents().prev('.customize-control-title'),
[166] Fix | Delete
randomButton = this.$el.find('.random').parent();
[167] Fix | Delete
if (this.collection.shouldHideTitle()) {
[168] Fix | Delete
title.add(randomButton).hide();
[169] Fix | Delete
} else {
[170] Fix | Delete
title.add(randomButton).show();
[171] Fix | Delete
}
[172] Fix | Delete
}
[173] Fix | Delete
});
[174] Fix | Delete
[175] Fix | Delete
[176] Fix | Delete
/**
[177] Fix | Delete
* wp.customize.HeaderTool.CombinedList
[178] Fix | Delete
*
[179] Fix | Delete
* Aggregates wp.customize.HeaderTool.ChoiceList collections (or any
[180] Fix | Delete
* Backbone object, really) and acts as a bus to feed them events.
[181] Fix | Delete
*
[182] Fix | Delete
* @memberOf wp.customize.HeaderTool
[183] Fix | Delete
* @alias wp.customize.HeaderTool.CombinedList
[184] Fix | Delete
*
[185] Fix | Delete
* @constructor
[186] Fix | Delete
* @augments wp.Backbone.View
[187] Fix | Delete
*/
[188] Fix | Delete
api.HeaderTool.CombinedList = wp.Backbone.View.extend(/** @lends wp.customize.HeaderTool.CombinedList.prototype */{
[189] Fix | Delete
initialize: function(collections) {
[190] Fix | Delete
this.collections = collections;
[191] Fix | Delete
this.on('all', this.propagate, this);
[192] Fix | Delete
},
[193] Fix | Delete
propagate: function(event, arg) {
[194] Fix | Delete
_.each(this.collections, function(collection) {
[195] Fix | Delete
collection.trigger(event, arg);
[196] Fix | Delete
});
[197] Fix | Delete
}
[198] Fix | Delete
});
[199] Fix | Delete
[200] Fix | Delete
})( jQuery, window.wp, _ );
[201] Fix | Delete
[202] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function