diff --git a/editors/ckeditor/plugin.js b/editors/ckeditor/plugin.js index 2dcd53d..1704b57 100644 --- a/editors/ckeditor/plugin.js +++ b/editors/ckeditor/plugin.js @@ -7,25 +7,126 @@ requires : [], init: function(editor) { - // Add Button editor.ui.addButton('video_filter', { label: 'Video filter', command: 'video_filter', icon: this.path + 'video_filter.png' }); - // Add Command - editor.addCommand('video_filter', { - exec : function () { - var path = (Drupal.settings.video_filter.url.wysiwyg_ckeditor) ? Drupal.settings.video_filter.url.wysiwyg_ckeditor : Drupal.settings.video_filter.url.ckeditor - var media = window.showModalDialog(path, { 'opener' : window, 'editorname' : editor.name }, "dialogWidth:580px; dialogHeight:480px; center:yes; resizable:yes; help:no;"); - } - }); - // Register an extra fucntion, this will be used in the popup. - editor._.video_filterFnNum = CKEDITOR.tools.addFunction(insert, editor); + if(typeof window.showModalDialog !== 'undefined') { + editor.addCommand('video_filter', { + exec : function () { + var path = (Drupal.settings.video_filter.url.wysiwyg_ckeditor) ? Drupal.settings.video_filter.url.wysiwyg_ckeditor : Drupal.settings.video_filter.url.ckeditor + var media = window.showModalDialog(path, { 'opener' : window, 'editorname' : editor.name }, "dialogWidth:580px; dialogHeight:480px; center:yes; resizable:yes; help:no;"); + } + }); + + // Register an extra function, this will be used in the popup. + editor._.video_filterFnNum = CKEDITOR.tools.addFunction(insert, editor); + } + else { + editor.addCommand('video_filter', new CKEDITOR.dialogCommand('video_filterDialog')); + } } + }); + CKEDITOR.dialog.add('video_filterDialog', function( editor ) { + var instructions_path = Drupal.settings.video_filter.instructions_url; + + return { + title : 'Add Video', + minWidth : 600, + minHeight : 180, + contents : [{ + id : 'general', + label : 'Settings', + elements : [ + { + type : 'text', + id : 'file_url', + label : 'URL', + validate : CKEDITOR.dialog.validate.notEmpty( 'The link must have a URL.' ), + required : true, + commit : function( data ) + { + data.file_url = this.getValue(); + } + }, + { + type : 'text', + id : 'width', + label : 'Width', + commit : function( data ) + { + data.width = this.getValue(); + } + }, + { + type : 'text', + id : 'height', + label : 'Height', + commit : function( data ) + { + data.height = this.getValue(); + } + }, + { + type : 'select', + id : 'align', + label : 'Align', + 'default': 'none', + items: [ + ['None', ''], + ['Left', 'left'], + ['Right', 'right'], + ['Center', 'center'] + ], + commit : function( data ) + { + data.align = this.getValue(); + } + }, + { + type : 'checkbox', + id : 'autoplay', + label : 'Autoplay', + 'default': '', + commit : function( data ) + { + data.autoplay = this.getValue() ? 1 : 0; + } + }, + { + type: 'html', + html: '', + }, + ] + }], + onOk : function() + { + var dialog = this, + data = {}, + link = editor.document.createElement( 'p' ); + this.commitContent( data ); + var str = '[video:' + data.file_url; + if (data.width) { + str += ' width:' + data.width; + } + if (data.height) { + str += ' height:' + data.height; + } + if (data.align) { + str += ' align:' + data.align; + } + if (data.autoplay) { + str += ' autoplay:' + data.autoplay; + } + str += ']'; + link.setHtml( str ); + editor.insertElement( link ); + } + }; }); function insert(params, editor) { diff --git a/video_filter.module b/video_filter.module index a0487c8..cd978de 100644 --- a/video_filter.module +++ b/video_filter.module @@ -386,6 +386,15 @@ function video_filter_menu() { 'theme callback' => '_video_filter_dashboard_theme', ); + $items['video_filter/instructions'] = array( + 'title' => 'Videofilter instructions', + 'description' => 'instructions', + 'page callback' => 'video_filter_instructions_page', + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + 'theme callback' => '_video_filter_dashboard_theme', + ); + return $items; } @@ -445,6 +454,17 @@ function video_filter_dashboard_page($editor) { exit(); } +/** + * Creates the instructions page. + */ +function video_filter_instructions_page() { + module_invoke('admin_menu', 'suppress'); + + $form = drupal_get_form('_video_filter_instructions_form'); + print theme('video_filter_dashboard', array('form' => render($form))); + exit(); +} + function _video_filter_form() { $form['video_filter'] = array( '#type' => 'fieldset', @@ -501,6 +521,25 @@ function _video_filter_form() { '#weight' => 5, ); + $form += _video_filter_instructions_form(); + + $form['cancel'] = array( + '#type' => 'button', + '#value' => t('Cancel'), + '#weight' => 98, + ); + + $form['insert'] = array( + '#type' => 'button', + '#value' => t('Insert'), + '#weight' => 99, + ); + + return $form; +} + +function _video_filter_instructions_form() { + $form['instructions'] = array( '#type' => 'fieldset', '#title' => t('Instructions'), @@ -518,18 +557,6 @@ function _video_filter_form() { '#markup' => $text, ); - $form['cancel'] = array( - '#type' => 'button', - '#value' => t('Cancel'), - '#weight' => 98, - ); - - $form['insert'] = array( - '#type' => 'button', - '#value' => t('Insert'), - '#weight' => 99, - ); - return $form; } @@ -591,7 +618,10 @@ function _video_filter_add_settings($editor) { // Add popup url. $settings = array( - 'video_filter' => array('url' => array($editor => url('video_filter/dashboard/' . $editor))), + 'video_filter' => array( + 'url' => array($editor => url('video_filter/dashboard/' . $editor)), + 'instructions_url' => url('video_filter/instructions'), + ), ); drupal_add_js($settings, 'setting'); }