Skip to content

Commit

Permalink
calculate "extension", since it's removed from API response #106
Browse files Browse the repository at this point in the history
  • Loading branch information
psolom committed May 7, 2017
1 parent 15f8c37 commit 1722cb2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
<span data-bind="text: koItem.rdo.attributes.name"></span>
</div>
</td>
<td data-bind="text: koItem.rdo.attributes.extension"></td>
<td data-bind="text: koItem.cdo.extension"></td>
<td data-bind="text: koItem.cdo.sizeFormatted"></td>
<td data-bind="text: koItem.cdo.dimensions"></td>
<td data-bind="text: koItem.rdo.attributes.modified"></td>
Expand Down
23 changes: 14 additions & 9 deletions scripts/filemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
preview_model.cdo({
isFolder: (resourceObject.type === 'folder'),
sizeFormatted: formatBytes(resourceObject.attributes.size),
extension: (resourceObject.type === 'file') ? getExtension(resourceObject.id) : null,
dimensions: resourceObject.attributes.width ? resourceObject.attributes.width + 'x' + resourceObject.attributes.height : null
});
});
Expand Down Expand Up @@ -953,7 +954,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)

this.initiateEditor = function(elements) {
var textarea = $previewWrapper.find('.fm-cm-editor-content')[0];
preview_model.editor.createInstance(preview_model.rdo().attributes.extension, textarea, {
preview_model.editor.createInstance(preview_model.cdo().extension, textarea, {
readOnly: false,
styleActiveLine: true
});
Expand All @@ -980,7 +981,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
} else {
cssClass.push('ico_file');
if(this.rdo().attributes.readable) {
extraClass.push('ext', this.rdo().attributes.extension);
extraClass.push('ext', this.cdo().extension);
} else {
extraClass.push('file', 'lock');
}
Expand Down Expand Up @@ -1245,6 +1246,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
this.rdo = resourceObject;
this.cdo = { // computed data object
isFolder: (resourceObject.type === 'folder'),
extension: (resourceObject.type === 'file') ? getExtension(resourceObject.id) : null,
dimensions: resourceObject.attributes.width ? resourceObject.attributes.width + 'x' + resourceObject.attributes.height : null,
cssItemClass: (resourceObject.type === 'folder') ? 'directory' : 'file'
};
Expand Down Expand Up @@ -1381,7 +1383,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
} else {
cssClass = 'ico_file';
if(this.rdo.attributes.readable) {
extraClass.push('ext', this.rdo.attributes.extension);
extraClass.push('ext', this.cdo.extension);
} else {
extraClass.push('file', 'lock');
}
Expand Down Expand Up @@ -1643,6 +1645,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
this.cdo = { // computed data object
isFolder: (resourceObject.type === 'folder'),
sizeFormatted: formatBytes(resourceObject.attributes.size),
extension: (resourceObject.type === 'file') ? getExtension(resourceObject.id) : null,
dimensions: resourceObject.attributes.width ? resourceObject.attributes.width + 'x' + resourceObject.attributes.height : null,
cssItemClass: (resourceObject.type === 'folder') ? 'directory' : 'file',
imageUrl: createImageUrl(resourceObject, true, true),
Expand Down Expand Up @@ -1685,7 +1688,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
} else {
cssClass = 'ico_file';
if (this.rdo.attributes.readable) {
extraClass.push('ext', this.rdo.attributes.extension);
extraClass.push('ext', this.cdo.extension);
} else {
extraClass.push('file', 'lock');
}
Expand All @@ -1707,7 +1710,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
} else {
cssClass.push('ico_file');
if (this.rdo.attributes.readable) {
extraClass.push('ext', this.rdo.attributes.extension);
extraClass.push('ext', this.cdo.extension);
} else {
extraClass.push('file', 'lock');
}
Expand Down Expand Up @@ -2096,8 +2099,10 @@ $.richFilemanagerPlugin = function(element, pluginOptions)

this.processDomElements = function($container) {
if (!instance.instance) {
var textarea = $container.find('.fm-cm-renderer-content')[0];
instance.createInstance(render_model.rdo().attributes.extension, textarea, {
var textarea = $container.find('.fm-cm-renderer-content')[0],
extension = getExtension(render_model.rdo().id);

instance.createInstance(extension, textarea, {
readOnly: 'nocursor',
styleActiveLine: false,
lineNumbers: false
Expand Down Expand Up @@ -2557,7 +2562,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)

switch(sortField) {
case 'type':
sortBy = item.rdo.attributes.extension || '';
sortBy = item.cdo.extension || '';
break;
case 'size':
sortBy = item.rdo.attributes.size;
Expand Down Expand Up @@ -3003,7 +3008,7 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
imageUrl = buildAbsolutePath(encodePath(resourceObject.attributes.path), disableCache);
} else {
var queryParams = {path: resourceObject.id};
if (resourceObject.attributes.extension === 'svg') {
if (getExtension(resourceObject.id) === 'svg') {
queryParams.mode = 'readfile';
} else {
queryParams.mode = 'getimage';
Expand Down
Loading

0 comments on commit 1722cb2

Please sign in to comment.