Permalink
Browse files

BUGFIX: Add comments and fix IE problems (class is a reserver JS word).

  • Loading branch information...
mateusz committed May 24, 2012
1 parent 1772355 commit d8fdda79be3d70a91c282828cc8435cdb8bf8e6e
Showing with 12 additions and 6 deletions.
  1. +12 −6 thirdparty/tinymce_ssbuttons/editor_plugin_src.js
@@ -66,14 +66,18 @@
var prefix, suffix, attributes, attributeString, url;
var attrs, attr;
var imgEl;
+ // Match various parts of the embed tag
while((matches = shortTagRegex.exec(content))) {
prefix = matches[1];
suffix = matches[4];
if(prefix === '[' && suffix === ']') {
continue;
}
attributes = {};
+ // Remove quotation marks and trim.
attributeString = matches[2].replace(/['"]/g, '').replace(/(^\s+|\s+$)/g, '');
+
+ // Extract the attributes and values into a key-value array (or key-key if no value is set)
attrs = attributeString.split(/\s+/);
for(attribute in attrs) {
attr = attrs[attribute].split('=');
@@ -83,14 +87,16 @@
attributes[attr[0]] = attr[1];
}
}
- attributes.cssclass = attributes.class;
+
+ // Build HTML element from embed attributes.
+ attributes.cssclass = attributes['class'];
url = matches[3];
imgEl = jQuery('<img/>').attr({
- 'src': attributes.thumbnail,
- 'width': attributes.width,
- 'height': attributes.height,
- 'class': attributes.cssclass,
- 'data-url': url,
+ 'src': attributes['thumbnail'],
+ 'width': attributes['width'],
+ 'height': attributes['height'],
+ 'class': attributes['cssclass'],
+ 'data-url': url
}).addClass('ss-htmleditorfield-file embed');
jQuery.each(attributes, function (key, value) {

0 comments on commit d8fdda7

Please sign in to comment.