-
+ F9D69607F5708C2E0D3DA1E801C80A55F8DAD6CBF5FED2E5A1C8EAAFCCD175F6EB8516C1FAA33599109D0905DFF0862D4ECCCE0F506C3811ACB9581B5E25B5E5
mp-wp/wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.js
(0 . 0)(1 . 174)
126533
126534 (function() {
126535 tinymce.create('tinymce.plugins.wpGallery', {
126536
126537 init : function(ed, url) {
126538 var t = this;
126539
126540 t.url = url;
126541 t._createButtons();
126542
126543 // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...');
126544 ed.addCommand('WP_Gallery', function() {
126545 var el = ed.selection.getNode(), vp = tinymce.DOM.getViewPort(), W = ( 720 < vp.w ) ? 720 : vp.w;
126546
126547 if ( el.nodeName != 'IMG' ) return;
126548 if ( ed.dom.getAttrib(el, 'class').indexOf('wpGallery') == -1 ) return;
126549
126550 var post_id = tinymce.DOM.get('post_ID').value;
126551 tb_show('', tinymce.documentBaseURL + '/media-upload.php?post_id='+post_id+'&tab=gallery&TB_iframe=true');
126552
126553 tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' );
126554 });
126555
126556 ed.onInit.add(function(ed) {
126557 tinymce.dom.Event.add(ed.getWin(), 'scroll', function(e) {
126558 ed.plugins.wpgallery.hideButtons();
126559 });
126560 });
126561
126562 ed.onBeforeExecCommand.add(function(ed, cmd, ui, val) {
126563 ed.plugins.wpgallery.hideButtons();
126564 });
126565
126566 ed.onSaveContent.add(function(ed, o) {
126567 ed.plugins.wpgallery.hideButtons();
126568 });
126569
126570 ed.onMouseUp.add(function(ed, e) {
126571 if ( tinymce.isOpera ) {
126572 if ( e.target.nodeName == 'IMG' )
126573 ed.plugins.wpgallery.showButtons(e.target);
126574 }
126575
126576 });
126577
126578 ed.onMouseDown.add(function(ed, e) {
126579 if ( tinymce.isOpera || e.target.nodeName != 'IMG' ) {
126580 t.hideButtons();
126581 return;
126582 }
126583 ed.plugins.wpgallery.showButtons(e.target);
126584 });
126585
126586 ed.onBeforeSetContent.add(function(ed, o) {
126587 o.content = t._do_gallery(o.content);
126588 });
126589
126590 ed.onPostProcess.add(function(ed, o) {
126591 if (o.get)
126592 o.content = t._get_gallery(o.content);
126593 });
126594 },
126595
126596 _do_gallery : function(co) {
126597 return co.replace(/\[gallery([^\]]*)\]/g, function(a,b){
126598 return '<img src="'+tinymce.baseURL+'/plugins/wpgallery/img/t.gif" class="wpGallery mceItem" title="gallery'+tinymce.DOM.encode(b)+'" />';
126599 });
126600 },
126601
126602 _get_gallery : function(co) {
126603
126604 function getAttr(s, n) {
126605 n = new RegExp(n + '=\"([^\"]+)\"', 'g').exec(s);
126606 return n ? tinymce.DOM.decode(n[1]) : '';
126607 };
126608
126609 return co.replace(/(?:<p[^>]*>)*(<img[^>]+>)(?:<\/p>)*/g, function(a,im) {
126610 var cls = getAttr(im, 'class');
126611
126612 if ( cls.indexOf('wpGallery') != -1 )
126613 return '<p>['+tinymce.trim(getAttr(im, 'title'))+']</p>';
126614
126615 return a;
126616 });
126617 },
126618
126619 showButtons : function(n) {
126620 var t = this, ed = tinyMCE.activeEditor, p1, p2, vp, DOM = tinymce.DOM, X, Y;
126621
126622 if (ed.dom.getAttrib(n, 'class').indexOf('wpGallery') == -1)
126623 return;
126624
126625 vp = ed.dom.getViewPort(ed.getWin());
126626 p1 = DOM.getPos(ed.getContentAreaContainer());
126627 p2 = ed.dom.getPos(n);
126628
126629 X = Math.max(p2.x - vp.x, 0) + p1.x;
126630 Y = Math.max(p2.y - vp.y, 0) + p1.y;
126631
126632 DOM.setStyles('wp_gallerybtns', {
126633 'top' : Y+5+'px',
126634 'left' : X+5+'px',
126635 'display' : 'block'
126636 });
126637
126638 t.btnsTout = window.setTimeout( function(){ed.plugins.wpgallery.hideButtons();}, 5000 );
126639 },
126640
126641 hideButtons : function() {
126642 if ( tinymce.DOM.isHidden('wp_gallerybtns') ) return;
126643
126644 tinymce.DOM.hide('wp_gallerybtns');
126645 window.clearTimeout(this.btnsTout);
126646 },
126647
126648 _createButtons : function() {
126649 var t = this, ed = tinyMCE.activeEditor, DOM = tinymce.DOM;
126650
126651 DOM.remove('wp_gallerybtns');
126652
126653 var wp_gallerybtns = DOM.add(document.body, 'div', {
126654 id : 'wp_gallerybtns',
126655 style : 'display:none;'
126656 });
126657
126658 var wp_editgallery = DOM.add('wp_gallerybtns', 'img', {
126659 src : t.url+'/img/edit.png',
126660 id : 'wp_editgallery',
126661 width : '24',
126662 height : '24',
126663 title : ed.getLang('wordpress.editgallery')
126664 });
126665
126666 wp_editgallery.onmousedown = function(e) {
126667 var ed = tinyMCE.activeEditor;
126668 ed.windowManager.bookmark = ed.selection.getBookmark('simple');
126669 ed.execCommand("WP_Gallery");
126670 this.parentNode.style.display = 'none';
126671 };
126672
126673 var wp_delgallery = DOM.add('wp_gallerybtns', 'img', {
126674 src : t.url+'/img/delete.png',
126675 id : 'wp_delgallery',
126676 width : '24',
126677 height : '24',
126678 title : ed.getLang('wordpress.delgallery')
126679 });
126680
126681 wp_delgallery.onmousedown = function(e) {
126682 var ed = tinyMCE.activeEditor, el = ed.selection.getNode();
126683
126684 if ( el.nodeName == 'IMG' && ed.dom.getAttrib(el, 'class').indexOf('wpGallery') != -1 ) {
126685 ed.dom.remove(el);
126686
126687 this.parentNode.style.display = 'none';
126688 ed.execCommand('mceRepaint');
126689 return false;
126690 }
126691 };
126692 },
126693
126694 getInfo : function() {
126695 return {
126696 longname : 'Gallery Settings',
126697 author : 'WordPress',
126698 authorurl : 'http://wordpress.org',
126699 infourl : '',
126700 version : "1.0"
126701 };
126702 }
126703 });
126704
126705 tinymce.PluginManager.add('wpgallery', tinymce.plugins.wpGallery);
126706 })();