diff --git a/scripts/ckeditor-config.js b/scripts/ckeditor-config.js index 288377de..6ab242ec 100755 --- a/scripts/ckeditor-config.js +++ b/scripts/ckeditor-config.js @@ -7,5 +7,5 @@ CKEDITOR.editorConfig = function( config ) { // Define changes to default configuration here. For example: // config.language = 'fr'; // config.uiColor = '#AADC6E'; - config.extraPlugins = 'abbr,timestamp,dndfiles,eqneditor'; + config.extraPlugins = 'timestamp,dndfiles,eqneditor,fileupload'; }; diff --git a/scripts/ckeditor/plugins/abbr/dialogs/abbr.js b/scripts/ckeditor/plugins/abbr/dialogs/abbr.js deleted file mode 100644 index cfb9d18a..00000000 --- a/scripts/ckeditor/plugins/abbr/dialogs/abbr.js +++ /dev/null @@ -1,83 +0,0 @@ -/** - * The abbr dialog definition. - * - * Created out of the CKEditor Plugin SDK: - * http://docs.ckeditor.com/#!/guide/plugin_sdk_sample_1 - */ - -// Our dialog definition. -CKEDITOR.dialog.add( 'abbrDialog', function( editor ) { - return { - - // Basic properties of the dialog window: title, minimum size. - title: 'Abbreviation Properties', - minWidth: 400, - minHeight: 200, - - // Dialog window contents definition. - contents: [ - { - // Definition of the Basic Settings dialog tab (page). - id: 'tab-basic', - label: 'Basic Settings', - - // The tab contents. - elements: [ - { - // Text input field for the abbreviation text. - type: 'text', - id: 'abbr', - label: 'Abbreviation', - - // Validation checking whether the field is not empty. - validate: CKEDITOR.dialog.validate.notEmpty( "Abbreviation field cannot be empty" ) - }, - { - // Text input field for the abbreviation title (explanation). - type: 'text', - id: 'title', - label: 'Explanation', - validate: CKEDITOR.dialog.validate.notEmpty( "Explanation field cannot be empty" ) - } - ] - }, - - // Definition of the Advanced Settings dialog tab (page). - { - id: 'tab-adv', - label: 'Advanced Settings', - elements: [ - { - // Another text field for the abbr element id. - type: 'text', - id: 'id', - label: 'Id' - } - ] - } - ], - - // This method is invoked once a user clicks the OK button, confirming the dialog. - onOk: function() { - - // The context of this function is the dialog object itself. - // http://docs.ckeditor.com/#!/api/CKEDITOR.dialog - var dialog = this; - - // Creates a new element. - var abbr = editor.document.createElement( 'abbr' ); - - // Set element attribute and text, by getting the defined field values. - abbr.setAttribute( 'title', dialog.getValueOf( 'tab-basic', 'title' ) ); - abbr.setText( dialog.getValueOf( 'tab-basic', 'abbr' ) ); - - // Now get yet another field value, from the advanced tab. - var id = dialog.getValueOf( 'tab-adv', 'id' ); - if ( id ) - abbr.setAttribute( 'id', id ); - - // Finally, inserts the element at the editor caret position. - editor.insertElement( abbr ); - } - }; -}); \ No newline at end of file diff --git a/scripts/ckeditor/plugins/abbr/icons/abbr.png b/scripts/ckeditor/plugins/abbr/icons/abbr.png deleted file mode 100644 index 7d863f94..00000000 Binary files a/scripts/ckeditor/plugins/abbr/icons/abbr.png and /dev/null differ diff --git a/scripts/ckeditor/plugins/fileupload/dialogs/fileupload.js b/scripts/ckeditor/plugins/fileupload/dialogs/fileupload.js new file mode 100644 index 00000000..2ff1f086 --- /dev/null +++ b/scripts/ckeditor/plugins/fileupload/dialogs/fileupload.js @@ -0,0 +1,132 @@ +/** + * The abbr dialog definition. + * + * Created out of the CKEditor Plugin SDK: + * http://docs.ckeditor.com/#!/guide/plugin_sdk_sample_1 + */ + +// Our dialog definition. +CKEDITOR.dialog.add( 'fileuploadDialog', function( editor ) { + + var lang = editor.lang.image2; + console.log(editor.lang); + console.log(lang.btnUpload); + + return { + + // Basic properties of the dialog window: title, minimum size. + title: 'Upload file', + minWidth: 200, + minHeight: 150, + + // Dialog window contents definition. + contents: [ + { + // Definition of the Upload Settings dialog tab (page). + id: 'Upload', + label: lang.uploadTab, + + // The tab contents. + elements: [ + { + // File browser for selecting a file + type: 'file', + id: 'upload', + label: lang.btnUpload, + style: 'height:40px', + }, + { + // Button for uploading the file. + type: 'fileButton', + id: 'uploadButton', + label: lang.btnUpload, + onLoad: function( a ) { + CKEDITOR.document.getById( this.domId ).on( 'click', function() { + + // grab the file(s) from the file input tag and upload it using AJAX + var dialog = this.getDialog(); + var files = dialog.getContentElement("Upload", "upload").getInputElement().$.files; + var formData = new FormData(); + formData.append('drop-count', files.length); // number of files being uploaded + formData.append('acmd', "Upload"); // Command for the server to recognize this as an ajax upload + for (var i = 0; i < files.length; i++) { + formData.append('next_attachment', parent.next_attachment); + formData.append('encoding', "HTML"); + formData.append('attfile', files[i]); + + // Remember the original name of the file in a hidden text field + dialog.getContentElement( 'Upload', 'name' ).setValue( files[i].name ); + } + + var URL = '/' + parent.logbook + '/upload.html?next_attachment=' + parent.next_attachment; + + $.ajax({ + xhr: function() + { + var xhr = new window.XMLHttpRequest(); + + //Upload progress + xhr.upload.addEventListener("progress", function(evt){ + if (evt.lengthComputable) { + var percentComplete = evt.loaded / evt.total; + //Do something with upload progress + // console.log(percentComplete); + } + }, false); + + return xhr; + }, + contentType: false, + processData: false, + type: 'POST', + url: URL, + data: formData, + success: function(data) { + dialog.getContentElement( 'Upload', 'src' ).setValue( data.attachments[0].fullName ); + }, + fail: function() { + console.log("error"); + } + }); + + // Do not call the built-in click command + return false; + }, this ); + }, + 'for': [ 'Upload', 'upload' ] + }, + { + // URL of the file + type: 'text', + id: 'src', + label: "URL", + + // Validation checking whether the field is not empty. + validate: CKEDITOR.dialog.validate.notEmpty( "URL cannot be empty!" ) + }, + { + // Original name of the file, this field is hidden and only used to + // capture and display the original filename in the editor + type: 'text', + id: 'name', + hidden: true + } + ] + } + ], + + // This method is invoked once a user clicks the OK button, confirming the dialog. + onOk: function() { + var dialog = this; + + console.log(dialog.getValueOf( 'Upload', 'src' )); + console.log(dialog.getValueOf( 'Upload', 'name' )); + + var file = editor.document.createElement( 'a' ); + file.setAttribute( 'href', dialog.getValueOf( 'Upload', 'src' ) ); + file.setText( dialog.getValueOf( 'Upload', 'name' ) ); + + editor.insertElement( file ); + } + }; +}); \ No newline at end of file diff --git a/scripts/ckeditor/plugins/fileupload/icons/fileupload.png b/scripts/ckeditor/plugins/fileupload/icons/fileupload.png new file mode 100644 index 00000000..14092372 Binary files /dev/null and b/scripts/ckeditor/plugins/fileupload/icons/fileupload.png differ diff --git a/scripts/ckeditor/plugins/abbr/plugin.js b/scripts/ckeditor/plugins/fileupload/plugin.js similarity index 67% rename from scripts/ckeditor/plugins/abbr/plugin.js rename to scripts/ckeditor/plugins/fileupload/plugin.js index b63be8c5..a4df419e 100644 --- a/scripts/ckeditor/plugins/abbr/plugin.js +++ b/scripts/ckeditor/plugins/fileupload/plugin.js @@ -6,32 +6,32 @@ */ // Register the plugin within the editor. -CKEDITOR.plugins.add( 'abbr', { +CKEDITOR.plugins.add( 'fileupload', { // Register the icons. - icons: 'abbr', + icons: 'fileupload', // The plugin initialization logic goes inside this method. init: function( editor ) { // Define an editor command that opens our dialog. - editor.addCommand( 'abbr', new CKEDITOR.dialogCommand( 'abbrDialog' ) ); + editor.addCommand( 'fileupload', new CKEDITOR.dialogCommand( 'fileuploadDialog' ) ); // Create a toolbar button that executes the above command. - editor.ui.addButton( 'Abbr', { + editor.ui.addButton( 'FileUpload', { // The text part of the button (if available) and tooptip. - label: 'Insert Abbreviation', + label: 'Upload a file', // The command to execute on click. - command: 'abbr', + command: 'fileupload', // The button placement in the toolbar (toolbar group name). toolbar: 'insert' }); // Register our dialog file. this.path is the plugin folder path. - CKEDITOR.dialog.add( 'abbrDialog', this.path + 'dialogs/abbr.js' ); + CKEDITOR.dialog.add( 'fileuploadDialog', this.path + 'dialogs/fileupload.js' ); } }); diff --git a/scripts/fckeditor.zip b/scripts/fckeditor.zip deleted file mode 100644 index aa5589d1..00000000 Binary files a/scripts/fckeditor.zip and /dev/null differ diff --git a/scripts/fckeditor/editor/plugins/elog/fckplugin.js b/scripts/fckeditor/editor/plugins/elog/fckplugin.js deleted file mode 100644 index 786609bf..00000000 --- a/scripts/fckeditor/editor/plugins/elog/fckplugin.js +++ /dev/null @@ -1,151 +0,0 @@ -/* - * FCKeditor - The text editor for Internet - http://www.fckeditor.net - * Copyright (C) 2003-2007 Frederico Caldeira Knabben - * - * == BEGIN LICENSE == - * - * Licensed under the terms of any of the following licenses at your - * choice: - * - * - GNU General Public License Version 2 or later (the "GPL") - * http://www.gnu.org/licenses/gpl.html - * - * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") - * http://www.gnu.org/licenses/lgpl.html - * - * - Mozilla Public License Version 1.1 or later (the "MPL") - * http://www.mozilla.org/MPL/MPL-1.1.html - * - * == END LICENSE == - * - * This plugin registers ELOG specific Toolbar items - */ - -/*---- 'Submit' ----------------------------------------------------*/ - -// Register 'Submit' toolbar button -var oELOGSubmitItem = new FCKToolbarButton('ELOGSubmit', window.top.ELOGSubmitEntry, null, null, true, null, 3); -FCKToolbarItems.RegisterItem('ELOGSubmit', oELOGSubmitItem); - -// Register 'Submit' command -var oELOGSubmitCommand = new Object(); -oELOGSubmitCommand.Name = 'ELOGSubmit'; - -oELOGSubmitCommand.Execute = function() -{ - window.top.document.form1.jcmd.value = "Submit"; - if(window.top.chkform()) - window.top.cond_submit(); -} - -oELOGSubmitCommand.GetState = function() -{ - // This function is always enabled. - return FCK_TRISTATE_OFF ; -} - -FCKCommands.RegisterCommand('ELOGSubmit', oELOGSubmitCommand); - -/*---- 'ELOGImage' ------------------------------------------------*/ - -// Register 'ELOGImage' toolbar button -var oELOGImage = new FCKToolbarButton('ELOGImage', window.top.ELOGInsertImage, null, null, true, null, 37); -FCKToolbarItems.RegisterItem('ELOGImage', oELOGImage); - -// Register 'ELOGImage' command -var oELOGImageCommand = new Object(); -oELOGImageCommand.Name = 'ELOGImage'; - -oELOGImageCommand.Execute = function() -{ - window.open('../../'+parent.logbook+'/upload.html?next_attachment='+parent.next_attachment, '', - 'top=280,left=350,width=500,height=120,dependent=yes,menubar=no,status=no,scrollbars=no,location=no,resizable=yes'); -} - -oELOGImageCommand.GetState = function() -{ - // This function is always enabled. - return FCK_TRISTATE_OFF ; -} - -FCKCommands.RegisterCommand('ELOGImage', oELOGImageCommand); - -/*---- 'InsertTime' ------------------------------------------------*/ - -// Create 'InsertTime' toolbar button -var oInsertTimeItem = new FCKToolbarButton('InsertTime', window.top.ELOGInsertDateTime, null, null, true, null, 4); -oInsertTimeItem.IconPath = FCKConfig.PluginsPath + 'elog/inserttime.gif' ; -FCKToolbarItems.RegisterItem('InsertTime', oInsertTimeItem); - -// Register 'InsertTime' command -var oInsertTimeCommand = new Object(); -oInsertTimeCommand.Name = 'InsertTime'; - -oInsertTimeCommand.Execute = function() -{ - var xmlHttp; - - try { - xmlHttp = new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari - } - catch (e) { - try { - xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer - } - catch (e) { - try { - xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); - } - catch (e) { - alert("Your browser does not support AJAX!"); - return false; - } - } - } - - xmlHttp.onreadystatechange = function() - { - if(xmlHttp.readyState == 4) { - // Get the editor instance that we want to interact with. - var oEditor = FCKeditorAPI.GetInstance('Text') ; - - // Insert the desired HTML. - oEditor.InsertHtml(xmlHttp.responseText); - } - } - - xmlHttp.open("GET","../../?cmd=gettimedate",true); - xmlHttp.send(null); -} - -oInsertTimeCommand.GetState = function() -{ - // This function is always enabled. - return FCK_TRISTATE_OFF ; -} - -FCKCommands.RegisterCommand('InsertTime', oInsertTimeCommand); - -/*---- 'InsertLink' ------------------------------------------------*/ - -// Create 'InsertLink' toolbar button -var oInsertLinkItem = new FCKToolbarButton('InsertLink', window.top.ELOGInsertLink, null, null, true, null, 34); -FCKToolbarItems.RegisterItem('InsertLink', oInsertLinkItem); - -// Register 'InsertLink' command -var oInsertLinkCommand = new Object(); -oInsertLinkCommand.Name = 'InsertLink'; - -oInsertLinkCommand.Execute = function() -{ - linkText = prompt(window.top.ELOGLinkTextPrompt, ''); - linkURL = prompt(window.top.ELOGLinkURLPrompt, 'http://'); - - // Get the editor instance that we want to interact with. - var oEditor = FCKeditorAPI.GetInstance('Text') ; - - // Insert the desired HTML. - oEditor.InsertHtml(''+linkText+''); -} - -FCKCommands.RegisterCommand('InsertLink', oInsertLinkCommand); diff --git a/scripts/fckeditor/editor/plugins/elog/inserttime.gif b/scripts/fckeditor/editor/plugins/elog/inserttime.gif deleted file mode 100644 index 35b0020c..00000000 Binary files a/scripts/fckeditor/editor/plugins/elog/inserttime.gif and /dev/null differ diff --git a/scripts/fckeditor/fckelog.js b/scripts/fckeditor/fckelog.js deleted file mode 100644 index 79e9689e..00000000 --- a/scripts/fckeditor/fckelog.js +++ /dev/null @@ -1,52 +0,0 @@ -/* - * ELOG specific FCKedit configuration - */ - -FCKConfig.PluginsPath = FCKConfig.BasePath.substr(0, FCKConfig.BasePath.length - 7) + 'editor/plugins/'; -FCKConfig.Plugins.Add('elog', null); - -FCKConfig.FirefoxSpellChecker = true ; - -FCKConfig.Plugins.Add('dragresizetable'); - -FCKConfig.ProtectedSource.Add( //gi ) ; //