Files
alfresco-community-repo/source/web/scripts/office/external_component.js
Kevin Roast 189422edce Merged V3.2E to HEAD
17495: Changed xforms-samples name to wcm-sample
   17496: Minor fixes for day and week views when rendering new events
   17497: *RECORD ONLY* Added Enterprise logo local copy.
   17498: ETHREEOH-2933 - User can see contents of the moderated site if user is not a member of the site
          - Site containers are now private and non member's can't see content.
          - fix only applies to new moderated sites.
   17499: ETHREEOH-2322 - Office Plugin: filename overlaps the plugin UI if longer than 40 characters without spaces
   17500: Temorary build fix for site visibility
   17508: ETHREEOH-1268 - Pages and Components show varying degrees of success handling "site not found" errors.
   17509: Fix for ETHREEOH1733 - Wrong display of multi day events in Share
   17514: View In Browser action for document list and document details actions.
   17515: Merged DEV-TEMPORARY to V3.2
      17471: ETHREEOH-3193: 'capitalize' in output path pattern works differently for templates (vs. XSDs)
   17516: Missing css file from Edit Offline changes. Also "Checked out on/by" text changed to "Editing started on/by". Tags now comma separated
   17517: Merged DEV-TEMPORARY to V3.2
      17474: ETHREEOH-1211: Can't See Images in TinyMCE
   17518: Office add-in: ETHREEOH-3361 - Workflow name is visible only before symbol &, ETHREEOH-2735 - Total number of founded items is not shown
   17519: 3.2E help links
   17520: 3.2E help links, plus ETHREEOH-1536 - Incorrect "insert into current document" function work for unsupported files in MS Office Addin
   17522: Fix for ETHREEOH-3257 - Event becomes All day again after editing it to not All day
   17526: Fix for unreported issue when rendering an edited event after the view is filtered via tag component causes an script error
   17528: Fixed ETHREEOH-3364 " Admin Console - Group Search needs to show searching message and disable further requests while search is running"
          - Disabling search button & message displaying "Searching..." after 2 seconds for long searches for the following components:
             * Admin Console: Users - search user, add group
             * Admin Console: Groups - search group, add group, add user
             * Site: Members: People - search members, add people
             * Site: Members: Groups - search membergroups, add group
             * Site: Members: Pending invites - search invites
             * Site: Doclib: Assign Workflow - add users
             * People Finder 
             * Site Finder
          - All component listed above uses max search result except the following where webscript services lacks support for it:
             * Admin Console: Users - add group
             * Admin Console: Groups - search group, add group
             * Site: Members: Pending invites - search invites
          - Bugfix: When minSearchTermLength is set to 0:
             * Group Admin Console: switched to browse view
             * User Admin Console: didnt do a search
          - Bugfix: For some components minSearchTermLength & maxSearchResults were brought in as strings causing the global search's max result to be 1001 instead of 101

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18126 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2010-01-19 11:50:05 +00:00

271 lines
7.0 KiB
JavaScript
Executable File

