/**
* @output wp-includes/js/customize-models.js
*/
/* global _wpCustomizeHeader */
(function( $, wp ) {
var api = wp.customize;
/** @namespace wp.customize.HeaderTool */
api.HeaderTool = {};
/**
* wp.customize.HeaderTool.ImageModel
*
* A header image. This is where saves via the Customizer API are
* abstracted away, plus our own Ajax calls to add images to and remove
* images from the user's recently uploaded images setting on the server.
* These calls are made regardless of whether the user actually saves new
* Customizer settings.
*
* @memberOf wp.customize.HeaderTool
* @alias wp.customize.HeaderTool.ImageModel
*
* @constructor
* @augments Backbone.Model
*/
api.HeaderTool.ImageModel = Backbone.Model.extend(/** @lends wp.customize.HeaderTool.ImageModel.prototype */{
defaults: function() {
return {
header: {
attachment_id: 0,
url: '',
timestamp: _.now(),
thumbnail_url: ''
},
choice: '',
selected: false,
random: false
};
},
initialize: function() {
this.on('hide', this.hide, this);
},
hide: function() {
this.set('choice', '');
api('header_image').set('remove-header');
api('header_image_data').set('remove-header');
},
destroy: function() {
var data = this.get('header'),
curr = api.HeaderTool.currentHeader.get('header').attachment_id;
// If the image we're removing is also the current header,
// unset the latter.
if (curr && data.attachment_id === curr) {
api.HeaderTool.currentHeader.trigger('hide');
}
wp.ajax.post( 'custom-header-remove', {
nonce: _wpCustomizeHeader.nonces.remove,
wp_customize: 'on',
theme: api.settings.theme.stylesheet,
attachment_id: data.attachment_id
});
this.trigger('destroy', this, this.collection);
},
save: function() {
if (this.get('random')) {
api('header_image').set(this.get('header').random);
api('header_image_data').set(this.get('header').random);
} else {
if (this.get('header').defaultName) {
api('header_image').set(this.get('header').url);
api('header_image_data').set(this.get('header').defaultName);
} else {
api('header_image').set(this.get('header').url);
api('header_image_data').set(this.get('header'));
}
}
api.HeaderTool.combinedList.trigger('control:setImage', this);
},
importImage: function() {
var data = this.get('header');
if (data.attachment_id === undefined) {
return;
}
wp.ajax.post( 'custom-header-add', {
nonce: _wpCustomizeHeader.nonces.add,
wp_customize: 'on',
theme: api.settings.theme.stylesheet,
attachment_id: data.attachment_id
} );
},
shouldBeCropped: function() {
if (this.get('themeFlexWidth') === true &&
this.get('themeFlexHeight') === true) {
return false;
}
if (this.get('themeFlexWidth') === true &&
this.get('themeHeight') === this.get('imageHeight')) {
return false;
}
if (this.get('themeFlexHeight') === true &&
this.get('themeWidth') === this.get('imageWidth')) {
return false;
}
if (this.get('themeWidth') === this.get('imageWidth') &&
this.get('themeHeight') === this.get('imageHeight')) {
return false;
}
if (this.get('imageWidth') <= this.get('themeWidth')) {
return false;
}
return true;
}
});
/**
* wp.customize.HeaderTool.ChoiceList
*
* @memberOf wp.customize.HeaderTool
* @alias wp.customize.HeaderTool.ChoiceList
*
* @constructor
* @augments Backbone.Collection
*/
api.HeaderTool.ChoiceList = Backbone.Collection.extend({
model: api.HeaderTool.ImageModel,
// Ordered from most recently used to least.
comparator: function(model) {
return -model.get('header').timestamp;
},
initialize: function() {
var current = api.HeaderTool.currentHeader.get('choice').replace(/^https?:\/\//, ''),
isRandom = this.isRandomChoice(api.get().header_image);
// Overridable by an extending class.
if (!this.type) {
this.type = 'uploaded';
}
// Overridable by an extending class.
if (typeof this.data === 'undefined') {
this.data = _wpCustomizeHeader.uploads;
}
if (isRandom) {
// So that when adding data we don't hide regular images.
current = api.get().header_image;
}
this.on('control:setImage', this.setImage, this);
this.on('control:removeImage', this.removeImage, this);
this.on('add', this.maybeRemoveOldCrop, this);
this.on('add', this.maybeAddRandomChoice, this);
_.each(this.data, function(elt, index) {
if (!elt.attachment_id) {
elt.defaultName = index;
}
if (typeof elt.timestamp === 'undefined') {
elt.timestamp = 0;
}
this.add({
header: elt,
choice: elt.url.split('/').pop(),
selected: current === elt.url.replace(/^https?:\/\//, '')
}, { silent: true });
}, this);
if (this.size() > 0) {
this.addRandomChoice(current);
}
},
maybeRemoveOldCrop: function( model ) {
var newID = model.get( 'header' ).attachment_id || false,
oldCrop;
// Bail early if we don't have a new attachment ID.
if ( ! newID ) {
return;
}
oldCrop = this.find( function( item ) {
return ( item.cid !== model.cid && item.get( 'header' ).attachment_id === newID );
} );
// If we found an old crop, remove it from the collection.
if ( oldCrop ) {
this.remove( oldCrop );
}
},
maybeAddRandomChoice: function() {
if (this.size() === 1) {
this.addRandomChoice();
}
},
addRandomChoice: function(initialChoice) {
var isRandomSameType = RegExp(this.type).test(initialChoice),
randomChoice = 'random-' + this.type + '-image';
this.add({
header: {
timestamp: 0,
random: randomChoice,
width: 245,
height: 41
},
choice: randomChoice,
random: true,
selected: isRandomSameType
});
},
isRandomChoice: function(choice) {
return (/^random-(uploaded|default)-image$/).test(choice);
},
shouldHideTitle: function() {
return this.size() < 2;
},
setImage: function(model) {
this.each(function(m) {
m.set('selected', false);
});
if (model) {
model.set('selected', true);
}
},
removeImage: function() {
this.each(function(m) {
m.set('selected', false);
});
}
});
/**
* wp.customize.HeaderTool.DefaultsList
*
* @memberOf wp.customize.HeaderTool
* @alias wp.customize.HeaderTool.DefaultsList
*
* @constructor
* @augments wp.customize.HeaderTool.ChoiceList
* @augments Backbone.Collection
*/
api.HeaderTool.DefaultsList = api.HeaderTool.ChoiceList.extend({
initialize: function() {
this.type = 'default';
this.data = _wpCustomizeHeader.defaults;
api.HeaderTool.ChoiceList.prototype.initialize.apply(this);
}
});
})( jQuery, window.wp );
| nama | waktu | ukuran | owner | perm | aksi |
|---|---|---|---|---|---|
| .. | |||||
| codemirror/ | 2026-10-22 10:47 | 1.53 MB | 76129f60960:kunden | dxwrx-rx-r | |
| crop/ | 2014-06-05 20:34 | 19.54 KB | 76129f60960:kunden | dxwrx-rx-r | |
| dist/ | 2026-10-22 10:47 | 48.8 MB | 76129f60960:kunden | dxwrx-rx-r | |
| imgareaselect/ | 2014-06-05 20:34 | 48.39 KB | 76129f60960:kunden | dxwrx-rx-r | |
| jcrop/ | 2014-06-05 20:34 | 24.39 KB | 76129f60960:kunden | dxwrx-rx-r | |
| jquery/ | 2021-01-14 01:34 | 1.23 MB | 76129f60960:kunden | dxwrx-rx-r | |
| mediaelement/ | 2018-02-08 19:20 | 704.4 KB | 76129f60960:kunden | dxwrx-rx-r | |
| plupload/ | 2018-02-08 19:20 | 479.45 KB | 76129f60960:kunden | dxwrx-rx-r | |
| swfupload/ | 2018-02-08 19:20 | 0 B | 76129f60960:kunden | dxwrx-rx-r | |
| thickbox/ | 2014-06-05 20:35 | 30.6 KB | 76129f60960:kunden | dxwrx-rx-r | |
| tinymce/ | 2026-11-26 08:02 | 3.35 MB | 76129f60960:kunden | dxwrx-rx-r | |
| admin-bar.js | 2026-10-22 10:47 | 10.3 KB | 76129f60960:kunden | -xw-x--x-- | |
| admin-bar.min.js | 2024-08-09 01:01 | 3.41 KB | 76129f60960:kunden | -xw-x----- | |
| api-request.js | 2021-01-14 01:34 | 3.25 KB | 76129f60960:kunden | -xw-x----- | |
| api-request.min.js | 2023-02-04 23:48 | 1023 B | 76129f60960:kunden | -xw-x----- | |
| autosave.js | 2026-10-22 10:47 | 21.95 KB | 76129f60960:kunden | -xw-x--x-- | |
| autosave.min.js | 2023-07-04 19:03 | 5.67 KB | 76129f60960:kunden | -xw-x----- | |
| backbone.js | 2026-10-22 10:47 | 78.55 KB | 76129f60960:kunden | -xw-x--x-- | |
| backbone.min.js | 2026-10-22 10:47 | 23.74 KB | 76129f60960:kunden | -xw-x--x-- | |
| clipboard.js | 2023-02-04 23:48 | 26.18 KB | 76129f60960:kunden | -xw-x----- | |
| clipboard.min.js | 2023-02-04 23:48 | 8.8 KB | 76129f60960:kunden | -xw-x----- | |
| colorpicker.js | 2014-06-05 20:34 | 28.4 KB | 76129f60960:kunden | -xw-x----- | |
| colorpicker.min.js | 2026-10-22 10:47 | 16.11 KB | 76129f60960:kunden | -xw-x--x-- | |
| comment-reply.js | 2026-10-22 10:47 | 12.09 KB | 76129f60960:kunden | -xw-x--x-- | |
| comment-reply.min.js | 2026-10-22 10:47 | 2.88 KB | 76129f60960:kunden | -xw-x--x-- | |
| customize-base.js | 2023-09-21 23:24 | 25.22 KB | 76129f60960:kunden | -xw-x----- | |
| customize-base.min.js | 2023-07-04 19:03 | 7.67 KB | 76129f60960:kunden | -xw-x----- | |
| customize-loader.js | 2024-08-09 01:01 | 7.72 KB | 76129f60960:kunden | -xw-x----- | |
| customize-loader.min.js | 2023-07-04 19:03 | 3.47 KB | 76129f60960:kunden | -xw-x----- | |
| customize-models.js | 2021-01-14 01:34 | 6.66 KB | 76129f60960:kunden | -xw-x----- | |
| customize-models.min.js | 2023-07-04 19:03 | 3.59 KB | 76129f60960:kunden | -xw-x----- | |
| customize-preview-nav-menus.js | 2021-01-14 01:34 | 14.67 KB | 76129f60960:kunden | -xw-x----- | |
| customize-preview-nav-menus.min.js | 2026-10-22 10:47 | 4.92 KB | 76129f60960:kunden | -xw-x--x-- | |
| customize-preview-widgets.js | 2026-11-19 21:55 | 22.92 KB | 76129f60960:kunden | -xw-x--x-- | |
| customize-preview-widgets.min.js | 2026-11-19 21:55 | 7.66 KB | 76129f60960:kunden | -xw-x--x-- | |
| customize-preview.js | 2026-10-22 10:47 | 27.93 KB | 76129f60960:kunden | -xw-x--x-- | |
| customize-preview.min.js | 2026-10-22 10:47 | 10.75 KB | 76129f60960:kunden | -xw-x--x-- | |
| customize-selective-refresh.js | 2026-11-19 21:55 | 32.51 KB | 76129f60960:kunden | -xw-x--x-- | |
| customize-selective-refresh.min.js | 2026-11-19 21:55 | 10.47 KB | 76129f60960:kunden | -xw-x--x-- | |
| customize-views.js | 2026-10-22 10:47 | 5.1 KB | 76129f60960:kunden | -xw-x--x-- | |
| customize-views.min.js | 2026-10-22 10:47 | 2.51 KB | 76129f60960:kunden | -xw-x--x-- | |
| heartbeat.js | 2026-10-22 10:47 | 23.49 KB | 76129f60960:kunden | -xw-x--x-- | |
| heartbeat.min.js | 2026-10-22 10:47 | 5.81 KB | 76129f60960:kunden | -xw-x--x-- | |
| hoverIntent.js | 2023-02-04 23:48 | 7.06 KB | 76129f60960:kunden | -xw-x----- | |
| hoverIntent.min.js | 2023-02-04 23:48 | 1.46 KB | 76129f60960:kunden | -xw-x----- | |
| hoverintent-js.min.js | 2021-01-14 01:34 | 1.68 KB | 76129f60960:kunden | -xw-x----- | |
| imagesloaded.min.js | 2024-01-20 23:47 | 5.39 KB | 76129f60960:kunden | -xw-x----- | |
| json2.js | 2026-10-22 10:47 | 31 B | 76129f60960:kunden | -xw-x--x-- | |
| json2.min.js | 2026-10-22 10:47 | 35 B | 76129f60960:kunden | -xw-x--x-- | |
| masonry.min.js | 2021-01-14 01:34 | 23.57 KB | 76129f60960:kunden | -xw-x----- | |
| mce-view.js | 2024-01-20 23:47 | 25.24 KB | 76129f60960:kunden | -xw-x----- | |
| mce-view.min.js | 2024-01-20 23:47 | 9.54 KB | 76129f60960:kunden | -xw-x----- | |
| media-audiovideo.js | 2026-10-22 10:47 | 24.14 KB | 76129f60960:kunden | -xw-x--x-- | |
| media-audiovideo.min.js | 2026-10-22 10:47 | 11.77 KB | 76129f60960:kunden | -xw-x--x-- | |
| media-editor.js | 2026-10-22 10:47 | 28.77 KB | 76129f60960:kunden | -xw-x--x-- | |
| media-editor.min.js | 2026-10-22 10:47 | 10.83 KB | 76129f60960:kunden | -xw-x--x-- | |
| media-grid.js | 2026-10-22 10:47 | 27.1 KB | 76129f60960:kunden | -xw-x--x-- | |
| media-grid.min.js | 2026-10-22 10:47 | 13.37 KB | 76129f60960:kunden | -xw-x--x-- | |
| media-models.js | 2026-10-22 10:47 | 43.05 KB | 76129f60960:kunden | -xw-x--x-- | |
| media-models.min.js | 2026-10-22 10:47 | 13.03 KB | 76129f60960:kunden | -xw-x--x-- | |
| media-views.js | 2026-10-22 10:47 | 266.69 KB | 76129f60960:kunden | -xw-x--x-- | |
| media-views.min.js | 2026-10-22 10:47 | 108.15 KB | 76129f60960:kunden | -xw-x--x-- | |
| quicktags.js | 2021-07-24 19:08 | 22.07 KB | 76129f60960:kunden | -xw-x----- | |
| quicktags.min.js | 2023-07-04 19:03 | 10.87 KB | 76129f60960:kunden | -xw-x----- | |
| shortcode.js | 2021-01-14 01:34 | 10.51 KB | 76129f60960:kunden | -xw-x----- | |
| shortcode.min.js | 2023-02-04 23:48 | 2.58 KB | 76129f60960:kunden | -xw-x----- | |
| swfobject.js | 2026-10-22 10:47 | 0 B | 76129f60960:kunden | -xw-x--x-- | |
| swfobject.min.js | 2026-10-22 10:47 | 35 B | 76129f60960:kunden | -xw-x--x-- | |
| tw-sack.js | 2026-10-22 10:47 | 4.85 KB | 76129f60960:kunden | -xw-x--x-- | |
| tw-sack.min.js | 2023-02-04 23:48 | 3.21 KB | 76129f60960:kunden | -xw-x----- | |
| twemoji.js | 2026-10-22 10:47 | 36.31 KB | 76129f60960:kunden | -xw-x--x-- | |
| twemoji.min.js | 2026-10-22 10:47 | 19.38 KB | 76129f60960:kunden | -xw-x--x-- | |
| underscore.js | 2026-10-22 10:47 | 67.26 KB | 76129f60960:kunden | -xw-x--x-- | |
| underscore.min.js | 2026-10-22 10:47 | 18.57 KB | 76129f60960:kunden | -xw-x--x-- | |
| utils.js | 2021-01-14 01:34 | 4.56 KB | 76129f60960:kunden | -xw-x----- | |
| utils.min.js | 2023-02-04 23:48 | 1.82 KB | 76129f60960:kunden | -xw-x----- | |
| wp-ajax-response.js | 2026-10-22 10:47 | 3.81 KB | 76129f60960:kunden | -xw-x--x-- | |
| wp-ajax-response.min.js | 2026-10-22 10:47 | 2.51 KB | 76129f60960:kunden | -xw-x--x-- | |
| wp-api.js | 2026-10-22 10:47 | 45.89 KB | 76129f60960:kunden | -xw-x--x-- | |
| wp-api.min.js | 2023-07-04 19:03 | 14.34 KB | 76129f60960:kunden | -xw-x----- | |
| wp-auth-check.js | 2026-10-22 10:47 | 4.34 KB | 76129f60960:kunden | -xw-x--x-- | |
| wp-auth-check.min.js | 2026-10-22 10:47 | 1.65 KB | 76129f60960:kunden | -xw-x--x-- | |
| wp-backbone.js | 2024-08-09 01:01 | 14.88 KB | 76129f60960:kunden | -xw-x----- | |
| wp-backbone.min.js | 2023-02-04 23:48 | 2.97 KB | 76129f60960:kunden | -xw-x----- | |
| wp-custom-header.js | 2021-07-24 19:08 | 10.22 KB | 76129f60960:kunden | -xw-x----- | |
| wp-custom-header.min.js | 2023-07-04 19:03 | 4.34 KB | 76129f60960:kunden | -xw-x----- | |
| wp-embed-template.js | 2023-02-04 23:48 | 6.62 KB | 76129f60960:kunden | -xw-x----- | |
| wp-embed-template.min.js | 2023-02-04 23:48 | 3.1 KB | 76129f60960:kunden | -xw-x----- | |
| wp-embed.js | 2024-01-20 23:47 | 3.14 KB | 76129f60960:kunden | -xw-x----- | |
| wp-embed.min.js | 2024-01-20 23:47 | 1.22 KB | 76129f60960:kunden | -xw-x----- | |
| wp-emoji-loader.js | 2026-10-22 10:47 | 13.04 KB | 76129f60960:kunden | -xw-x--x-- | |
| wp-emoji-loader.min.js | 2026-10-22 10:47 | 2.91 KB | 76129f60960:kunden | -xw-x--x-- | |
| wp-emoji-release.min.js | 2026-10-22 10:47 | 22.22 KB | 76129f60960:kunden | -xw-x--x-- | |
| wp-emoji.js | 2026-10-22 10:47 | 8.59 KB | 76129f60960:kunden | -xw-x--x-- | |
| wp-emoji.min.js | 2026-10-22 10:47 | 2.79 KB | 76129f60960:kunden | -xw-x--x-- | |
| wp-list-revisions.js | 2019-06-12 20:12 | 970 B | 76129f60960:kunden | -xw-x----- | |
| wp-list-revisions.min.js | 2021-07-24 19:08 | 597 B | 76129f60960:kunden | -xw-x----- | |
| wp-lists.js | 2023-09-21 23:24 | 24.72 KB | 76129f60960:kunden | -xw-x----- | |
| wp-lists.min.js | 2023-09-21 23:24 | 7.34 KB | 76129f60960:kunden | -xw-x----- | |
| wp-pointer.js | 2021-07-24 19:08 | 9.99 KB | 76129f60960:kunden | -xw-x----- | |
| wp-pointer.min.js | 2023-02-04 23:48 | 3.54 KB | 76129f60960:kunden | -xw-x----- | |
| wp-sanitize.js | 2026-10-22 10:47 | 1.58 KB | 76129f60960:kunden | -xw-x--x-- | |
| wp-sanitize.min.js | 2026-10-22 10:47 | 402 B | 76129f60960:kunden | -xw-x--x-- | |
| wp-tooltip.js | 2026-10-22 10:47 | 1.8 KB | 76129f60960:kunden | -xw-x--x-- | |
| wp-tooltip.min.js | 2026-10-22 10:47 | 643 B | 76129f60960:kunden | -xw-x--x-- | |
| wp-util.js | 2026-10-22 10:47 | 4.58 KB | 76129f60960:kunden | -xw-x--x-- | |
| wp-util.min.js | 2026-10-22 10:47 | 1.4 KB | 76129f60960:kunden | -xw-x--x-- | |
| wpdialog.js | 2023-07-04 19:03 | 569 B | 76129f60960:kunden | -xw-x----- | |
| wpdialog.min.js | 2023-07-04 19:03 | 281 B | 76129f60960:kunden | -xw-x----- | |
| wplink.js | 2026-10-22 10:47 | 20.74 KB | 76129f60960:kunden | -xw-x--x-- | |
| wplink.min.js | 2026-10-22 10:47 | 11.05 KB | 76129f60960:kunden | -xw-x--x-- | |
| zxcvbn-async.js | 2019-06-12 20:12 | 821 B | 76129f60960:kunden | -xw-x----- | |
| zxcvbn-async.min.js | 2021-07-24 19:08 | 351 B | 76129f60960:kunden | -xw-x----- | |
| zxcvbn.min.js | 2021-01-14 01:34 | 802.97 KB | 76129f60960:kunden | -xw-x----- | |