annotate sites/all/modules/wysiwyg/wysiwyg.api.js @ 11:b0ee71395280

deleted .DS_Store files
author danieleb <danielebarchiesi@me.com>
date Mon, 28 Oct 2013 16:12:13 +0000
parents ff03f76ab3fe
children
rev   line source
danielebarchiesi@0 1
danielebarchiesi@0 2 /**
danielebarchiesi@0 3 * Wysiwyg plugin button implementation for Awesome plugin.
danielebarchiesi@0 4 */
danielebarchiesi@0 5 Drupal.wysiwyg.plugins.awesome = {
danielebarchiesi@0 6 /**
danielebarchiesi@0 7 * Return whether the passed node belongs to this plugin.
danielebarchiesi@0 8 *
danielebarchiesi@0 9 * @param node
danielebarchiesi@0 10 * The currently focused DOM element in the editor content.
danielebarchiesi@0 11 */
danielebarchiesi@0 12 isNode: function(node) {
danielebarchiesi@0 13 return ($(node).is('img.mymodule-awesome'));
danielebarchiesi@0 14 },
danielebarchiesi@0 15
danielebarchiesi@0 16 /**
danielebarchiesi@0 17 * Execute the button.
danielebarchiesi@0 18 *
danielebarchiesi@0 19 * @param data
danielebarchiesi@0 20 * An object containing data about the current selection:
danielebarchiesi@0 21 * - format: 'html' when the passed data is HTML content, 'text' when the
danielebarchiesi@0 22 * passed data is plain-text content.
danielebarchiesi@0 23 * - node: When 'format' is 'html', the focused DOM element in the editor.
danielebarchiesi@0 24 * - content: The textual representation of the focused/selected editor
danielebarchiesi@0 25 * content.
danielebarchiesi@0 26 * @param settings
danielebarchiesi@0 27 * The plugin settings, as provided in the plugin's PHP include file.
danielebarchiesi@0 28 * @param instanceId
danielebarchiesi@0 29 * The ID of the current editor instance.
danielebarchiesi@0 30 */
danielebarchiesi@0 31 invoke: function(data, settings, instanceId) {
danielebarchiesi@0 32 // Generate HTML markup.
danielebarchiesi@0 33 if (data.format == 'html') {
danielebarchiesi@0 34 // Prevent duplicating a teaser break.
danielebarchiesi@0 35 if ($(data.node).is('img.mymodule-awesome')) {
danielebarchiesi@0 36 return;
danielebarchiesi@0 37 }
danielebarchiesi@0 38 var content = this._getPlaceholder(settings);
danielebarchiesi@0 39 }
danielebarchiesi@0 40 // Generate plain text.
danielebarchiesi@0 41 else {
danielebarchiesi@0 42 var content = '<!--break-->';
danielebarchiesi@0 43 }
danielebarchiesi@0 44 // Insert new content into the editor.
danielebarchiesi@0 45 if (typeof content != 'undefined') {
danielebarchiesi@0 46 Drupal.wysiwyg.instances[instanceId].insert(content);
danielebarchiesi@0 47 }
danielebarchiesi@0 48 },
danielebarchiesi@0 49
danielebarchiesi@0 50 /**
danielebarchiesi@0 51 * Prepare all plain-text contents of this plugin with HTML representations.
danielebarchiesi@0 52 *
danielebarchiesi@0 53 * Optional; only required for "inline macro tag-processing" plugins.
danielebarchiesi@0 54 *
danielebarchiesi@0 55 * @param content
danielebarchiesi@0 56 * The plain-text contents of a textarea.
danielebarchiesi@0 57 * @param settings
danielebarchiesi@0 58 * The plugin settings, as provided in the plugin's PHP include file.
danielebarchiesi@0 59 * @param instanceId
danielebarchiesi@0 60 * The ID of the current editor instance.
danielebarchiesi@0 61 */
danielebarchiesi@0 62 attach: function(content, settings, instanceId) {
danielebarchiesi@0 63 content = content.replace(/<!--break-->/g, this._getPlaceholder(settings));
danielebarchiesi@0 64 return content;
danielebarchiesi@0 65 },
danielebarchiesi@0 66
danielebarchiesi@0 67 /**
danielebarchiesi@0 68 * Process all HTML placeholders of this plugin with plain-text contents.
danielebarchiesi@0 69 *
danielebarchiesi@0 70 * Optional; only required for "inline macro tag-processing" plugins.
danielebarchiesi@0 71 *
danielebarchiesi@0 72 * @param content
danielebarchiesi@0 73 * The HTML content string of the editor.
danielebarchiesi@0 74 * @param settings
danielebarchiesi@0 75 * The plugin settings, as provided in the plugin's PHP include file.
danielebarchiesi@0 76 * @param instanceId
danielebarchiesi@0 77 * The ID of the current editor instance.
danielebarchiesi@0 78 */
danielebarchiesi@0 79 detach: function(content, settings, instanceId) {
danielebarchiesi@0 80 var $content = $('<div>' + content + '</div>');
danielebarchiesi@0 81 $.each($('img.mymodule-awesome', $content), function (i, elem) {
danielebarchiesi@0 82 //...
danielebarchiesi@0 83 });
danielebarchiesi@0 84 return $content.html();
danielebarchiesi@0 85 },
danielebarchiesi@0 86
danielebarchiesi@0 87 /**
danielebarchiesi@0 88 * Helper function to return a HTML placeholder.
danielebarchiesi@0 89 *
danielebarchiesi@0 90 * The 'drupal-content' CSS class is required for HTML elements in the editor
danielebarchiesi@0 91 * content that shall not trigger any editor's native buttons (such as the
danielebarchiesi@0 92 * image button for this example placeholder markup).
danielebarchiesi@0 93 */
danielebarchiesi@0 94 _getPlaceholder: function (settings) {
danielebarchiesi@0 95 return '<img src="' + settings.path + '/images/spacer.gif" alt="&lt;--break-&gt;" title="&lt;--break--&gt;" class="wysiwyg-break drupal-content" />';
danielebarchiesi@0 96 }
danielebarchiesi@0 97 };