/
documentlist-custom.js
95 lines (85 loc) · 3.6 KB
/
documentlist-custom.js
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
/**
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of an unsupported extension to Alfresco.
*/
/**
* @module DocumentLibrary
*/
/**
* Large view extension of DocumentListViewRenderer component.
*
* @namespace Alfresco
* @class Alfresco.DocumentListLargeViewRenderer
* @extends Alfresco.DocumentListViewRenderer
*/
(function()
{
/**
* YUI Library aliases
*/
var Dom = YAHOO.util.Dom,
Event = YAHOO.util.Event,
Anim = YAHOO.util.Anim;
/**
* Alfresco Slingshot aliases
*/
var $html = Alfresco.util.encodeHTML;
/**
* LargeViewRenderer constructor.
*
* @param name {String} The name of the LargeViewRenderer
* @return {Alfresco.DocumentListLargeViewRenderer} The new LargeViewRenderer instance
* @constructor
*/
Alfresco.DocumentListLargeViewRenderer = function(name)
{
Alfresco.DocumentListLargeViewRenderer.superclass.constructor.call(this, name);
// Defaults to large but we'll copy the metadata from detailed view
this.metadataBannerViewName = "detailed";
this.metadataLineViewName = "detailed";
this.thumbnailColumnWidth = 200;
return this;
};
/**
* Extend from Alfresco.DocumentListViewRenderer
*/
YAHOO.extend(Alfresco.DocumentListLargeViewRenderer, Alfresco.DocumentListViewRenderer);
Alfresco.DocumentListLargeViewRenderer.prototype.renderCellThumbnail = function Example_renderCellThumbnail(scope, elCell, oRecord, oColumn, oData, imgIdSuffix)
{
var record = oRecord.getData(),
node = record.jsNode,
properties = node.properties,
name = record.displayName,
isContainer = node.isContainer,
isLink = node.isLink,
extn = name.substring(name.lastIndexOf(".")),
imgId = node.nodeRef.nodeRef; // DD added
var containerTarget; // This will only get set if thumbnail represents a container
oColumn.width = this.thumbnailColumnWidth;
Dom.setStyle(elCell, "width", oColumn.width + "px");
Dom.setStyle(elCell.parentNode, "width", oColumn.width + "px");
if (isContainer || (isLink && node.linkedNode.isContainer))
{
elCell.innerHTML = '<span class="folder documents-large">' + (isLink ? '<span class="link"></span>' : '') + (scope.dragAndDropEnabled ? '<span class="droppable"></span>' : '') + Alfresco.DocumentList.generateFileFolderLinkMarkup(scope, record) + '<img id="' + imgId + '" src="' + Alfresco.constants.URL_RESCONTEXT + 'components/documentlibrary/images/folder-64.png" /></a>';
containerTarget = new YAHOO.util.DDTarget(imgId); // Make the folder a target
}
else
{
elCell.innerHTML = '<span class="thumbnail documents-large">' + (isLink ? '<span class="link"></span>' : '') + Alfresco.DocumentList.generateFileFolderLinkMarkup(scope, record) + '<img id="' + imgId + '" src="' + Alfresco.DocumentList.generateThumbnailUrl(record, 'imgpreview') + '" alt="' + extn + '" title="' + $html(name) + '" /></a></span>';
}
var dnd = new Alfresco.DnD(imgId, scope);
};
})();