Created
April 18, 2013 16:29
-
-
Save Partoo/5414118 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function BrowseServer( startupPath, functionData ) | |
| { | |
| // You can use the "CKFinder" class to render CKFinder in a page: | |
| var finder = new CKFinder(); | |
| // The path for the installation of CKFinder (default = "/ckfinder/"). | |
| finder.basePath = '/manage/libarary/editor/ckfinder'; | |
| //Startup path in a form: "Type:/path/to/directory/" | |
| finder.startupPath = startupPath; | |
| // Name of a function which is called when a file is selected in CKFinder. | |
| finder.selectActionFunction = SetFileField; | |
| // Additional data to be passed to the selectActionFunction in a second argument. | |
| // We'll use this feature to pass the Id of a field that will be updated. | |
| finder.selectActionData = functionData; | |
| // Name of a function which is called when a thumbnail is selected in CKFinder. | |
| finder.selectThumbnailActionFunction = ShowThumbnails; | |
| finder.selectThumbnailActionData = functionData; | |
| // Launch CKFinder | |
| finder.popup(); | |
| } | |
| // This is a sample function which is called when a file is selected in CKFinder. | |
| function SetFileField( fileUrl, data ) | |
| { | |
| document.getElementById( data["selectActionData"] ).value = fileUrl; | |
| var sFileName = this.getSelectedFile().name; | |
| document.getElementById( 'thumbnails' ).innerHTML = | |
| '<div class="thumb">' + | |
| '<img src="' + fileUrl + '" />' + | |
| '<div class="caption">' + | |
| '<a href="' + data["fileUrl"] + '" target="_blank">' + sFileName + '</a> (' + data["fileSize"] + 'KB)' + | |
| '</div>' + | |
| '</div>'; | |
| document.getElementById( 'preview' ).style.display = ""; | |
| } | |
| // This is a sample function which is called when a thumbnail is selected in CKFinder. | |
| function ShowThumbnails( fileUrl, data) | |
| { | |
| var url = window.location.protocol+"//"+window.location.host+window.location.port; | |
| var subStrNum = url.length; | |
| // this = CKFinderAPI | |
| document.getElementById( data['selectThumbnailActionData'] ).value =fileUrl.substr(subStrNum); | |
| var sFileName = this.getSelectedFile().name; | |
| document.getElementById( 'thumbnails' ).innerHTML = | |
| '<div class="thumb">' + | |
| '<img src="' + fileUrl + '" />' + | |
| '<div class="caption">' + | |
| '<a href="' + data["fileUrl"] + '" target="_blank">' + sFileName + '</a> (' + data["fileSize"] + 'KB)' + | |
| '</div>' + | |
| '</div>'; | |
| document.getElementById( 'preview' ).style.display = ""; | |
| // It is not required to return any value. | |
| // When false is returned, CKFinder will not close automatically. | |
| // return false; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment