wp/wp-admin/js/gallery.js
author ymh <ymh.work@gmail.com>
Fri, 05 Sep 2025 18:52:52 +0200
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
permissions -rw-r--r--
Update WordPress to latest version (6.7) - Sync WordPress core files from latest release - Updated admin interface, blocks, and core functionality - Enhanced block editor features and performance - Security updates and bug fixes - Preserved custom wp-content directory and configuration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     1
/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     2
 * @output wp-admin/js/gallery.js
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     3
 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     4
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     5
/* global unescape, getUserSetting, setUserSetting, wpgallery, tinymce */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
     6
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
     7
jQuery( function($) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
     8
	var gallerySortable, gallerySortableInit, sortIt, clearAll, w, desc = false;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
	gallerySortableInit = function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
		gallerySortable = $('#media-items').sortable( {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
			items: 'div.media-item',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
			placeholder: 'sorthelper',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
			axis: 'y',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
			distance: 2,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
			handle: 'div.filename',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    17
			stop: function() {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    18
				// When an update has occurred, adjust the order for each item.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
				var all = $('#media-items').sortable('toArray'), len = all.length;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
				$.each(all, function(i, id) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
					var order = desc ? (len - i) : (1 + i);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
					$('#' + id + ' .menu_order input').val(order);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
				});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
		} );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    26
	};
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
	sortIt = function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
		var all = $('.menu_order_input'), len = all.length;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
		all.each(function(i){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
			var order = desc ? (len - i) : (1 + i);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
			$(this).val(order);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
		});
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    34
	};
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
	clearAll = function(c) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
		c = c || 0;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    38
		$('.menu_order_input').each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    39
			if ( this.value === '0' || c ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    40
				this.value = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    41
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
		});
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    43
	};
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    45
	$('#asc').on( 'click', function( e ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    46
		e.preventDefault();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    47
		desc = false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    48
		sortIt();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    49
	});
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    50
	$('#desc').on( 'click', function( e ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    51
		e.preventDefault();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    52
		desc = true;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    53
		sortIt();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    54
	});
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    55
	$('#clear').on( 'click', function( e ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    56
		e.preventDefault();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    57
		clearAll(1);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    58
	});
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    59
	$('#showall').on( 'click', function( e ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    60
		e.preventDefault();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
		$('#sort-buttons span a').toggle();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
		$('a.describe-toggle-on').hide();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
		$('a.describe-toggle-off, table.slidetoggle').show();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
		$('img.pinkynail').toggle(false);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
	});
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    66
	$('#hideall').on( 'click', function( e ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    67
		e.preventDefault();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
		$('#sort-buttons span a').toggle();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
		$('a.describe-toggle-on').show();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
		$('a.describe-toggle-off, table.slidetoggle').hide();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
		$('img.pinkynail').toggle(true);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
	});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    74
	// Initialize sortable.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
	gallerySortableInit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
	clearAll();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
	if ( $('#media-items>*').length > 1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
		w = wpgallery.getWin();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
		$('#save-all, #gallery-settings').show();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    82
		if ( typeof w.tinyMCE !== 'undefined' && w.tinyMCE.activeEditor && ! w.tinyMCE.activeEditor.isHidden() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
			wpgallery.mcemode = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
			wpgallery.init();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
			$('#insert-gallery').show();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
/* gallery settings */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    92
window.tinymce = null;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    94
window.wpgallery = {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
	mcemode : false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
	editor : {},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
	dom : {},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
	is_update : false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
	el : {},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
	I : function(e) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
		return document.getElementById(e);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
	},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
	init: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
		var t = this, li, q, i, it, w = t.getWin();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   108
		if ( ! t.mcemode ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   109
			return;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   110
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
		li = ('' + document.location.search).replace(/^\?/, '').split('&');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
		q = {};
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
		for (i=0; i<li.length; i++) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
			it = li[i].split('=');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
			q[unescape(it[0])] = unescape(it[1]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   119
		if ( q.mce_rdomain ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
			document.domain = q.mce_rdomain;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   121
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   123
		// Find window & API.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   124
		window.tinymce = w.tinymce;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   125
		window.tinyMCE = w.tinyMCE;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
		t.editor = tinymce.EditorManager.activeEditor;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
		t.setup();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
	},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
	getWin : function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
		return window.dialogArguments || opener || parent || top;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
	},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
	setup : function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
		var t = this, a, ed = t.editor, g, columns, link, order, orderby;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   137
		if ( ! t.mcemode ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   138
			return;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   139
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
		t.el = ed.selection.getNode();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   143
		if ( t.el.nodeName !== 'IMG' || ! ed.dom.hasClass(t.el, 'wpGallery') ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   144
			if ( ( g = ed.dom.select('img.wpGallery') ) && g[0] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
				t.el = g[0];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
			} else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   147
				if ( getUserSetting('galfile') === '1' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   148
					t.I('linkto-file').checked = 'checked';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   149
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   150
				if ( getUserSetting('galdesc') === '1' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   151
					t.I('order-desc').checked = 'checked';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   152
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   153
				if ( getUserSetting('galcols') ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   154
					t.I('columns').value = getUserSetting('galcols');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   155
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   156
				if ( getUserSetting('galord') ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   157
					t.I('orderby').value = getUserSetting('galord');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   158
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
				jQuery('#insert-gallery').show();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
				return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
		a = ed.dom.getAttrib(t.el, 'title');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
		a = ed.dom.decode(a);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
		if ( a ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
			jQuery('#update-gallery').show();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
			t.is_update = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
			columns = a.match(/columns=['"]([0-9]+)['"]/);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
			link = a.match(/link=['"]([^'"]+)['"]/i);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
			order = a.match(/order=['"]([^'"]+)['"]/i);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
			orderby = a.match(/orderby=['"]([^'"]+)['"]/i);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   176
			if ( link && link[1] ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   177
				t.I('linkto-file').checked = 'checked';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   178
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   179
			if ( order && order[1] ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   180
				t.I('order-desc').checked = 'checked';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   181
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   182
			if ( columns && columns[1] ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   183
				t.I('columns').value = '' + columns[1];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   184
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   185
			if ( orderby && orderby[1] ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   186
				t.I('orderby').value = orderby[1];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   187
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
			jQuery('#insert-gallery').show();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
	},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
	update : function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
		var t = this, ed = t.editor, all = '', s;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
		if ( ! t.mcemode || ! t.is_update ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   197
			s = '[gallery' + t.getSettings() + ']';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
			t.getWin().send_to_editor(s);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   202
		if ( t.el.nodeName !== 'IMG' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   203
			return;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   204
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   206
		all = ed.dom.decode( ed.dom.getAttrib( t.el, 'title' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
		all = all.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi, '');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
		all += t.getSettings();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
		ed.dom.setAttrib(t.el, 'title', all);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
		t.getWin().tb_remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
	},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
	getSettings : function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
		var I = this.I, s = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
		if ( I('linkto-file').checked ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
			s += ' link="file"';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
			setUserSetting('galfile', '1');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
		if ( I('order-desc').checked ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
			s += ' order="DESC"';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
			setUserSetting('galdesc', '1');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   227
		if ( I('columns').value !== 3 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   228
			s += ' columns="' + I('columns').value + '"';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
			setUserSetting('galcols', I('columns').value);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   232
		if ( I('orderby').value !== 'menu_order' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   233
			s += ' orderby="' + I('orderby').value + '"';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
			setUserSetting('galord', I('orderby').value);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
		return s;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
};