-
+ EA8F81F08CB7F4D05F0AC7E3EDE78493621EA774E52954EF001B501E22F11D9F8A1DAFEAA5F2291C7B175D5514750C68772C703CCC51261848F85A06C1C740E6
mp-wp/wp-admin/js/gallery.js
(0 . 0)(1 . 175)
49811 jQuery(function($) {
49812 var gallerySortable;
49813 var gallerySortableInit = function() {
49814 gallerySortable = $('#media-items').sortable( {
49815 items: '.media-item',
49816 placeholder: 'sorthelper',
49817 axis: 'y',
49818 distance: 2,
49819 update: galleryReorder
49820 } );
49821 }
49822
49823 // When an update has occurred, adjust the order for each item
49824 var galleryReorder = function(e, sort) {
49825 jQuery.each(sort['element'].sortable('toArray'), function(i, id) {
49826 jQuery('#' + id + ' .menu_order input')[0].value = (1+i);
49827 });
49828 }
49829
49830 // initialize sortable
49831 gallerySortableInit();
49832 });
49833
49834 jQuery(document).ready(function($){
49835 $('.menu_order_input').each(function(){
49836 if ( this.value == '0' ) this.value = '';
49837 });
49838
49839 if ( $('#media-items>*').length > 1 ) {
49840 var w = wpgallery.getWin();
49841
49842 $('#save-all, #gallery-settings').show();
49843 if ( typeof w.tinyMCE != 'undefined' && w.tinyMCE.activeEditor && ! w.tinyMCE.activeEditor.isHidden() ) {
49844 wpgallery.mcemode = true;
49845 wpgallery.init();
49846 } else {
49847 $('#insert-gallery').show();
49848 }
49849 }
49850 });
49851
49852 jQuery(window).unload( function () { tinymce = tinyMCE = wpgallery = null; } ); // Cleanup
49853
49854 /* gallery settings */
49855 var tinymce = null, tinyMCE;
49856
49857 var wpgallery = {
49858 mcemode : false,
49859 editor : {},
49860 dom : {},
49861 is_update : false,
49862 el : {},
49863
49864 I : function(e) {
49865 return document.getElementById(e);
49866 },
49867
49868 init: function() {
49869 var t = this, li, q, i, it, w = t.getWin();
49870
49871 if ( ! t.mcemode ) return;
49872
49873 li = ('' + document.location.search).replace(/^\?/, '').split('&');
49874 q = {};
49875 for (i=0; i<li.length; i++) {
49876 it = li[i].split('=');
49877 q[unescape(it[0])] = unescape(it[1]);
49878 }
49879
49880 if (q.mce_rdomain)
49881 document.domain = q.mce_rdomain;
49882
49883 // Find window & API
49884 tinymce = w.tinymce;
49885 tinyMCE = w.tinyMCE;
49886 t.editor = tinymce.EditorManager.activeEditor;
49887
49888 t.setup();
49889 },
49890
49891 getWin : function() {
49892 return window.dialogArguments || opener || parent || top;
49893 },
49894
49895 restoreSelection : function() {
49896 var t = this;
49897
49898 if (tinymce.isIE)
49899 t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark);
49900 },
49901
49902 setup : function() {
49903 var t = this, a, f = document.forms[0], ed = t.editor, el, g;
49904 if ( ! t.mcemode ) return;
49905
49906 t.restoreSelection();
49907 t.el = ed.selection.getNode();
49908
49909 if ( t.el.nodeName != 'IMG' || ! ed.dom.hasClass(t.el, 'wpGallery') ) {
49910 if ( (g = ed.dom.select('img.wpGallery')) && g[0] ) {
49911 t.el = g[0];
49912 } else {
49913 if ( getUserSetting('galfile') == '1' ) t.I('linkto-file').checked = "checked";
49914 if ( getUserSetting('galdesc') == '1' ) t.I('order-desc').checked = "checked";
49915 if ( getUserSetting('galcols') ) t.I('columns').value = getUserSetting('galcols');
49916 if ( getUserSetting('galord') ) t.I('orderby').value = getUserSetting('galord');
49917 jQuery('#insert-gallery').show();
49918 return;
49919 }
49920 }
49921
49922 a = ed.dom.getAttrib(t.el, 'title');
49923 a = ed.dom.decode(a);
49924
49925 if ( a ) {
49926 jQuery('#update-gallery').show();
49927 t.is_update = true;
49928
49929 var columns = a.match(/columns=['"]([0-9]+)['"]/), link = a.match(/link=['"]([^'"]+)['"]/i);
49930 var order = a.match(/order=['"]([^'"]+)['"]/i), orderby = a.match(/orderby=['"]([^'"]+)['"]/i), all = '';
49931
49932 if ( link && link[1] ) t.I('linkto-file').checked = "checked";
49933 if ( order && order[1] ) t.I('order-desc').checked = "checked";
49934 if ( columns && columns[1] ) t.I('columns').value = ''+columns[1];
49935 if ( orderby && orderby[1] ) t.I('orderby').value = orderby[1];
49936 } else {
49937 jQuery('#insert-gallery').show();
49938 }
49939 },
49940
49941 update : function() {
49942 var t = this, ed = t.editor, el, all = '';
49943
49944 if ( ! t.mcemode || ! t.is_update ) {
49945 var s = '[gallery'+t.getSettings()+']';
49946 t.getWin().send_to_editor(s);
49947 return;
49948 }
49949
49950 if (t.el.nodeName != 'IMG') return;
49951
49952 all = ed.dom.decode(ed.dom.getAttrib(t.el, 'title'));
49953 all = all.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi, '');
49954 all += t.getSettings();
49955
49956 ed.dom.setAttrib(t.el, 'title', all);
49957 t.getWin().tb_remove();
49958 },
49959
49960 getSettings : function() {
49961 var I = this.I, s = '';
49962
49963 if ( I('linkto-file').checked ) {
49964 s += ' link="file"';
49965 setUserSetting('galfile', '1');
49966 }
49967
49968 if ( I('order-desc').checked ) {
49969 s += ' order="DESC"';
49970 setUserSetting('galdesc', '1');
49971 }
49972
49973 if ( I('columns').value != 3 ) {
49974 s += ' columns="'+I('columns').value+'"';
49975 setUserSetting('galcols', I('columns').value);
49976 }
49977
49978 if ( I('orderby').value != 'menu_order' ) {
49979 s += ' orderby="'+I('orderby').value+'"';
49980 setUserSetting('galord', I('orderby').value);
49981 }
49982
49983 return s;
49984 }
49985 };