/**
* External component static wrapper that composes and 'calls' external component methods
*/
var ExternalComponent =
{
extender: null,
init: function(params, extenderType)
{
if (typeof extenderType == "undefined")
{
// MSOffice mode check
extenderType = (typeof top.window.external != "undefined" && typeof top.window.external.saveToAlfresco != "undefined") ? "msoffice" : "openoffice";
}
switch (extenderType.toLowerCase())
{
case "msoffice":
this.extender = new MSOffice(params);
break;
case "openoffice":
this.extender = new OpenOffice(params);
break;
default:
alert('ExtenderType "' + extenderType + '" is not supported.');
return;
}
},
openDocument: function()
{
return this.extender.openDocument.apply(this.extender, arguments);
},
docHasExtension: function()
{
return this.extender.docHasExtension.apply(this.extender, arguments);
},
saveToAlfresco: function()
{
return this.extender.saveToAlfresco.apply(this.extender, arguments);
},
saveToAlfrescoAs: function()
{
return this.extender.saveToAlfrescoAs.apply(this.extender, arguments);
},
compareDocument: function()
{
return this.extender.compareDocument.apply(this.extender, arguments);
},
insertDocument: function()
{
return this.extender.insertDocument.apply(this.extender, arguments);
}
}
/**
* External component wrapper for Microsoft Internet Explorer and MSOffice add-in
*/
var MSOffice = new Class(
{
params: {},
initialize: function(params)
{
$extend(this.params, params);
},
openDocument: function(relativePath)
{
window.external.openDocument(relativePath);
},
docHasExtension: function(fnTrue, fnFalse)
{
if (window.external.docHasExtension())
{
fnTrue.apply(arguments.callee);
}
else
{
fnFalse.apply(arguments.callee);
}
},
saveToAlfresco: function(relativePath)
{
return window.external.saveToAlfresco(relativePath);
},
saveToAlfrescoAs: function(relativePath, filename)
{
return window.external.saveToAlfrescoAs(relativePath, filename);
},
compareDocument: function(url)
{
return window.external.compareDocument(url);
},
insertDocument: function(relativePath, nodeRef)
{
return window.external.insertDocument(relativePath, nodeRef);
}
});
/**
* External component wrapper for OpenOffice.org add-in
*/
var OpenOffice = new Class(
{
debugMode: false,
queryResults: [],
params: {},
initialize: function(params)
{
$extend(this.params, params);
},
// Open document with given relativePath
openDocument: function(relativePath)
{
with (this)
{
logDebug('openDocument', 'relativePath=' + relativePath);
doExternalCall('openDocument', relativePath);
}
},
// call external hoster object method
docHasExtension: function(functionIfTrue, functionIfFalse)
{
with (this)
{
logDebug('docHasExtension', 'functionIfTrue, functionIfFalse');
queryResults["docHasExtension"] = null;
checkBooleanResult(10, 'docHasExtension', functionIfTrue, functionIfFalse).delay(100, this);
doExternalCall('docHasExtension', '').delay(1000, this);
}
},
// call external hoster object method
saveToAlfresco: function(currentPath)
{
with (this)
{
logDebug('saveToAlfresco', 'currentPath=' + currentPath);
doExternalCall('saveToAlfresco', currentPath);
}
},
// call external hoster object method
saveToAlfrescoAs: function(currentPath, filename)
{
with (this)
{
logDebug('saveToAlfrescoAs', 'currentPath=' + currentPath + ", filename=" + filename);
doExternalCallEx('saveToAlfrescoAs', currentPath, filename);
}
},
compareDocument: function(currentPath)
{
with (this)
{
logDebug('compareDocument', 'currentPath=' + currentPath);
doExternalCall('compareDocument', currentPath);
}
},
// Insert a document into the currently open one
insertDocument: function(relativePath)
{
with (this)
{
logDebug('insertDocument', 'relativePath=' + relativePath);
doExternalCall('insertDocument', relativePath);
}
},
/**
* Implementation-specific functions
*/
// Set external method call result
setResult: function(methodName, success)
{
with (this)
{
logDebug('setResult', 'method=' + methodName + ', success=' + success);
queryResults[methodName] = success;
}
},
// used by timer for checking boolean result of external method call
checkBooleanResult: function(maxCount, methodName, functionIfTrue, functionIfFalse)
{
with (this)
{
var result = queryResults[methodName];
logDebug('checkBooleanResult', 'waiting: maxCount=' + maxCount + ", methodName=" + methodName + ", ...");
if (result != null)
{
if (result)
{
functionIfTrue();
}
else
{
functionIfFalse();
}
return;
}
if (maxCount <= 0)
{
logDebug('checkBooleanResult', 'waiting timeout: maxCount=' + maxCount + ", methodName=" + methodName + ", ...");
return;
}
checkBooleanResult(maxCount-1, methodName, functionIfTrue, functionIfFalse).delay(1000, this);
}
},
// compose URL for purpose to call external object method
doExternalCall: function(methodName, path)
{
with (this)
{
var newUrl = params.folderPath + "callexternal?extcall=&action=" + methodName
+ "&path=" + encodeURIComponent(path) + "&ts=" + new Date().getTime()
+ (params.ticket != "" ? "&ticket=" + params.ticket : "");
logDebug('doExternalCall', 'url=' + newUrl);
$("if_externalComponenetMethodCall").src = newUrl;
}
},
// compose URL for purpose to call external object method
doExternalCallEx: function(methodName, path, filename)
{
with (this)
{
var newUrl = params.folderPath + "callexternal?extcall=&action=" + methodName
+ "&path=" + encodeURIComponent(path) + "&filename=" + encodeURIComponent(filename) + "&ts=" + new Date().getTime()
+ (params.ticket != "" ? "&ticket=" + params.ticket : "");
logDebug('doExternalCallEx', 'url=' + newUrl);
$("if_externalComponenetMethodCall").src = newUrl;
}
},
// logger method
logDebug: function(methodName, message)
{
with (this)
{
if (debugMode.enabled && debugMode.methods[methodName])
{
alert("[DEBUG][ExternalComponent::" + methodName + "] " + message);
}
}
}
});