编辑:customize-models.js
/** * @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 );
保存文件
位置:
home
/
londongranite
/
public_html
/
wp-includes
/
js
批量上传
创建
创建
批量权限
批量删除
名称
权限
大小
修改时间
操作
↑ 返回上级
-
-
-
-
codemirror
drwxr-xr-x
-
2026-05-21 23:23
权限
删除
重命名
crop
drwxr-xr-x
-
2024-10-28 16:19
权限
删除
重命名
dist
drwxr-xr-x
-
2026-07-17 19:44
权限
删除
重命名
imgareaselect
drwxr-xr-x
-
2024-10-28 16:19
权限
删除
重命名
jcrop
drwxr-xr-x
-
2024-10-28 16:19
权限
删除
重命名
jquery
drwxr-xr-x
-
2026-08-17 04:21
权限
删除
重命名
mediaelement
drwxr-xr-x
-
2024-10-28 16:19
权限
删除
重命名
plupload
drwxr-xr-x
-
2024-10-28 16:19
权限
删除
重命名
swfupload
drwxr-xr-x
-
2024-10-28 16:19
权限
删除
重命名
thickbox
drwxr-xr-x
-
2024-10-28 16:19
权限
删除
重命名
tinymce
drwxr-xr-x
-
2024-10-28 16:19
权限
删除
重命名
admin-bar.min.js
-rw-r--r--
3.41 KB
2024-05-11 22:28
编辑
下载
权限
删除
重命名
api-request.js
-rw-r--r--
3.25 KB
2020-12-01 08:44
编辑
下载
权限
删除
重命名
backbone.js
-rw-r--r--
78.55 KB
2026-05-21 23:23
编辑
下载
权限
删除
重命名
colorpicker.js
-rw-r--r--
28.4 KB
2012-11-17 20:11
编辑
下载
权限
删除
重命名
colorpicker.min.js
-rw-r--r--
16.11 KB
2026-03-15 20:43
编辑
下载
权限
删除
重命名
comment-reply.js
-rw-r--r--
12.22 KB
2024-09-04 00:36
编辑
下载
权限
删除
重命名
customize-base.js
-rw-r--r--
25.22 KB
2023-05-20 14:19
编辑
下载
权限
删除
重命名
customize-loader.js
-rw-r--r--
7.72 KB
2024-04-12 21:47
编辑
下载
权限
删除
重命名
customize-loader.min.js
-rw-r--r--
3.47 KB
2023-02-02 21:36
编辑
下载
权限
删除
重命名
customize-models.js
-rw-r--r--
6.66 KB
2020-06-25 16:43
编辑
下载
权限
删除
重命名
customize-preview-nav-menus.js
-rw-r--r--
14.67 KB
2020-07-28 03:35
编辑
下载
权限
删除
重命名
customize-preview-nav-menus.min.js
-rw-r--r--
4.92 KB
2026-03-15 20:43
编辑
下载
权限
删除
重命名
customize-preview-widgets.js
-rw-r--r--
22.71 KB
2020-06-20 16:58
编辑
下载
权限
删除
重命名
customize-preview-widgets.min.js
-rw-r--r--
7.64 KB
2026-03-15 20:43
编辑
下载
权限
删除
重命名
customize-preview.min.js
-rw-r--r--
10.75 KB
2026-03-15 20:43
编辑
下载
权限
删除
重命名
customize-selective-refresh.js
-rw-r--r--
32.55 KB
2024-04-12 21:47
编辑
下载
权限
删除
重命名
customize-selective-refresh.min.js
-rw-r--r--
10.44 KB
2026-03-15 20:43
编辑
下载
权限
删除
重命名
customize-views.min.js
-rw-r--r--
2.51 KB
2026-03-15 20:43
编辑
下载
权限
删除
重命名
hoverIntent.min.js
-rw-r--r--
1.46 KB
2024-06-27 16:55
编辑
下载
权限
删除
重命名
hoverintent-js.min.js
-rw-r--r--
1.68 KB
2019-12-10 06:03
编辑
下载
权限
删除
重命名
json2.js
-rw-r--r--
31 B
2026-03-15 20:43
编辑
下载
权限
删除
重命名
mce-view.js
-rw-r--r--
25.24 KB
2023-10-10 01:31
编辑
下载
权限
删除
重命名
mce-view.min.js
-rw-r--r--
9.54 KB
2024-06-27 16:55
编辑
下载
权限
删除
重命名
media-audiovideo.js
-rw-r--r--
24.13 KB
2026-05-21 23:23
编辑
下载
权限
删除
重命名
media-audiovideo.min.js
-rw-r--r--
11.76 KB
2026-05-21 23:23
编辑
下载
权限
删除
重命名
media-editor.js
-rw-r--r--
28.77 KB
2026-05-21 23:23
编辑
下载
权限
删除
重命名
media-editor.min.js
-rw-r--r--
10.83 KB
2026-05-21 23:23
编辑
下载
权限
删除
重命名
quicktags.js
-rw-r--r--
22.07 KB
2021-09-09 03:29
编辑
下载
权限
删除
重命名
quicktags.min.js
-rw-r--r--
10.87 KB
2023-02-02 21:36
编辑
下载
权限
删除
重命名
shortcode.js
-rw-r--r--
10.51 KB
2020-01-29 05:45
编辑
下载
权限
删除
重命名
tw-sack.js
-rw-r--r--
4.85 KB
2026-03-15 20:43
编辑
下载
权限
删除
重命名
twemoji.min.js
-rw-r--r--
19.38 KB
2026-07-10 03:34
编辑
下载
权限
删除
重命名
underscore.js
-rw-r--r--
67.26 KB
2026-05-21 23:23
编辑
下载
权限
删除
重命名
underscore.min.js
-rw-r--r--
18.57 KB
2026-05-21 23:23
编辑
下载
权限
删除
重命名
utils.js
-rw-r--r--
4.56 KB
2020-01-29 05:45
编辑
下载
权限
删除
重命名
wp-ajax-response.js
-rw-r--r--
3.81 KB
2026-03-15 20:43
编辑
下载
权限
删除
重命名
wp-ajax-response.min.js
-rw-r--r--
2.51 KB
2026-03-15 20:43
编辑
下载
权限
删除
重命名
wp-api.js
-rw-r--r--
45.88 KB
2023-01-10 14:30
编辑
下载
权限
删除
重命名
wp-auth-check.js
-rw-r--r--
4.34 KB
2026-05-21 23:23
编辑
下载
权限
删除
重命名
wp-auth-check.min.js
-rw-r--r--
1.65 KB
2026-05-21 23:23
编辑
下载
权限
删除
重命名
wp-backbone.min.js
-rw-r--r--
2.97 KB
2022-04-09 00:07
编辑
下载
权限
删除
重命名
wp-custom-header.js
-rw-r--r--
10.22 KB
2021-04-10 16:40
编辑
下载
权限
删除
重命名
wp-custom-header.min.js
-rw-r--r--
4.34 KB
2023-02-02 21:36
编辑
下载
权限
删除
重命名
wp-embed-template.js
-rw-r--r--
6.62 KB
2021-11-11 07:49
编辑
下载
权限
删除
重命名
wp-embed-template.min.js
-rw-r--r--
3.1 KB
2024-06-27 16:55
编辑
下载
权限
删除
重命名
wp-embed.js
-rw-r--r--
3.14 KB
2023-08-10 23:49
编辑
下载
权限
删除
重命名
wp-emoji-loader.js
-rw-r--r--
13.04 KB
2026-08-06 19:42
编辑
下载
权限
删除
重命名
wp-emoji-loader.min.js
-rw-r--r--
2.91 KB
2026-08-06 19:42
编辑
下载
权限
删除
重命名
wp-emoji-release.min.js
-rw-r--r--
22.22 KB
2026-07-10 03:34
编辑
下载
权限
删除
重命名
wp-emoji.min.js
-rw-r--r--
2.79 KB
2026-03-15 20:43
编辑
下载
权限
删除
重命名
wp-list-revisions.js
-rw-r--r--
970 B
2018-06-28 06:30
编辑
下载
权限
删除
重命名
wp-list-revisions.min.js
-rw-r--r--
597 B
2021-01-06 20:29
编辑
下载
权限
删除
重命名
wp-lists.js
-rw-r--r--
24.72 KB
2023-06-24 18:32
编辑
下载
权限
删除
重命名
wp-lists.min.js
-rw-r--r--
7.34 KB
2023-06-24 18:32
编辑
下载
权限
删除
重命名
wp-pointer.js
-rw-r--r--
9.99 KB
2021-02-17 01:25
编辑
下载
权限
删除
重命名
wp-sanitize.js
-rw-r--r--
1.58 KB
2026-05-21 23:23
编辑
下载
权限
删除
重命名
wp-sanitize.min.js
-rw-r--r--
402 B
2026-05-21 23:23
编辑
下载
权限
删除
重命名
wp-util.min.js
-rw-r--r--
1.4 KB
2026-03-10 20:40
编辑
下载
权限
删除
重命名
wpdialog.js
-rw-r--r--
569 B
2023-01-25 02:13
编辑
下载
权限
删除
重命名
wpdialog.min.js
-rw-r--r--
281 B
2023-01-25 02:13
编辑
下载
权限
删除
重命名