diff -urN original/video_filter/scripts/video_filter.js modified/video_filter/scripts/video_filter.js --- original/video_filter/scripts/video_filter.js 1970-01-01 01:00:00.000000000 +0100 +++ modified/video_filter/scripts/video_filter.js 2010-09-20 16:41:05.000000000 +0200 @@ -0,0 +1,41 @@ +// Add more textarea IDs that can parse Video Filter. +var textareaIDs = { + "edit-teaser-js": "", + "edit-body": "", + "edit-comment": "" +}; + +var textareaFocussed = "edit-body"; + +Drupal.behaviors.VideoFilterFocus = function() { + $("textarea").bind("focus", function() { + var textAreaID = $(this).attr("id"); + if (textAreaID in textareaIDs) { + textareaFocussed = textAreaID; + } + }); +} + +function addVideoFilter() { + var videotag = $(".video-filter-box #edit-input-box").val(); + + if (videotag != "") { + videotag = "[video:" + videotag + "]"; + $("textarea#"+ textareaFocussed +", textarea#edit-comment").each(function() { + // Plain textarea support + if (document.selection) { + this.focus(); + document.selection.createRange().text = videotag; + } + else if (this.selectionStart || this.selectionStart === 0) { + var cursorPos = this.selectionEnd + videotag.length; + this.value = this.value.substring(0, this.selectionStart) + videotag + this.value.substring(this.selectionEnd); + this.selectionStart = this.selectionEnd = cursorPos; + } + else { + this.value = this.value + videotag; + } + this.focus(); + }); + } +} diff -urN original/video_filter/video_filter.module modified/video_filter/video_filter.module --- original/video_filter/video_filter.module 2009-10-22 21:40:44.000000000 +0200 +++ modified/video_filter/video_filter.module 2010-09-20 16:31:10.000000000 +0200 @@ -198,6 +198,38 @@ ), ); + /* Video filter input box settings */ + $form['video_filter']['video_inputbox'] = array( + '#type' => 'fieldset', + '#title' => t('Video filter input box settings'), + ); + $form['video_filter']['video_inputbox']['video_filter_enable_for'] = array( + '#type' => 'markup', + '#value' => ''. t('Enable Video filter input box for:') .'', + ); + $form['video_filter']['video_inputbox']['video_filter_enable_for_nodes'] = array( + '#type' => 'checkbox', + '#title' => t('Nodes'), + '#default_value' => variable_get('video_filter_enable_for_nodes', 0), + ); + $form['video_filter']['video_inputbox']['video_filter_enable_for_comments'] = array( + '#type' => 'checkbox', + '#title' => t('Comments'), + '#default_value' => variable_get('video_filter_enable_for_comments', 0), + ); + $form['video_filter']['video_inputbox']['video_filter_node_types_content'] = array( + '#type' => 'checkboxes', + '#title' => t('On the following node types'), + '#description' => t('Select the node types you want to enable Video filter input box for.'), + '#default_value' => variable_get('video_filter_node_types_content', array()), + '#options' => node_get_types('names'), + ); + $form['video_filter']['video_inputbox']['video_filter_input_box_expanded'] = array( + '#type' => 'checkbox', + '#title' => t('Expand select box fieldset by default'), + '#default_value' => variable_get('video_filter_input_box_expanded', TRUE), + ); + return $form; } @@ -342,4 +374,64 @@ } $output .= ''; return $output; -} \ Nincs újsor a fájl végén +} + +/** + * Implementation of hook_form_alter(). + */ +function video_filter_form_alter(&$form, $form_state, $form_id) { + if ($form_id != 'comment_form' && !isset($form['#node'])) { + return; + } + + if ($form_id == 'comment_form') { + $node_type = db_result(db_query('SELECT type FROM {node} WHERE nid=%d', $form['nid']['#value'])); + } + else if (!empty($form['type']['#value'])) { + $node_type = $form['type']['#value']; + } + + if (in_array($node_type, variable_get('video_filter_node_types_content', array()), TRUE)) { + if ( ((isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) && + variable_get('video_filter_enable_for_nodes', 0) && + isset($form['body_field']) || + ('comment_form' == $form_id && variable_get('video_filter_enable_for_comments', 0)))) { + + $output = ''; + if (array_key_exists('body_field', $form)) { + $key = 'body_field'; + } + elseif (array_key_exists('comment_filter', $form)) { + $key = 'comment_filter'; + } +/* else { + $key = 'smileys_wrapper'; + } */ + + $collapsed = variable_get('video_filter_input_box_expanded', TRUE) ? FALSE : TRUE; + $form[$key]['video_filter'] = array( + '#type' => 'fieldset', + '#title' => t('Video'), + '#collapsible' => TRUE, + '#collapsed' => $collapsed, + '#weight' => 0, + '#prefix' => '
', + '#suffix' => '
', + ); + $form[$key]['video_filter']['input_box'] = array( + '#type' => 'textfield', + '#title' => t('Video URL'), +// '#value' => theme('smileys_select_table', TRUE), + ); + $form[$key]['video_filter']['add_button'] = array( + '#type' => 'button', + '#value' => t('Add Video'), + '#attributes' => array('onClick' => 'addVideoFilter(); return false;'), +// '#value' => theme('smileys_select_table', TRUE), + ); + drupal_add_js(drupal_get_path('module', 'video_filter') . '/scripts/video_filter.js'); + } + } + + return $form; +}