-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
101 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* CKFinder - Sample Plugins | ||
* ========================== | ||
* http://cksource.com/ckfinder | ||
* Copyright (C) 2007-2015, CKSource - Frederico Knabben. All rights reserved. | ||
* | ||
* This file and its contents are subject to the MIT License. | ||
* Please read the LICENSE.md file before using, installing, copying, | ||
* modifying or distribute this file or part of its contents. | ||
*/ | ||
|
||
CKFinder.define( [ 'marionette' ], function( Marionette ) { | ||
'use strict'; | ||
|
||
/** | ||
* Plugin that adds a custom column to list view. | ||
*/ | ||
var CustomColumn = { | ||
init: function( finder ) { | ||
finder.on( 'listView:columns', function( evt ) { | ||
var sizeColumn = evt.data.columns.findWhere( { name: 'size' } ); | ||
|
||
if ( sizeColumn ) { | ||
sizeColumn.set( 'priority', 40 ); | ||
} | ||
|
||
var dateColumn = evt.data.columns.findWhere( { name: 'date' } ); | ||
|
||
if ( dateColumn ) { | ||
dateColumn.set( 'priority', 30 ); | ||
} | ||
} ); | ||
|
||
finder.on( 'listView:columns', function( evt ) { | ||
evt.data.columns.push( { | ||
name: 'type', | ||
label: 'Type', | ||
priority: 25 // Column will be displayed after name column | ||
} ); | ||
} ); | ||
|
||
// Add a view for file | ||
finder.on( 'listView:file:column:type', function( evt ) { | ||
evt.data.view = Marionette.ItemView.extend( { | ||
tagName: 'td', | ||
// The it variable contains file's attributes and template helpers | ||
template: finder.doT.template( '{{= it.getType( it.name ) }}' ), | ||
templateHelpers: { | ||
getType: function( name ) { | ||
var extension = name.substr( name.lastIndexOf( '.' ) + 1 ).toLowerCase(); | ||
|
||
if ( /(jpg|jpeg|gif|png)/.test( extension ) ) { | ||
return 'Image'; | ||
} | ||
|
||
if ( /(doc|docx|pdf)/.test( extension ) ) { | ||
return 'Document'; | ||
} | ||
|
||
return 'Other'; | ||
} | ||
} | ||
} ); | ||
} ); | ||
|
||
// Add a view for folder | ||
finder.on( 'listView:folder:column:type', function( evt ) { | ||
evt.data.view = Marionette.ItemView.extend( { | ||
tagName: 'td', | ||
template: finder.doT.template( 'Folder' ) | ||
} ); | ||
} ); | ||
} | ||
}; | ||
|
||
return CustomColumn; | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters