-
+ 4F7166D52BF9EB94595733AE779068F3C65A0665E53B5CB460006681BF3CBC169CE6FE17D6B631F848042BC8D973FD37BFB264F6A933C319E57D142D7B57E39E
mp-wp/wp-includes/js/tinymce/themes/advanced/js/image.js
(0 . 0)(1 . 254)
128694 var ImageDialog = {
128695 preInit : function() {
128696 var url;
128697
128698 tinyMCEPopup.requireLangPack();
128699
128700 if (url = tinyMCEPopup.getParam("external_image_list_url"))
128701 document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
128702 },
128703
128704 init : function() {
128705 var f = document.forms[0], ed = tinyMCEPopup.editor;
128706
128707 // Setup browse button
128708 document.getElementById('srcbrowsercontainer').innerHTML = getBrowserHTML('srcbrowser','src','image','theme_advanced_image');
128709 if (isVisible('srcbrowser'))
128710 document.getElementById('src').style.width = '180px';
128711
128712 e = ed.selection.getNode();
128713
128714 this.fillFileList('image_list', 'tinyMCEImageList');
128715
128716 if (e.nodeName == 'IMG') {
128717 f.src.value = ed.dom.getAttrib(e, 'src');
128718 f.alt.value = ed.dom.getAttrib(e, 'alt');
128719 f.border.value = this.getAttrib(e, 'border');
128720 f.vspace.value = this.getAttrib(e, 'vspace');
128721 f.hspace.value = this.getAttrib(e, 'hspace');
128722 f.width.value = ed.dom.getAttrib(e, 'width');
128723 f.height.value = ed.dom.getAttrib(e, 'height');
128724 f.insert.value = ed.getLang('update');
128725 f.class_name.value = ed.dom.getAttrib(e, 'class');
128726 this.styleVal = ed.dom.getAttrib(e, 'style');
128727 selectByValue(f, 'image_list', f.src.value);
128728 selectByValue(f, 'align', this.getAttrib(e, 'align'));
128729 this.updateStyle();
128730 }
128731 },
128732
128733 fillFileList : function(id, l) {
128734 var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl;
128735
128736 l = window[l];
128737
128738 if (l && l.length > 0) {
128739 lst.options[lst.options.length] = new Option('', '');
128740
128741 tinymce.each(l, function(o) {
128742 lst.options[lst.options.length] = new Option(o[0], o[1]);
128743 });
128744 } else
128745 dom.remove(dom.getParent(id, 'tr'));
128746 },
128747
128748 update : function() {
128749 var f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, args = {}, el;
128750
128751 tinyMCEPopup.restoreSelection();
128752
128753 if (f.src.value === '') {
128754 if (ed.selection.getNode().nodeName == 'IMG') {
128755 ed.dom.remove(ed.selection.getNode());
128756 ed.execCommand('mceRepaint');
128757 }
128758
128759 tinyMCEPopup.close();
128760 return;
128761 }
128762
128763 if (!ed.settings.inline_styles) {
128764 args = tinymce.extend(args, {
128765 vspace : nl.vspace.value,
128766 hspace : nl.hspace.value,
128767 border : nl.border.value,
128768 align : getSelectValue(f, 'align')
128769 });
128770 } else
128771 args.style = this.styleVal;
128772
128773 tinymce.extend(args, {
128774 src : f.src.value,
128775 alt : f.alt.value,
128776 width : f.width.value,
128777 height : f.height.value,
128778 'class' : f.class_name.value
128779 });
128780
128781 el = ed.selection.getNode();
128782
128783 if (el && el.nodeName == 'IMG') {
128784 ed.dom.setAttribs(el, args);
128785 } else {
128786 ed.execCommand('mceInsertContent', false, '<img id="__mce_tmp" />', {skip_undo : 1});
128787 ed.dom.setAttribs('__mce_tmp', args);
128788 ed.dom.setAttrib('__mce_tmp', 'id', '');
128789 ed.undoManager.add();
128790 }
128791
128792 tinyMCEPopup.close();
128793 },
128794
128795 updateStyle : function() {
128796 var dom = tinyMCEPopup.dom, st, v, cls, oldcls, rep, f = document.forms[0];
128797
128798 if (tinyMCEPopup.editor.settings.inline_styles) {
128799 st = tinyMCEPopup.dom.parseStyle(this.styleVal);
128800
128801 // Handle align
128802 v = getSelectValue(f, 'align');
128803 cls = f.class_name.value || '';
128804 cls = cls ? cls.replace(/alignright\s*|alignleft\s*|aligncenter\s*/g, '') : '';
128805 cls = cls ? cls.replace(/^\s*(.+?)\s*$/, '$1') : '';
128806 if (v) {
128807 if (v == 'left' || v == 'right') {
128808 st['float'] = v;
128809 delete st['vertical-align'];
128810 oldcls = cls ? ' '+cls : '';
128811 f.class_name.value = 'align' + v + oldcls;
128812 } else {
128813 st['vertical-align'] = v;
128814 delete st['float'];
128815 f.class_name.value = cls;
128816 }
128817 } else {
128818 delete st['float'];
128819 delete st['vertical-align'];
128820 f.class_name.value = cls;
128821 }
128822
128823 // Handle border
128824 v = f.border.value;
128825 if (v || v == '0') {
128826 if (v == '0')
128827 st['border'] = '0';
128828 else
128829 st['border'] = v + 'px solid black';
128830 } else
128831 delete st['border'];
128832
128833 // Handle hspace
128834 v = f.hspace.value;
128835 if (v) {
128836 delete st['margin'];
128837 st['margin-left'] = v + 'px';
128838 st['margin-right'] = v + 'px';
128839 } else {
128840 delete st['margin-left'];
128841 delete st['margin-right'];
128842 }
128843
128844 // Handle vspace
128845 v = f.vspace.value;
128846 if (v) {
128847 delete st['margin'];
128848 st['margin-top'] = v + 'px';
128849 st['margin-bottom'] = v + 'px';
128850 } else {
128851 delete st['margin-top'];
128852 delete st['margin-bottom'];
128853 }
128854
128855 // Merge
128856 st = tinyMCEPopup.dom.parseStyle(dom.serializeStyle(st));
128857 this.styleVal = dom.serializeStyle(st);
128858 }
128859 },
128860
128861 getAttrib : function(e, at) {
128862 var ed = tinyMCEPopup.editor, dom = ed.dom, v, v2;
128863
128864 if (ed.settings.inline_styles) {
128865 switch (at) {
128866 case 'align':
128867 if (v = dom.getStyle(e, 'float'))
128868 return v;
128869
128870 if (v = dom.getStyle(e, 'vertical-align'))
128871 return v;
128872
128873 break;
128874
128875 case 'hspace':
128876 v = dom.getStyle(e, 'margin-left')
128877 v2 = dom.getStyle(e, 'margin-right');
128878 if (v && v == v2)
128879 return parseInt(v.replace(/[^0-9]/g, ''));
128880
128881 break;
128882
128883 case 'vspace':
128884 v = dom.getStyle(e, 'margin-top')
128885 v2 = dom.getStyle(e, 'margin-bottom');
128886 if (v && v == v2)
128887 return parseInt(v.replace(/[^0-9]/g, ''));
128888
128889 break;
128890
128891 case 'border':
128892 v = 0;
128893
128894 tinymce.each(['top', 'right', 'bottom', 'left'], function(sv) {
128895 sv = dom.getStyle(e, 'border-' + sv + '-width');
128896
128897 // False or not the same as prev
128898 if (!sv || (sv != v && v !== 0)) {
128899 v = 0;
128900 return false;
128901 }
128902
128903 if (sv)
128904 v = sv;
128905 });
128906
128907 if (v)
128908 return parseInt(v.replace(/[^0-9]/g, ''));
128909
128910 break;
128911 }
128912 }
128913
128914 if (v = dom.getAttrib(e, at))
128915 return v;
128916
128917 return '';
128918 },
128919
128920 resetImageData : function() {
128921 var f = document.forms[0];
128922
128923 f.width.value = f.height.value = "";
128924 },
128925
128926 updateImageData : function() {
128927 var f = document.forms[0], t = ImageDialog;
128928
128929 if (f.width.value == "")
128930 f.width.value = t.preloadImg.width;
128931
128932 if (f.height.value == "")
128933 f.height.value = t.preloadImg.height;
128934 },
128935
128936 getImageData : function() {
128937 var f = document.forms[0];
128938
128939 this.preloadImg = new Image();
128940 this.preloadImg.onload = this.updateImageData;
128941 this.preloadImg.onerror = this.resetImageData;
128942 this.preloadImg.src = tinyMCEPopup.editor.documentBaseURI.toAbsolute(f.src.value);
128943 }
128944 };
128945
128946 ImageDialog.preInit();
128947 tinyMCEPopup.onInit.add(ImageDialog.init, ImageDialog);