Dotclear

Changeset 402:9e1af86fe7e4 for admin


Ignore:
Timestamp:
06/22/11 10:32:52 (14 years ago)
Author:
Tomtom33 <tbouron@…>
Branch:
wysiwyg
Message:

Fixed DOM bug for media insert

Location:
admin/js
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • admin/js/jquery/jquery.oembed.js

    r399 r402  
    191191               if (data.title) alt.push(data.title); 
    192192                
    193                return $('<a>').attr({ 
     193               return $('<div>').append($('<a>').attr({ 
    194194                    'href': data.url, 
    195195                    'title': title 
     
    198198                    'title': title, 
    199199                    'alt': alt.join(' - ') 
    200                })); 
     200               }))).html(); 
    201201          }, 
    202202           
     
    219219               if (data.title) alt.push(data.title); 
    220220                
    221                return $('<a>').attr({ 
     221               return $('<div>').append($('<a>').attr({ 
    222222                    'href': data.url, 
    223223                    'title': title 
    224                }).append(title); 
     224               }).append(title)).html(); 
    225225          }, 
    226226           
     
    243243                              } 
    244244                         } 
    245                          xhtml += object.get(0).outerHTML; 
     245                         xhtml += $('<div>').append(object).html(); 
    246246                    }  
    247247                    else if (this.tagName == 'OBJECT') { 
     
    256256                              $(this).find('embed').remove(); 
    257257                         } 
    258                          xhtml += this.outerHTML; 
     258                         xhtml += $('<div>').append($(this)).html(); 
    259259                    } else { 
    260                          xhtml += internalMethods._getValidHXHTMLCode($(html).find('iframe,object').get(0).outerHTML); 
     260                         xhtml += internalMethods._getValidHXHTMLCode($('<div>').append($(html).find('iframe,object')).html()); 
    261261                    } 
    262262               }); 
  • admin/js/tiny_mce/plugins/dcControls/js/popup_media.js

    r400 r402  
    8181                    } 
    8282                     
    83                     res = ed.dom.createHTML('div',opt_div,oplayer.get(0).outerHTML); 
     83                    res = ed.dom.createHTML('div',opt_div,ed.dom.getOuterHTML(oplayer.get(0))); 
    8484                     
    8585                    ed.execCommand('mceInsertContent',false,res,{skip_undo : 1}); 
  • admin/js/tiny_mce/plugins/dcControls/js/popup_web_media.js

    r399 r402  
    33var popup_web_media = { 
    44     oembed_opts: { 
    5           maxWidth: 480, 
     5          maxWidth: 450, 
    66          maxHeight: 400, 
    77          onProviderNotFound: function(url) { 
     
    4646      
    4747     init: function() { 
    48           $('#src').focusin(function() { 
     48          $('#src').focusin(function(e) { 
    4949               $(this).removeClass(); 
     50          }).keypress(function(e) { 
     51               if (e.keyCode == 13) { 
     52                    $(this).focusout(); 
     53                    $('#webmedia-insert-search').click(); 
     54               } 
    5055          }); 
    5156           
     
    7883               var title = $('input[name="title"]').val(); 
    7984               var alt = $('input[name="alt"]').val(); 
    80                var code = ''; 
     85               var width = $('input[name="width"]').val(); 
     86               var height = $('input[name="height"]').val(); 
    8187                
    8288               if (data != null) { 
    83                     var a = $('<a>').attr({ 
    84                          'href': src, 
    85                          'title': title 
    86                     }); 
    87                     var img = $('<img>').attr({ 
    88                          'src': data.thumbnail_url, 
    89                          'alt': alt, 
    90                          'title': title 
    91                     }); 
     89                    var res = null; 
     90                    var opts_div = {}; 
     91                    var opts_img = { 
     92                         src: data.thumbnail_url, 
     93                         alt: alt, 
     94                         title: title 
     95                    }; 
     96                    var opts_a = { 
     97                         href: src, 
     98                         title: title 
     99                    }; 
     100                     
    92101                    switch($('input[name="insertion"]:checked').val()) { 
    93102                         case 'media': 
    94                               code = $(data.code); 
     103                              code = $(data.code).attr({ 
     104                                   'width': width, 
     105                                   'height': height 
     106                              }); 
     107                              res = ed.dom.create('div',opts_div,ed.dom.getOuterHTML(code.get(0))) 
    95108                              break; 
    96109                         case 'thumbnail': 
    97                               code = a.append(img); 
     110                              var img = ed.dom.create('img',opts_img); 
     111                              res = ed.dom.create('a',opts_a,ed.dom.getOuterHTML(img)); 
    98112                              break; 
    99113                         case 'link': 
    100                               code = a.append(alt); 
     114                              res = ed.dom.create('a',opts_a,alt); 
    101115                              break; 
    102116                    } 
    103117                     
    104118                    if (alignment != 'none') { 
    105                          code.attr('style',media_align_grid[alignment]); 
     119                         ed.dom.setAttribs(res,{style: media_align_grid[alignment]}); 
    106120                    } 
    107121                     
    108                     ed.execCommand('mceInsertContent',false,code.get(0).outerHTML); 
     122                    ed.execCommand('mceInsertContent',false,ed.dom.getOuterHTML(res)); 
    109123                    tinyMCEPopup.close(); 
    110124               } else { 
     
    127141          } 
    128142          return info; 
    129      }, 
    130       
    131      getValidXHTMLCode: function(html) { 
    132           var xhtml = $(html); 
    133           var type = xhtml.get(0).tagName; 
    134            
    135           if (type == 'IFRAME') { 
    136                var attr = { 
    137                     'src': 'data', 
    138                     'width': 'width', 
    139                     'height': 'height' 
    140                }; 
    141                var attributes = xhtml.get(0).attributes; 
    142                xhtml = $('<object>'); 
    143                xhtml.attr('type','text/html'); 
    144                for (i in attributes) { 
    145                     if (attr.hasOwnProperty(attributes[i].name)) { 
    146                          xhtml.attr(attr[attributes[i].name],attributes[i].value); 
    147                     } 
    148                } 
    149           }  
    150           else if (type == 'OBJECT') { 
    151                if (xhtml.find('embed').size() > 0) { 
    152                     var embed = xhtml.find('embed').get(0); 
    153                     if ($.inArray('src',embed.attributes)) { 
    154                          xhtml.attr('data',embed.attributes.src.nodeValue); 
    155                     } 
    156                     if ($.inArray('type',embed.attributes)) { 
    157                          xhtml.attr('type',embed.attributes.type.nodeValue); 
    158                     } 
    159                     xhtml.find('embed').remove(); 
    160                } 
    161           } 
    162           else { 
    163                xhtml = this.getValidXHTMLCode(xhtml.find('iframe,object').get(0).outerHTML); 
    164           } 
    165            
    166           return xhtml; 
    167143     } 
    168144}; 
Note: See TracChangeset for help on using the changeset viewer.

Sites map