Advertisement
Guest User

TinyMCE example

a guest
Jan 2nd, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         _mceImage : function(ui, val) {
  2.             var ed = this.editor;
  3.             var t = this;
  4.  
  5.             // Internal image object like a flash placeholder
  6.             if (ed.dom.getAttrib(ed.selection.getNode(), 'class').indexOf('mceItem') != -1)
  7.                 return;
  8.  
  9.             XenForo.ajax('index.php?editor/dialog', { dialog: 'fast_image'}, t._xenforo_ajax_success);
  10.         },
  11.  
  12.         _xenforo_ajax_success: function(ajaxData)
  13.         {
  14.             if (XenForo.hasResponseError(ajaxData) || typeof(ajaxData.templateHtml) == 'undefined')
  15.             {
  16.                 return;
  17.             }
  18.    
  19.                 if (ajaxData.templateHtml)
  20.                 {
  21.                     new XenForo.ExtLoader(ajaxData, function()
  22.                     {
  23.                         var overlay, overtop, isTouch = XenForo.isTouchBrowser();
  24.                         if(isTouch) { overtop = '10%'; } else { overtop = 'center'; }
  25.                        
  26.                         $triger = $(ajaxData.templateHtml).find('.miuTriger');
  27.                         $focus = $(ajaxData.templateHtml).find('.mceFocus');
  28.                         $inputs = $(ajaxData.templateHtml).find('input');
  29.  
  30.                         overlay = $(ajaxData.templateHtml)
  31.                             .xfInsert('prependTo', 'body', 'xfFadeIn')
  32.                             .overlay({
  33.                                 mask: {
  34.                                         color: '#000000',
  35.                                         zIndex: 10010,
  36.                                         loadSpeed: 200,
  37.                                         opacity: 0.6
  38.                                 },
  39.                                 onBeforeLoad: function(e) {
  40.                                     $('.xenOverlay').css('opacity', '0.5');
  41.                                 },
  42.                                 onLoad: function(e) {
  43.                                     this.getOverlay().insertAfter('#exposeMask').addClass('isLoaded');//@http://stackoverflow.com/questions/1939494/
  44.                                         $inputs
  45.                                         .bind('keypress', function(e){
  46.                                             //Map "return" Key to the .miuTriger button
  47.                                             if ( e.which == 13 )
  48.                                             {
  49.                                                 e.preventDefault();
  50.                                                 $triger.trigger('click');
  51.                                             }
  52.                                         });
  53.                                         $triger.one('click', function (e){
  54.                                             e.stopImmediatePropagation();
  55.                                            
  56.                                             var inputs = {};
  57.  
  58.                                             $inputs.each(function(index) {
  59.                                                 inputs[$(this).attr('name')] = $(this).val();
  60.                                             });
  61.                                             overlay.close();
  62.  
  63.                                             //XenForo.miuExtra.miu.textarea.focus();
  64.                                             //XenForo.miuExtra[redirection](inputs, XenForo.miuExtra.miu);
  65.                                             return false;
  66.                                         });
  67.                        
  68.                                         $focus.focus();
  69.                                     },
  70.                                         onClose: function(e) {
  71.                                             $('.xenOverlay').css('opacity', '1').expose();
  72.                                             $inputs.val('');
  73.                                         },
  74.                                         top: overtop,
  75.                                         left:0, //will be centered by css... better to avoid bugs
  76.                                             fixed:!isTouch,
  77.                                         closeOnClick: false,
  78.                                         oneInstance: false,
  79.                                         load: true,
  80.                                         api:true
  81.                                     }).load();
  82.  
  83.                                 return false;                          
  84.                     });
  85.                 }
  86.         },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement