/usr/share/drupal6/modules/imagefield_assist/imagefield_assist_textarea.js is in drupal6-mod-imagefield-assist 1.0~beta3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | // $Id: imagefield_assist_textarea.js,v 1.1.2.1 2009/10/22 01:48:41 franz Exp $
/**
* This javascript file allows imagefield_assist to work with a plain textarea.
* This file is used instead of imagefield_assist_tinymce.js if imagefield_assist is called
* from the textarea button.
* Additional JS files similar to imagefield_assist_textarea.js and
* imagefield_assist_tinymce.js could be created for using imagefield_assist with other
* WYSIWYG editors. Some minor code changes to the menu function in
* imagefield_assist.module will be necessary, at least in imagefield_assist_menu() and
* imagefield_assist_loader().
*
* @todo update this
*/
// Declare global variables
var myDoc, myForm, myTextarea, hasInputFormat;
function initLoader() {
// Save the references to the parent form and textarea to be used later.
myDoc = window.opener.document; // global (so don't use var keyword)
myForm = '';
myTextarea = '';
hasInputFormat = false;
var args = getArgs(); // get the querystring arguments
var textarea = args.textarea;
// Reference the form object for this textarea.
if (myDoc.getElementsByTagName) {
var f = myDoc.getElementsByTagName('form');
for (var i=0; i<f.length; i++) {
// Is this textarea is using an input format?
if (f[i]['edit-format']) {
hasInputFormat = true;
}
if (f[i][textarea]) {
myForm = f[i];
myTextarea = f[i][textarea];
break;
}
}
}
frames['imagefield_assist_main'].window.location.href = Drupal.settings.basePath + 'index.php?q=imagefield_assist/thumbs/imagefield_assist_browser';
}
function initProperties() {
setHeader('properties');
updateCaption();
onChangeLink();
onChangeSizeLabel();
}
function initThumbs() {
setHeader('browse');
}
function initHeader() {
}
function initUpload() {
setHeader('uploading');
}
function getFilterTag(formObj) {
var fid = formObj['edit-fid'].value;
var captionTitle = formObj['edit-title'].value;
var captionDesc = formObj['edit-desc'].value;
var link = formObj['edit-link'].value;
var url = formObj['edit-url'].value;
var align = formObj['edit-align'].value;
var width = formObj['edit-width'].value;
var height = formObj['edit-height'].value;
var preset = formObj['edit-size-label'].value;
var lightbox = formObj['edit-lightbox'].checked;
// Create the image placeholder tag
var miscAttribs = 'fid=' + fid + '|title=' + captionTitle + '|desc=' + captionDesc + '|link=' + link;
if (lightbox) {
miscAttribs += '|lightbox=true';
}
if (url != formObj['edit-default-url'].value) {
miscAttribs += '|url=' + url;
}
var content = '[imagefield_assist|' + miscAttribs + '' + '|align=' + align + '|preset=' + preset;
if (preset=='other'){
content += '|width=' + width + '|height=' + height;
}
content += ']';
return content;
}
function insertToEditor(content) {
// Insert the image
if (myDoc.selection) {
// IE
myTextarea.focus();
cursor = myDoc.selection.createRange();
cursor.text = content;
}
else if (myTextarea.selectionStart || myTextarea.selectionStart == "0") {
// Gecko-based engines: Mozilla, Camino, Firefox, Netscape
var startPos = myTextarea.selectionStart;
var endPos = myTextarea.selectionEnd;
var body = myTextarea.value;
myTextarea.value = body.substring(0, startPos) + content + body.substring(endPos, body.length);
}
else {
// Worst case scenario: browsers that don't know about cursor position:
// Safari, OmniWeb, Konqueror
myTextarea.value += content;
}
// Close the dialog
return cancelAction();
}
function cancelAction() {
// Close the dialog
window.close();
return false;
}
/**
* getArgs() by Jim K - From Orielly JSB pp 244
*
* This function parses comma separated name=value argument pairs from the query
* string of the URL. It stores the name=value pairs in properties of an object
* and then returns that object.
*
* @example
* var args = getArgs();
* alert(args.CSSPATH);
*/
function getArgs() {
var args = new Object();
var query = location.search.substring(1); // Get Query String
var pairs = query.split("&"); // Split query at the ampersand
for(var i = 0; i < pairs.length; i++) { // Begin loop through the querystring
var pos = pairs[i].indexOf('='); // Look for "name=value"
if (pos == -1) continue; // if not found, skip to next
var argname = pairs[i].substring(0,pos); // Extract the name
var value = pairs[i].substring(pos+1); // Extract the value
args[argname] = unescape(value); // Store as a property
}
return args; // Return the Object
}
|