first import
62
sites/all/modules/ckeditor/plugins/counter/plugin.js
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @file Plugin to count symbols, symbols without blanks and words
|
||||
*/
|
||||
( function(){
|
||||
var emptyHtml = '<span class="cke_empty"> </span>';
|
||||
CKEDITOR.plugins.add( 'counter',
|
||||
{
|
||||
init : function( editor )
|
||||
{
|
||||
var spaceId = 'cke_counter_' + editor.name;
|
||||
var spaceElement;
|
||||
var ckeditorEventThemeSpace = 'uiSpace';
|
||||
var getSpaceElement = function()
|
||||
{
|
||||
if ( !spaceElement )
|
||||
spaceElement = CKEDITOR.document.getById( spaceId );
|
||||
return spaceElement;
|
||||
};
|
||||
|
||||
if (Drupal.ckeditor_ver == 3) {
|
||||
ckeditorEventThemeSpace = 'themeSpace';
|
||||
}
|
||||
|
||||
editor.on( ckeditorEventThemeSpace, function( event )
|
||||
{
|
||||
if ( event.data.space == 'bottom' )
|
||||
{
|
||||
event.data.html +=
|
||||
'<span id="' + spaceId + '_label" class="cke_voice_label">Counter</span>' +
|
||||
'<div id="' + spaceId + '" class="cke_counter" role="group" aria-labelledby="' + spaceId + '_label">' + emptyHtml + '</div>';
|
||||
}
|
||||
});
|
||||
|
||||
function count( ev )
|
||||
{
|
||||
var space = getSpaceElement();
|
||||
var text = ev.editor.getData();
|
||||
// decode HTML entities; it also removes HTML tags, but works only if jQuery is available
|
||||
text = jQuery('<div/>').html(text).text();
|
||||
// remove all redundant blank symbols
|
||||
text = text.replace(new RegExp('\\s+', 'g'), ' ');
|
||||
// remove all blank symbols at the start and at the end
|
||||
text = text.replace(new RegExp('(^\\s+)|(\\s+$)', 'g'), '');
|
||||
var symbols = text.length;
|
||||
var words = text.split(' ').length;
|
||||
//remove all blank symbols
|
||||
text = text.replace(new RegExp('\\s+', 'g'), '');
|
||||
var symbols_wo_blanks = text.length;
|
||||
|
||||
space.setHtml( '<span class="cke_counter" style="float: right">' + symbols + ' / ' + symbols_wo_blanks + ' symbols; ' + words + ' words</span>' );
|
||||
}
|
||||
|
||||
editor.on( 'dataReady', count );
|
||||
editor.on( 'blur', count );
|
||||
editor.on( 'focus', count );
|
||||
// Almost useless
|
||||
//editor.on( 'saveSnapshot', count );
|
||||
// Requires too much resources
|
||||
//editor.on( 'key', count );
|
||||
}
|
||||
});
|
||||
})();
|
After Width: | Height: | Size: 191 B |
After Width: | Height: | Size: 212 B |
After Width: | Height: | Size: 54 B |
175
sites/all/modules/ckeditor/plugins/drupalbreaks/plugin.js
Normal file
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
|
||||
For licensing, see LICENSE.html or http://ckeditor.com/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file Plugin for inserting Drupal teaser and page breaks.
|
||||
*/
|
||||
( function() {
|
||||
var pluginRequires = [ 'fakeobjects' ];
|
||||
if (Drupal.ckeditor_ver == 3) {
|
||||
pluginRequires = [ 'fakeobjects', 'htmldataprocessor' ];
|
||||
}
|
||||
|
||||
CKEDITOR.plugins.add( 'drupalbreaks',
|
||||
{
|
||||
requires : pluginRequires,
|
||||
|
||||
init : function( editor )
|
||||
{
|
||||
var addCssObj = CKEDITOR;
|
||||
|
||||
if (Drupal.ckeditor_ver == 3) {
|
||||
addCssObj = editor;
|
||||
}
|
||||
// Add the styles that renders our fake objects.
|
||||
addCssObj.addCss(
|
||||
'img.cke_drupal_pagebreak,img.cke_drupal_break' +
|
||||
'{' +
|
||||
'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/pagebreak.gif' ) + ');' +
|
||||
'background-position: center center;' +
|
||||
'background-repeat: no-repeat;' +
|
||||
'clear: both;' +
|
||||
'display: block;' +
|
||||
'float: none;' +
|
||||
'width: 100%;' +
|
||||
'border-top: #999999 1px dotted;' +
|
||||
'border-bottom: #999999 1px dotted;' +
|
||||
'height: 5px;' +
|
||||
'}' +
|
||||
'img.cke_drupal_break' +
|
||||
'{' +
|
||||
'border-top: #FF0000 1px dotted;' +
|
||||
'border-bottom: #FF0000 1px dotted;' +
|
||||
'}'
|
||||
);
|
||||
|
||||
// Register the toolbar buttons.
|
||||
editor.ui.addButton( 'DrupalBreak',
|
||||
{
|
||||
label : Drupal.t('Insert Teaser Break'),
|
||||
icon : this.path + 'images/drupalbreak.png',
|
||||
command : 'drupalbreak'
|
||||
});
|
||||
|
||||
editor.addCommand( 'drupalbreak',
|
||||
{
|
||||
exec : function()
|
||||
{
|
||||
// There should be only one <!--break--> in document. So, look
|
||||
// for an image with class "cke_drupal_break" (the fake element).
|
||||
var images = editor.document.getElementsByTag( 'img' );
|
||||
for ( var i = 0, len = images.count() ; i < len ; i++ )
|
||||
{
|
||||
var img = images.getItem( i );
|
||||
if ( img.hasClass( 'cke_drupal_break' ) )
|
||||
{
|
||||
if ( confirm( Drupal.t( 'The document already contains a teaser break. Do you want to proceed by removing it first?' ) ) )
|
||||
{
|
||||
img.remove();
|
||||
break;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
insertComment( 'break' );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.ui.addButton( 'DrupalPageBreak',
|
||||
{
|
||||
label : Drupal.t( 'Insert Page Break' ),
|
||||
icon : this.path + 'images/drupalpagebreak.png',
|
||||
command : 'drupalpagebreak'
|
||||
});
|
||||
|
||||
editor.addCommand( 'drupalpagebreak',
|
||||
{
|
||||
exec : function()
|
||||
{
|
||||
insertComment( 'pagebreak' );
|
||||
}
|
||||
} );
|
||||
|
||||
// This function effectively inserts the comment into the editor.
|
||||
function insertComment( text )
|
||||
{
|
||||
// Create the fake element that will be inserted into the document.
|
||||
// The trick is declaring it as an <hr>, so it will behave like a
|
||||
// block element (and in effect it behaves much like an <hr>).
|
||||
if ( !CKEDITOR.dom.comment.prototype.getAttribute ) {
|
||||
CKEDITOR.dom.comment.prototype.getAttribute = function() {
|
||||
return '';
|
||||
};
|
||||
CKEDITOR.dom.comment.prototype.attributes = {
|
||||
align : ''
|
||||
};
|
||||
}
|
||||
var fakeElement = editor.createFakeElement( new CKEDITOR.dom.comment( text ), 'cke_drupal_' + text, 'hr' );
|
||||
|
||||
// This is the trick part. We can't use editor.insertElement()
|
||||
// because we need to put the comment directly at <body> level.
|
||||
// We need to do range manipulation for that.
|
||||
|
||||
// Get a DOM range from the current selection.
|
||||
var range = editor.getSelection().getRanges()[0],
|
||||
elementsPath = new CKEDITOR.dom.elementPath( range.getCommonAncestor( true ) ),
|
||||
element = ( elementsPath.block && elementsPath.block.getParent() ) || elementsPath.blockLimit,
|
||||
hasMoved;
|
||||
|
||||
// If we're not in <body> go moving the position to after the
|
||||
// elements until reaching it. This may happen when inside tables,
|
||||
// lists, blockquotes, etc.
|
||||
while ( element && element.getName() != 'body' )
|
||||
{
|
||||
range.moveToPosition( element, CKEDITOR.POSITION_AFTER_END );
|
||||
hasMoved = 1;
|
||||
element = element.getParent();
|
||||
}
|
||||
|
||||
// Split the current block.
|
||||
if ( !hasMoved )
|
||||
range.splitBlock( 'p' );
|
||||
|
||||
// Insert the fake element into the document.
|
||||
range.insertNode( fakeElement );
|
||||
|
||||
// Now, we move the selection to the best possible place following
|
||||
// our fake element.
|
||||
var next = fakeElement;
|
||||
while ( ( next = next.getNext() ) && !range.moveToElementEditStart( next ) )
|
||||
{}
|
||||
|
||||
range.select();
|
||||
}
|
||||
},
|
||||
|
||||
afterInit : function( editor )
|
||||
{
|
||||
// Adds the comment processing rules to the data filter, so comments
|
||||
// are replaced by fake elements.
|
||||
editor.dataProcessor.dataFilter.addRules(
|
||||
{
|
||||
comment : function( value )
|
||||
{
|
||||
if ( !CKEDITOR.htmlParser.comment.prototype.getAttribute ) {
|
||||
CKEDITOR.htmlParser.comment.prototype.getAttribute = function() {
|
||||
return '';
|
||||
};
|
||||
CKEDITOR.htmlParser.comment.prototype.attributes = {
|
||||
align : ''
|
||||
};
|
||||
}
|
||||
|
||||
if ( value == 'break' || value == 'pagebreak' )
|
||||
return editor.createFakeParserElement( new CKEDITOR.htmlParser.comment( value ), 'cke_drupal_' + value, 'hr' );
|
||||
|
||||
return value;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} )();
|
BIN
sites/all/modules/ckeditor/plugins/imce/images/icon.png
Normal file
After Width: | Height: | Size: 523 B |
67
sites/all/modules/ckeditor/plugins/imce/plugin.js
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
|
||||
For licensing, see LICENSE.html or http://ckeditor.com/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file Plugin for inserting files from imce without image dialog
|
||||
*/
|
||||
( function() {
|
||||
CKEDITOR.plugins.add( 'imce',
|
||||
{
|
||||
init: function( editor )
|
||||
{
|
||||
//adding button
|
||||
editor.ui.addButton( 'IMCE',
|
||||
{
|
||||
label: 'IMCE',
|
||||
command: 'IMCEWindow',
|
||||
icon: this.path + 'images/icon.png'
|
||||
});
|
||||
|
||||
//opening imce window
|
||||
editor.addCommand( 'IMCEWindow', {
|
||||
exec : function () {
|
||||
var width = editor.config.filebrowserWindowWidth || '80%',
|
||||
height = editor.config.filebrowserWindowHeight || '70%';
|
||||
|
||||
editor.popup(Drupal.settings.basePath + 'index.php?q=imce\x26app=ckeditor|sendto@ckeditor_setFile|&CKEditorFuncNum=' + editor._.filebrowserFnIMCE, width, height);
|
||||
}
|
||||
});
|
||||
|
||||
//add editor function
|
||||
editor._.filebrowserFnIMCE = CKEDITOR.tools.addFunction( setFile, editor )
|
||||
|
||||
//function which receive imce response
|
||||
window.ckeditor_setFile = function (file, win) {
|
||||
var cfunc = win.location.href.split('&');
|
||||
for (var x in cfunc) {
|
||||
if (cfunc[x].match(/^CKEditorFuncNum=\d+$/)) {
|
||||
cfunc = cfunc[x].split('=');
|
||||
break;
|
||||
}
|
||||
}
|
||||
CKEDITOR.tools.callFunction(cfunc[1], file);
|
||||
win.close();
|
||||
};
|
||||
|
||||
}
|
||||
} );
|
||||
function setFile(file) {
|
||||
var sel = this.getSelection(),
|
||||
text = sel.getSelectedText();
|
||||
if (file.width != 0 && file.height != 0) {
|
||||
if (text) {
|
||||
this.insertHtml('<a href="' + document.location.protocol + '//'+ document.location.host + file.url + '">' + text + '</a>');
|
||||
} else {
|
||||
this.insertHtml('<img src="' + file.url + '" style="width:' + file.width + 'px;height:' + file.height + 'px;" alt="' + file.name + '" />');
|
||||
}
|
||||
} else {
|
||||
if (text) {
|
||||
this.insertHtml('<a href="' +document.location.protocol + '//'+ document.location.host + file.url + '">' + text + '</a>');
|
||||
} else {
|
||||
this.insertHtml('<a href="' + document.location.protocol + '//'+ document.location.host + file.url + '">' + file.name + '</a>');
|
||||
}
|
||||
}
|
||||
}
|
||||
} )();
|
BIN
sites/all/modules/ckeditor/plugins/media/images/icon.gif
Normal file
After Width: | Height: | Size: 126 B |
349
sites/all/modules/ckeditor/plugins/media/library.js
Normal file
@@ -0,0 +1,349 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Attach Media ckeditor behaviors.
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
Drupal.media = Drupal.media || {};
|
||||
|
||||
Drupal.settings.ckeditor.plugins['media'] = {
|
||||
|
||||
/**
|
||||
* Initializes the tag map.
|
||||
*/
|
||||
initializeTagMap: function () {
|
||||
if (typeof Drupal.settings.tagmap == 'undefined') {
|
||||
Drupal.settings.tagmap = { };
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Execute the button.
|
||||
*/
|
||||
invoke: function (data, settings, instanceId) {
|
||||
if (data.format == 'html') {
|
||||
Drupal.media.popups.mediaBrowser(function (mediaFiles) {
|
||||
Drupal.settings.ckeditor.plugins['media'].mediaBrowserOnSelect(mediaFiles, instanceId);
|
||||
}, settings['global']);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Respond to the mediaBrowser's onSelect event.
|
||||
*/
|
||||
mediaBrowserOnSelect: function (mediaFiles, instanceId) {
|
||||
var mediaFile = mediaFiles[0];
|
||||
var options = {};
|
||||
Drupal.media.popups.mediaStyleSelector(mediaFile, function (formattedMedia) {
|
||||
Drupal.settings.ckeditor.plugins['media'].insertMediaFile(mediaFile, formattedMedia.type, formattedMedia.html, formattedMedia.options, CKEDITOR.instances[instanceId]);
|
||||
}, options);
|
||||
|
||||
return;
|
||||
},
|
||||
|
||||
insertMediaFile: function (mediaFile, viewMode, formattedMedia, options, ckeditorInstance) {
|
||||
|
||||
this.initializeTagMap();
|
||||
// @TODO: the folks @ ckeditor have told us that there is no way
|
||||
// to reliably add wrapper divs via normal HTML.
|
||||
// There is some method of adding a "fake element"
|
||||
// But until then, we're just going to embed to img.
|
||||
// This is pretty hacked for now.
|
||||
//
|
||||
var imgElement = $(this.stripDivs(formattedMedia));
|
||||
this.addImageAttributes(imgElement, mediaFile.fid, viewMode, options);
|
||||
|
||||
var toInsert = this.outerHTML(imgElement);
|
||||
// Create an inline tag
|
||||
var inlineTag = Drupal.settings.ckeditor.plugins['media'].createTag(imgElement);
|
||||
// Add it to the tag map in case the user switches input formats
|
||||
Drupal.settings.tagmap[inlineTag] = toInsert;
|
||||
ckeditorInstance.insertHtml(toInsert);
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the HTML content of an element
|
||||
*
|
||||
* @param jQuery element
|
||||
*/
|
||||
outerHTML: function (element) {
|
||||
return $('<div>').append( element.eq(0).clone() ).html();
|
||||
},
|
||||
|
||||
addImageAttributes: function (imgElement, fid, view_mode, additional) {
|
||||
imgElement.addClass('media-image');
|
||||
|
||||
this.forceAttributesIntoClass(imgElement, fid, view_mode, additional);
|
||||
},
|
||||
|
||||
/**
|
||||
* Due to problems handling wrapping divs in ckeditor, this is needed.
|
||||
*
|
||||
* Going forward, if we don't care about supporting other editors
|
||||
* we can use the fakeobjects plugin to ckeditor to provide cleaner
|
||||
* transparency between what Drupal will output <div class="field..."><img></div>
|
||||
* instead of just <img>, for now though, we're going to remove all the stuff surrounding the images.
|
||||
*
|
||||
* @param String formattedMedia
|
||||
* Element containing the image
|
||||
*
|
||||
* @return HTML of <img> tag inside formattedMedia
|
||||
*/
|
||||
stripDivs: function (formattedMedia) {
|
||||
// Check to see if the image tag has divs to strip
|
||||
var stripped = null;
|
||||
if ($(formattedMedia).is('img')) {
|
||||
stripped = this.outerHTML($(formattedMedia));
|
||||
} else {
|
||||
stripped = this.outerHTML($('img', $(formattedMedia)));
|
||||
}
|
||||
// This will fail if we pass the img tag without anything wrapping it, like we do when re-enabling ckeditor
|
||||
return stripped;
|
||||
},
|
||||
|
||||
/**
|
||||
* Attach function, called when a rich text editor loads.
|
||||
* This finds all [[tags]] and replaces them with the html
|
||||
* that needs to show in the editor.
|
||||
*
|
||||
*/
|
||||
attach: function (content, settings, instanceId) {
|
||||
var matches = content.match(/\[\[.*?\]\]/g);
|
||||
this.initializeTagMap();
|
||||
var tagmap = Drupal.settings.tagmap;
|
||||
if (matches) {
|
||||
var inlineTag = "";
|
||||
for (i = 0; i < matches.length; i++) {
|
||||
inlineTag = matches[i];
|
||||
if (tagmap[inlineTag]) {
|
||||
// This probably needs some work...
|
||||
// We need to somehow get the fid propogated here.
|
||||
// We really want to
|
||||
var tagContent = tagmap[inlineTag];
|
||||
var mediaMarkup = this.stripDivs(tagContent); // THis is <div>..<img>
|
||||
|
||||
var _tag = inlineTag;
|
||||
_tag = _tag.replace('[[','');
|
||||
_tag = _tag.replace(']]','');
|
||||
mediaObj = JSON.parse(_tag);
|
||||
|
||||
var imgElement = $(mediaMarkup);
|
||||
this.addImageAttributes(imgElement, mediaObj.fid, mediaObj.view_mode);
|
||||
var toInsert = this.outerHTML(imgElement);
|
||||
content = content.replace(inlineTag, toInsert);
|
||||
}
|
||||
else {
|
||||
debug.debug("Could not find content for " + inlineTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
return content;
|
||||
},
|
||||
|
||||
/**
|
||||
* Detach function, called when a rich text editor detaches
|
||||
*/
|
||||
detach: function (content, settings, instanceId) {
|
||||
var content = $('<div>' + content + '</div>');
|
||||
$('img.media-image',content).each(function (elem) {
|
||||
var tag = Drupal.settings.ckeditor.plugins['media'].createTag($(this));
|
||||
$(this).replaceWith(tag);
|
||||
var newContent = content.html();
|
||||
var tagContent = $('<div></div>').append($(this)).html();
|
||||
Drupal.settings.tagmap[tag] = tagContent;
|
||||
});
|
||||
return content.html();
|
||||
},
|
||||
|
||||
/**
|
||||
* @param jQuery imgNode
|
||||
* Image node to create tag from
|
||||
*/
|
||||
createTag: function (imgNode) {
|
||||
// Currently this is the <img> itself
|
||||
// Collect all attribs to be stashed into tagContent
|
||||
var mediaAttributes = {};
|
||||
var imgElement = imgNode[0];
|
||||
var sorter = [];
|
||||
|
||||
// @todo: this does not work in IE, width and height are always 0.
|
||||
for (i=0; i< imgElement.attributes.length; i++) {
|
||||
var attr = imgElement.attributes[i];
|
||||
if (attr.specified == true) {
|
||||
if (attr.name !== 'class') {
|
||||
sorter.push(attr);
|
||||
}
|
||||
else {
|
||||
// Exctract expando properties from the class field.
|
||||
var attributes = this.getAttributesFromClass(attr.value);
|
||||
for (var name in attributes) {
|
||||
if (attributes.hasOwnProperty(name)) {
|
||||
var value = attributes[name];
|
||||
if (value.type && value.type === 'attr') {
|
||||
sorter.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sorter.sort(this.sortAttributes);
|
||||
|
||||
for (var prop in sorter) {
|
||||
mediaAttributes[sorter[prop].name] = sorter[prop].value;
|
||||
}
|
||||
|
||||
// The following 5 ifs are dedicated to IE7
|
||||
// If the style is null, it is because IE7 can't read values from itself
|
||||
if (jQuery.browser.msie && jQuery.browser.version == '7.0') {
|
||||
if (mediaAttributes.style === "null") {
|
||||
var imgHeight = imgNode.css('height');
|
||||
var imgWidth = imgNode.css('width');
|
||||
mediaAttributes.style = {
|
||||
height: imgHeight,
|
||||
width: imgWidth
|
||||
}
|
||||
if (!mediaAttributes['width']) {
|
||||
mediaAttributes['width'] = imgWidth;
|
||||
}
|
||||
if (!mediaAttributes['height']) {
|
||||
mediaAttributes['height'] = imgHeight;
|
||||
}
|
||||
}
|
||||
// If the attribute width is zero, get the CSS width
|
||||
if (Number(mediaAttributes['width']) === 0) {
|
||||
mediaAttributes['width'] = imgNode.css('width');
|
||||
}
|
||||
// IE7 does support 'auto' as a value of the width attribute. It will not
|
||||
// display the image if this value is allowed to pass through
|
||||
if (mediaAttributes['width'] === 'auto') {
|
||||
delete mediaAttributes['width'];
|
||||
}
|
||||
// If the attribute height is zero, get the CSS height
|
||||
if (Number(mediaAttributes['height']) === 0) {
|
||||
mediaAttributes['height'] = imgNode.css('height');
|
||||
}
|
||||
// IE7 does support 'auto' as a value of the height attribute. It will not
|
||||
// display the image if this value is allowed to pass through
|
||||
if (mediaAttributes['height'] === 'auto') {
|
||||
delete mediaAttributes['height'];
|
||||
}
|
||||
}
|
||||
|
||||
// Remove elements from attribs using the blacklist
|
||||
for (var blackList in Drupal.settings.media.blacklist) {
|
||||
delete mediaAttributes[Drupal.settings.media.blacklist[blackList]];
|
||||
}
|
||||
tagContent = {
|
||||
"type": 'media',
|
||||
// @todo: This will be selected from the format form
|
||||
"view_mode": attributes['view_mode'].value,
|
||||
"fid" : attributes['fid'].value,
|
||||
"attributes": mediaAttributes
|
||||
};
|
||||
return '[[' + JSON.stringify(tagContent) + ']]';
|
||||
},
|
||||
|
||||
/**
|
||||
* Forces custom attributes into the class field of the specified image.
|
||||
*
|
||||
* Due to a bug in some versions of Firefox
|
||||
* (http://forums.mozillazine.org/viewtopic.php?f=9&t=1991855), the
|
||||
* custom attributes used to share information about the image are
|
||||
* being stripped as the image markup is set into the rich text
|
||||
* editor. Here we encode these attributes into the class field so
|
||||
* the data survives.
|
||||
*
|
||||
* @param imgElement
|
||||
* The image
|
||||
* @fid
|
||||
* The file id.
|
||||
* @param view_mode
|
||||
* The view mode.
|
||||
* @param additional
|
||||
* Additional attributes to add to the image.
|
||||
*/
|
||||
forceAttributesIntoClass: function (imgElement, fid, view_mode, additional) {
|
||||
var wysiwyg = imgElement.attr('wysiwyg');
|
||||
if (wysiwyg) {
|
||||
imgElement.addClass('attr__wysiwyg__' + wysiwyg);
|
||||
}
|
||||
var format = imgElement.attr('format');
|
||||
if (format) {
|
||||
imgElement.addClass('attr__format__' + format);
|
||||
}
|
||||
var typeOf = imgElement.attr('typeof');
|
||||
if (typeOf) {
|
||||
imgElement.addClass('attr__typeof__' + typeOf);
|
||||
}
|
||||
if (fid) {
|
||||
imgElement.addClass('img__fid__' + fid);
|
||||
}
|
||||
if (view_mode) {
|
||||
imgElement.addClass('img__view_mode__' + view_mode);
|
||||
}
|
||||
if (additional) {
|
||||
for (var name in additional) {
|
||||
if (additional.hasOwnProperty(name)) {
|
||||
if (name !== 'alt') {
|
||||
imgElement.addClass('attr__' + name + '__' + additional[name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieves encoded attributes from the specified class string.
|
||||
*
|
||||
* @param classString
|
||||
* A string containing the value of the class attribute.
|
||||
* @return
|
||||
* An array containing the attribute names as keys, and an object
|
||||
* with the name, value, and attribute type (either 'attr' or
|
||||
* 'img', depending on whether it is an image attribute or should
|
||||
* be it the attributes section)
|
||||
*/
|
||||
getAttributesFromClass: function (classString) {
|
||||
var actualClasses = [];
|
||||
var otherAttributes = [];
|
||||
var classes = classString.split(' ');
|
||||
var regexp = new RegExp('^(attr|img)__([^\S]*)__([^\S]*)$');
|
||||
for (var index = 0; index < classes.length; index++) {
|
||||
var matches = classes[index].match(regexp);
|
||||
if (matches && matches.length === 4) {
|
||||
otherAttributes[matches[2]] = {
|
||||
name: matches[2],
|
||||
value: matches[3],
|
||||
type: matches[1]
|
||||
};
|
||||
}
|
||||
else {
|
||||
actualClasses.push(classes[index]);
|
||||
}
|
||||
}
|
||||
if (actualClasses.length > 0) {
|
||||
otherAttributes['class'] = {
|
||||
name: 'class',
|
||||
value: actualClasses.join(' '),
|
||||
type: 'attr'
|
||||
};
|
||||
}
|
||||
return otherAttributes;
|
||||
},
|
||||
|
||||
sortAttributes: function (a, b) {
|
||||
var nameA = a.name.toLowerCase();
|
||||
var nameB = b.name.toLowerCase();
|
||||
if (nameA < nameB) {
|
||||
return -1;
|
||||
}
|
||||
if (nameA > nameB) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
58
sites/all/modules/ckeditor/plugins/media/plugin.js
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
|
||||
For licensing, see LICENSE.html or http://ckeditor.com/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file Plugin for inserting images from Drupal media module
|
||||
*/
|
||||
( function() {
|
||||
CKEDITOR.plugins.add( 'media',
|
||||
{
|
||||
// Wrap Drupal plugin in a proxy plugin.
|
||||
init: function(editor)
|
||||
{
|
||||
var pluginCommand = {
|
||||
exec: function (editor) {
|
||||
var data = {
|
||||
format: 'html',
|
||||
node: null,
|
||||
content: ''
|
||||
};
|
||||
var selection = editor.getSelection();
|
||||
|
||||
if (selection) {
|
||||
data.node = selection.getSelectedElement();
|
||||
if (data.node) {
|
||||
data.node = data.node.$;
|
||||
}
|
||||
if (selection.getType() == CKEDITOR.SELECTION_TEXT) {
|
||||
if (CKEDITOR.env.ie) {
|
||||
data.content = selection.getNative().createRange().text;
|
||||
}
|
||||
else {
|
||||
data.content = selection.getNative().toString();
|
||||
}
|
||||
}
|
||||
else if (data.node) {
|
||||
// content is supposed to contain the "outerHTML".
|
||||
data.content = data.node.parentNode.innerHTML;
|
||||
}
|
||||
}
|
||||
Drupal.settings.ckeditor.plugins['media'].invoke(data, Drupal.settings.ckeditor.plugins['media'], editor.name);
|
||||
}
|
||||
};
|
||||
editor.addCommand( 'media', pluginCommand );
|
||||
|
||||
editor.ui.addButton( 'Media',
|
||||
{
|
||||
label: 'Add media',
|
||||
command: 'media',
|
||||
icon: this.path + 'images/icon.gif'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
} )();
|
||||
|
||||
|
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
|
||||
For licensing, see LICENSE.html or http://ckeditor.com/license
|
||||
*/
|
||||
|
||||
CKEDITOR.dialog.add( 'mediaembedDialog', function( editor ) {
|
||||
var numberRegex = /^\d+(?:\.\d+)?$/;
|
||||
var cssifyLength = function( length )
|
||||
{
|
||||
if ( numberRegex.test( length ) )
|
||||
return length + 'px';
|
||||
return length;
|
||||
}
|
||||
return {
|
||||
title : Drupal.t('Embed Media Dialog'),
|
||||
minWidth : 400,
|
||||
minHeight : 200,
|
||||
contents : [
|
||||
{
|
||||
id : 'mediaTab',
|
||||
label : Drupal.t('Embed media code'),
|
||||
title : Drupal.t('Embed media code'),
|
||||
elements :
|
||||
[
|
||||
{
|
||||
id : 'embed',
|
||||
type : 'textarea',
|
||||
rows : 9,
|
||||
label : Drupal.t('Paste embed code here')
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
onOk : function() {
|
||||
var editor = this.getParentEditor();
|
||||
var content = this.getValueOf( 'mediaTab', 'embed' );
|
||||
if ( content.length>0 ) {
|
||||
var realElement = CKEDITOR.dom.element.createFromHtml('<div class="media_embed"></div>');
|
||||
realElement.setHtml(content);
|
||||
var fakeElement = editor.createFakeElement( realElement , 'cke_mediaembed', 'div', true);
|
||||
var matches = content.match(/width=(["']?)(\d+)\1/i);
|
||||
if (matches && matches.length == 3) {
|
||||
fakeElement.setStyle('width', cssifyLength(matches[2]));
|
||||
}
|
||||
matches = content.match(/height=([\"\']?)(\d+)\1/i);
|
||||
if (matches && matches.length == 3) {
|
||||
fakeElement.setStyle('height', cssifyLength(matches[2]));
|
||||
}
|
||||
editor.insertElement(fakeElement);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
BIN
sites/all/modules/ckeditor/plugins/mediaembed/images/icon.png
Normal file
After Width: | Height: | Size: 560 B |
After Width: | Height: | Size: 2.6 KiB |
110
sites/all/modules/ckeditor/plugins/mediaembed/plugin.js
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
|
||||
For licensing, see LICENSE.html or http://ckeditor.com/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file Plugin for inserting Drupal embeded media
|
||||
*/
|
||||
( function() {
|
||||
var numberRegex = /^\d+(?:\.\d+)?$/;
|
||||
var cssifyLength = function( length )
|
||||
{
|
||||
if ( numberRegex.test( length ) )
|
||||
return length + 'px';
|
||||
return length;
|
||||
}
|
||||
CKEDITOR.plugins.add( 'mediaembed',
|
||||
{
|
||||
requires : [ 'dialog', 'fakeobjects' ],
|
||||
init: function( editor )
|
||||
{
|
||||
var addCssObj = CKEDITOR;
|
||||
|
||||
if (Drupal.ckeditor_ver == 3) {
|
||||
addCssObj = editor;
|
||||
}
|
||||
addCssObj.addCss(
|
||||
'img.cke_mediaembed' +
|
||||
'{' +
|
||||
'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/placeholder.gif' ) + ');' +
|
||||
'background-position: center center;' +
|
||||
'background-repeat: no-repeat;' +
|
||||
'border: 1px solid #a9a9a9;' +
|
||||
'width: 80px;' +
|
||||
'height: 80px;' +
|
||||
'}'
|
||||
);
|
||||
|
||||
editor.addCommand( 'mediaembedDialog', new CKEDITOR.dialogCommand( 'mediaembedDialog' ) );
|
||||
editor.ui.addButton( 'MediaEmbed',
|
||||
{
|
||||
label: 'Embed Media',
|
||||
command: 'mediaembedDialog',
|
||||
icon: this.path + 'images/icon.png'
|
||||
} );
|
||||
CKEDITOR.dialog.add( 'mediaembedDialog', this.path + 'dialogs/mediaembed.js' );
|
||||
},
|
||||
afterInit : function( editor )
|
||||
{
|
||||
var dataProcessor = editor.dataProcessor,
|
||||
dataFilter = dataProcessor && dataProcessor.dataFilter,
|
||||
htmlFilter = dataProcessor && dataProcessor.htmlFilter;
|
||||
|
||||
if ( htmlFilter )
|
||||
{
|
||||
htmlFilter.addRules({
|
||||
elements :
|
||||
{
|
||||
'div' : function ( element ) {
|
||||
if( element.attributes['class'] == 'media_embed' ) {
|
||||
for (var x in element.children) {
|
||||
if (typeof(element.children[x].attributes) != 'undefined') {
|
||||
if (typeof(element.children[x].attributes.width) != undefined) {
|
||||
element.children[x].attributes.width = element.attributes.width;
|
||||
}
|
||||
if (typeof(element.children[x].attributes.height) != undefined) {
|
||||
element.children[x].attributes.height = element.attributes.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if ( dataFilter )
|
||||
{
|
||||
dataFilter.addRules(
|
||||
{
|
||||
elements :
|
||||
{
|
||||
'div' : function( element )
|
||||
{
|
||||
var attributes = element.attributes,
|
||||
classId = attributes.classid && String( attributes.classid ).toLowerCase();
|
||||
|
||||
if (element.attributes[ 'class' ] == 'media_embed') {
|
||||
var fakeElement = editor.createFakeParserElement(element, 'cke_mediaembed', 'div', true);
|
||||
var fakeStyle = fakeElement.attributes.style || '';
|
||||
if (typeof(element.children[0].attributes) != 'undefined') {
|
||||
var height = element.children[0].attributes.height,
|
||||
width = element.children[0].attributes.width;
|
||||
}
|
||||
if ( typeof width != 'undefined' )
|
||||
fakeStyle = fakeElement.attributes.style = fakeStyle + 'width:' + cssifyLength( width ) + ';';
|
||||
|
||||
if ( typeof height != 'undefined' )
|
||||
fakeStyle = fakeElement.attributes.style = fakeStyle + 'height:' + cssifyLength( height ) + ';';
|
||||
|
||||
return fakeElement;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
}
|
||||
},
|
||||
5);
|
||||
}
|
||||
}
|
||||
} );
|
||||
} )();
|