Commit 24580912 authored by nsuit's avatar nsuit

Added word count for ecomma_node_form. User data is now including count of...

Added word count for ecomma_node_form. User data is now including count of child comments. Fixed tag_details display: doesn't disappear anymore when clicking on the panel tabs.
parent 989f20ee
......@@ -36,8 +36,10 @@ Instructions below are based on navigation in admin menu (admin_menu module).
13. Community_tags: Enable "tag content" for authenticated and anonymous users.
(Enables unauthenticated users to see the tags, but not to tag.)
14. Community_tags: Enable "edit own tags" for authenticated.
15. Comment: Enable “view comments" for anonymous and authenticated users.
(Enables unauthenticated users to see the comments, but not to comment.)
15. Comment:
-Enable “View comments" for anonymous and authenticated users.
(Enables unauthenticated users to see the comments, but not to comment.)
-Enable "Administer comments and comment settings" for authenticated users.
16. Structure > Pages:
-Enable node_view and click on edit.
-Selection rules > select "Node:type" and then check new content type
......
......@@ -35,8 +35,6 @@ ol li {
}
div.ecomma_line {
/*display: inline;
padding: 1px 0px;*/
display: block;
position: relative;
height: 100% !important;
......@@ -47,7 +45,7 @@ div.ecomma_line {
}
.rtl_dir div.ecomma_line {
left: 0px;
left: -23px;
}
.ec-comment-info {
......@@ -1295,6 +1293,7 @@ ol.ec-tag-list {
max-height: 180px;
overflow-y: scroll;
list-style: none;
padding-left: 20px;
}
ol.ec-item-list {
......@@ -1304,6 +1303,7 @@ ol.ec-item-list {
ol.ec-tag-list li {
padding: 8px 12px;
border-top: 1px solid #cbcbb7;
margin-left: 0px;
}
ol.ec-tag-list li a,
......@@ -1599,9 +1599,6 @@ span.punctuation {
}
.line_number {
/*padding: 0px 2px 0px 0px;
float: left;
*/
position: absolute;
padding-right: 2px;
margin-right: 12px;
......@@ -1611,6 +1608,16 @@ span.punctuation {
left: -30px
}
.rtl_dir .line_number {
padding-left: 4px;
margin-left: 12px;
border-left: 1px #666 solid;
border-right: 0px;
width: 20px;
right: -45px;
text-align: left;
}
div.pane-node-field-annotation-text div:last-of-type span.line_number{ display: none; }
div.ui-dialog.ui-widget.ui-widget-content.ui-corner-all.ui-draggable {
......
@charset "UTF-8";
/* CSS Document */
#word_count_message .label,
#word_count_wrapper .label,
#text_input_note .label{
font-weight: bold
}
#word_count_wrapper{
margin-top: 20px;
font-size: 16px;
}
#word_count_wrapper.overlimit,
#word_count_overlimit{
color: #F70000;
}
#text_input_note{
margin-top: 20px;
}
#edit-actions.overlimit{
display: none;
}
#word_count_overlimit{
display: none;
}
......@@ -91,15 +91,13 @@ function ecomma_schema() {
'description' => 'Machine name of a content type that contains a text field which is ecomma enabled.',
),
'ecomma_enabled' => array(
'description' => 'MY TIMESTAMP',
'type' => 'int',
'not null' => TRUE,
'description' => 'Indicates if the text field of a specific content type is ecomma enabled or not.',
),
),
);
$schema['ecomma_node_text_direction'] = array(
'fields' => array(
......
......@@ -406,9 +406,9 @@ function ecomma_form_comment_form_alter(&$form, &$form_state, $form_id) {
function ecomma_form_alter(&$form, &$form_state, $form_id) {
global $base_url;
global $user;
$user_role = "user";
if (arg(0) == 'node' && ctype_digit(arg(1)) && !array_key_exists(2, arg()) || arg(0) == 'ecomma_user_data') {
$user_role = "user";
$node = node_load(arg(1));
$ecomma_enabled = ecomma_enabled_variable_by_content_type($node, $node->nid);
......@@ -443,6 +443,7 @@ function ecomma_form_alter(&$form, &$form_state, $form_id) {
$form['#attached']['library'][] = array('system', 'ui.droppable');
$form['#attached']['library'][] = array('system', 'ui.sortable');
}
}
elseif (arg(2) == 'types' && arg(5) == 'fields' && array_key_exists(6, arg()) && array_key_exists('instance', $form)) {
$ecomma_enabled = ecomma_enabled_variable_by_field_name($form['instance']['field_name']['#value']);
......@@ -482,6 +483,8 @@ function ecomma_form_alter(&$form, &$form_state, $form_id) {
case 'community_tags_form':
$form['tags']['#title'] = 'Delete your tags';
unset($form['tags']['#autocomplete_path']);
if ($user->uid == 0) {
$form['new']['#type'] = 'markup';
$redirect = drupal_get_destination();
......@@ -519,7 +522,33 @@ function ecomma_form_alter(&$form, &$form_state, $form_id) {
'#title' => t('Enable right-to-left text direction'),
'#default_value' => $text_direction,
'#description' => t('For languages such as Hebrew and Arabic.'));
$form['some_text'] = array(
'#markup' => '<div id="word_count_message"><span class="label">Recommended length:</span> 200 words (faster page loading)<br /><span class="label">Max length:</span> 500 words</div><div id="word_count_wrapper"><span class="label">Word Count: </span><span id="word_count"></span></div><div id="word_count_overlimit">The text saving option is disabled until you lower the word count (max: 500).</div><div id="text_input_note"><span class="label"></span>Place each paragraph into a separate textarea. Avoid line breaks and empty lines inside textareas, unless you want to display a line number at the beginning of a line.</div>'
);
$form['#attached']['js'][] = array(
'data' => drupal_get_path('module', 'ecomma') . '/js/ecomma_node_form.js',
'type' => 'file',
);
$form['#attached']['js'][] = array(
'data' => array(
'ecomma' => array(
'base_url_var' => $base_url,
'user_role' => $user_role,
'ecommaToken' => drupal_get_token(),
)),
'type' => 'setting',
);
$form['#attached']['css'] = array(
drupal_get_path('module', 'ecomma') . '/css/ecomma_node_form.css' => array(
'type' => 'file',
),
);
break;
case 'node_delete_confirm';
......@@ -558,8 +587,8 @@ function ecomma_customize_comment_form(&$form) {
/**
* Implements hook_comment_submit().
*
* When comment is submitted to insert a new database record in ecomma_range
* database table.
* Comment is submitted to insert a new database record in ecomma_range
* database table. But no record is entered if comment is edited.
*/
function ecomma_comment_submit($form, &$form_state) {
......@@ -584,7 +613,7 @@ function ecomma_comment_submit($form, &$form_state) {
$pid = $form_state['comment']->pid;
if (isset($cid) && $pid == 0) {
if (isset($cid) && isset($beg) && isset($end) && $pid == 0) {
if(!preg_match('/([^\.]*)\.(.*)/', $form_state['comment']->thread)){
db_insert('ecomma_range')
->fields(array(
......@@ -600,24 +629,26 @@ function ecomma_comment_submit($form, &$form_state) {
))->execute();
}
else {
$range = db_select('ecomma_range', 'e')
->fields('e', array('beg', 'end'))
->condition('e.cid', $pid)
->execute()
->fetchAssoc();
if (isset($beg) && isset($end)){
$range = db_select('ecomma_range', 'e')
->fields('e', array('beg', 'end'))
->condition('e.cid', $pid)
->execute()
->fetchAssoc();
db_insert('ecomma_range')
->fields(array(
'rid' => NULL,
'nid' => $nid,
'vid' => $vid,
'uid' => $uid,
'tid' => $tid,
'cid' => $cid,
'beg' => $range['beg'],
'end' => $range['end'],
'created' => $timestamp,
))->execute();
db_insert('ecomma_range')
->fields(array(
'rid' => NULL,
'nid' => $nid,
'vid' => $vid,
'uid' => $uid,
'tid' => $tid,
'cid' => $cid,
'beg' => $range['beg'],
'end' => $range['end'],
'created' => $timestamp,
))->execute();
}
}
}
}
......@@ -869,15 +900,31 @@ function ecomma_block_view($delta = '') {
$user_data_table = "";
$view_name = 'ecomma_user_data';
$view = views_get_view($view_name);
$view->set_arguments(array(arg(1), "all"));
$view->execute_display('default');
if ($view->result) {
$view_name2 = 'ecomma_user_child_comments';
$view2 = views_get_view($view_name2);
if($view && $view2){
$view->set_arguments(array(arg(1), "all"));
$view->execute_display('default');
$view2->set_arguments(array(arg(1), "all"));
$view2->execute_display('default');
}
$uid_key = 0;
if ($view->result && $view2->result) {
foreach ($view->result as $user_data) {
$uids[] = $user_data->ecomma_range_uid;
$uids[$uid_key] = $user_data->ecomma_range_uid;
$uid_key++;
}
foreach ($view2->result as $user_data2){
$uids[$uid_key] = $user_data2->comment_uid;
$uid_key++;
}
$uids_totals = array_count_values($uids);
$user_data_table = '<ol class="ec-user-list">';
foreach ($uids_totals as $uid_key => $uid_total) {
$current_user = user_load($uid_key);
$user_data_table .= '<li class="ec-user-admin">';
......@@ -886,7 +933,7 @@ function ecomma_block_view($delta = '') {
$user_data_table .= '<span>' . $uid_total . ' annotations</span></li>';
}
$user_data_table .= '</ol>';
}
}
$block['subject'] = t('eComma User Annotation Total');
$block['content'] = $user_data_table;
......@@ -1106,7 +1153,6 @@ function ecomma_display_username() {
}
/**
* Implements hook_query_alter().
*/
......@@ -1190,6 +1236,7 @@ function ecomma_enabled_variable_by_field_name($fieldname) {
}
}
/**
* Get the shared static $text_direction variable.
*
......
......@@ -177,5 +177,13 @@ function ecomma_views_data() {
),
);
$data['comment']['list_comments'] = array(
'title' => t('List of comments'),
'help' => t("Display the node's list of comments."),
'field' => array(
'handler' => 'ecomma_handler_field_list_comments',
),
);
return $data;
}
......@@ -118,7 +118,7 @@ li.tags a {
}
li.comments a p {
color: #69f;
color: #0065A8;
}
li.annotation_count a p {
......@@ -226,6 +226,7 @@ li.annotation_count a p {
padding: 0.2em 0 0.2em 0.2em;
width: 3.5em;
}
#tabs-icons .ui-tabs-nav li {
right: 4px;
border-right: none;
......@@ -235,9 +236,15 @@ li.annotation_count a p {
-webkit-border-radius: 4px 0px 0px 4px;
overflow: hidden;
}
#tabs-icons .ui-tabs-nav li:hover {
background: #666666;
}
#tabs-icons .ui-tabs-nav li.ui-tabs-selected {
border-right: 1px solid transparent;
}
#tabs-icons .ui-tabs-nav li a {
width: 23px;
}
......
......@@ -6,7 +6,7 @@
$view = new view();
$view->name = 'ecomma_comments_export';
$view->description = 'ecomma_comments_export';
$view->description = 'Export ecomma comments to xml.';
$view->tag = 'ecomma_comments_export';
$view->base_table = 'node';
$view->human_name = '';
......
<?php
/**
* @file
* This file provides the view to query and display child comments.
*/
$view = new view();
$view->name = 'ecomma_user_child_comments';
$view->description = 'Display child comments.';
$view->tag = 'ecomma_user_child_comments';
$view->base_table = 'comment';
$view->human_name = 'ecomma_user_child_comments';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'access comments';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '0';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['pager']['options']['quantity'] = '9';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Relationship: Comment: Content */
$handler->display->display_options['relationships']['nid']['id'] = 'nid';
$handler->display->display_options['relationships']['nid']['table'] = 'comment';
$handler->display->display_options['relationships']['nid']['field'] = 'nid';
$handler->display->display_options['relationships']['nid']['required'] = TRUE;
/* Relationship: Comment: Parent comment */
$handler->display->display_options['relationships']['pid']['id'] = 'pid';
$handler->display->display_options['relationships']['pid']['table'] = 'comment';
$handler->display->display_options['relationships']['pid']['field'] = 'pid';
/* Field: Comment: Rendered Comment */
$handler->display->display_options['fields']['rendered_entity']['id'] = 'rendered_entity';
$handler->display->display_options['fields']['rendered_entity']['table'] = 'views_entity_comment';
$handler->display->display_options['fields']['rendered_entity']['field'] = 'rendered_entity';
$handler->display->display_options['fields']['rendered_entity']['link_to_entity'] = 1;
$handler->display->display_options['fields']['rendered_entity']['view_mode'] = 'full';
$handler->display->display_options['fields']['rendered_entity']['bypass_access'] = 0;
/* Field: Comment: Author uid */
$handler->display->display_options['fields']['uid_1']['id'] = 'uid_1';
$handler->display->display_options['fields']['uid_1']['table'] = 'comment';
$handler->display->display_options['fields']['uid_1']['field'] = 'uid';
/* Field: Comment: ID */
$handler->display->display_options['fields']['cid']['id'] = 'cid';
$handler->display->display_options['fields']['cid']['table'] = 'comment';
$handler->display->display_options['fields']['cid']['field'] = 'cid';
/* Field: Comment: Post date */
$handler->display->display_options['fields']['created']['id'] = 'created';
$handler->display->display_options['fields']['created']['table'] = 'comment';
$handler->display->display_options['fields']['created']['field'] = 'created';
$handler->display->display_options['fields']['created']['date_format'] = 'long';
$handler->display->display_options['fields']['created']['second_date_format'] = 'long';
/* Field: Comment: Title */
$handler->display->display_options['fields']['subject']['id'] = 'subject';
$handler->display->display_options['fields']['subject']['table'] = 'comment';
$handler->display->display_options['fields']['subject']['field'] = 'subject';
/* Sort criterion: Comment: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'comment';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Contextual filter: Content: Nid */
$handler->display->display_options['arguments']['nid']['id'] = 'nid';
$handler->display->display_options['arguments']['nid']['table'] = 'node';
$handler->display->display_options['arguments']['nid']['field'] = 'nid';
$handler->display->display_options['arguments']['nid']['relationship'] = 'nid';
$handler->display->display_options['arguments']['nid']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25';
/* Contextual filter: Comment: Author uid */
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'comment';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['default_action'] = 'empty';
$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['uid']['break_phrase'] = TRUE;
/* Filter criterion: Comment: Approved */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'comment';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status_node']['id'] = 'status_node';
$handler->display->display_options['filters']['status_node']['table'] = 'node';
$handler->display->display_options['filters']['status_node']['field'] = 'status';
$handler->display->display_options['filters']['status_node']['relationship'] = 'nid';
$handler->display->display_options['filters']['status_node']['value'] = 1;
$handler->display->display_options['filters']['status_node']['group'] = 1;
$handler->display->display_options['filters']['status_node']['expose']['operator'] = FALSE;
/* Filter criterion: Comment: Nid */
$handler->display->display_options['filters']['nid']['id'] = 'nid';
$handler->display->display_options['filters']['nid']['table'] = 'comment';
$handler->display->display_options['filters']['nid']['field'] = 'nid';
$handler->display->display_options['filters']['nid']['relationship'] = 'pid';
$handler->display->display_options['filters']['nid']['operator'] = 'not empty';
......@@ -6,11 +6,11 @@
$view = new view();
$view->name = 'ecomma_user_data';
$view->description = 'ecomma_user_data';
$view->description = 'Display eComma annotation data for a user.';
$view->tag = 'ecomma_user_data';
$view->base_table = 'ecomma_range';
$view->human_name = '';
$view->core = 0;
$view->human_name = 'ecomma_user_data';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
......
......@@ -42,6 +42,10 @@ var comment_list = Array();
var isTouchSupported = "ontouchend" in document;
var myDown = "touchstart mousedown";
var myUp = "touchend mouseup";
var myDown = "touchstart mousedown keydown";
var myUp = "touchend mouseup keyup";
var selectionEndTimeout;
var word_count = 0;
base_path = Drupal.settings.basePath;
user_role = settings.ecomma.user_role;
......@@ -65,6 +69,7 @@ var comment_list = Array();
}
});
$(".ecomma_line", context).each(function(t){
$(this, context).prepend('<span class ="line_number"><span class ="line_number_symbol" style ="display:none">#---ecomma_line_symbol</span>' + Drupal.t('@line_number', {'@line_number': (t + 1)}) + '</span>');
});
......@@ -191,7 +196,7 @@ var comment_list = Array();
$('.comment-form', context).append('<div id ="comment_thread" />');
$('.floating-box .ecomma_tabs', context).append('<li class ="active"><a href ="#community-tags-form">' + Drupal.t('Add Tag') + '</a></li><li><a href =".comment-form">' + Drupal.t('Add Comment') + '</a></li>');
$('.floating-box #selection', context).append('<h3>' + Drupal.t('Your selection') + '</h3>');
$('.floating-box #selection', context).append('<div class ="ec-warning">' + Drupal.t('eComma couldn\'t understand your selection.<br /><b>Please try again.</b>') + '</div>');
$('.floating-box #selection', context).append('<div class ="ec-warning">' + Drupal.t('eComma couldn\'t understand your selection. A selection should not start or end with a space.<br /><br /><b>Please try again.</b>') + '</div>');
$('.floating-box #selection', context).append('<p id ="ec-selection-text" class ="ec-selection-text"></p>');
$('.floating-box #community-tags-form', context).append('<input name ="tag-range-beg" id ="tag-range-beg" type ="hidden" value ="' + beg_id + '">');
$('.floating-box #community-tags-form', context).append('<input name ="tag-range-end" id ="tag-range-end" type ="hidden" value ="' + end_id + '">');
......@@ -260,14 +265,22 @@ var comment_list = Array();
$('.original-community-tags-form .cloud a', context).each(function(i){
var someObj = new Object();
someObj = $(this);
var tag = $(this, context).text();
var tag = decodeEntities($(this, context).text());
//hide all tags
someObj.addClass("not-ec");
//hide non-eComma tags in delete tags section
$('ul.inline-tags li', context).each(function(k){
if($(this, context).text() == someObj.text()){
if(decodeEntities($(this, context).text()) != someObj.text()){
$(this, context).addClass("not-ec");
}
});
$.post(base_path + "tag_query/" + escape(tag) + "/" + nid, someObj, function(data) {
//check if tags are eComma tags and then make them visible
$.post(base_path + "tag_query/" + decodeEntities(tag) + "/" + nid, someObj, function(data) {
if(data){
for(var k in data){
if(data[k].tid != undefined) {
......@@ -275,9 +288,10 @@ var comment_list = Array();
someObj.attr('href', 'javascript:;');
someObj.attr("id","ec-t" + data[k].tid);
someObj.attr("rel","tag");
someObj.text(decodeEntities(someObj.text()));
someObj.removeClass("not-ec").addClass("ec-tagged");
$('ul.inline-tags li', context).each(function(k){
if($(this, context).text() == someObj.text()){
if(decodeEntities($(this, context).text()) == someObj.text()){
$(this, context).removeClass("not-ec");
}
});
......@@ -414,17 +428,6 @@ var comment_list = Array();
var rects = sel.getRangeAt(0).getClientRects();
var n = rects.length - 1;
// display end marker based on direction of selection
if( (match_result_flag == "pane-node-field-annotation-text" && activeEl.tagName.toLowerCase() == "body") || parentElClass =="column" || parentElClass =="cloud" || parentElClass =="pane-title" || parentElClass =="indented" || parentElClass =="submitted" || parentElClass =="undefined" || parentElClass =="word_cloud" && (activeEl.title != "word cloud" || activeEl.title != "tag cloud" || activeEl.title != "list of users with annotation count" || activeEl.title != "comment thread")){
if(backwards){
//console.log("backwards");
$('.ec-warning-outside-box', context).dialog('open');
}else{
//console.log("forward");
$('.ec-warning-outside-box', context).dialog('open');
}
}
}
});
......@@ -434,8 +437,9 @@ var comment_list = Array();
// Function triggers annotation dialog on text selection
$(".ecomma_line", context).bind(myUp, function(e){
e.preventDefault();
$('.ec-warning-outside-box', context).dialog('close');
$('.ec-warning-outside-box', context).dialog('close');
selectionEndTimeout = null;
$(".line_number_symbol", context).css("display","block");
var text = "";
var sel = null;
......@@ -613,12 +617,12 @@ var comment_list = Array();
$(".floating-box", context).dialog('open');
if (ie){
$('#ec-selection-text', context).text(Drupal.t('@sel_text', {'@sel_text': sel.text}));
$('#ec-selection-text', context).text(decodeEntities(Drupal.t('@sel_text', {'@sel_text': sel.text})));
}else{
$('#ec-selection-text', context).text(Drupal.t('@text', {'@text': text}));
$('#ec-selection-text', context).text(decodeEntities(Drupal.t('@text', {'@text': text})));
}
$('#ec-selection-text', context).text(Drupal.t('@text', {'@text': text}));
$('#ec-selection-text', context).text(decodeEntities(Drupal.t('@text', {'@text': text})));
$('.floating-box #community-tags-form', context).show();
$(".floating-box", context).dialog('open');
if(!$('.floating-box .form-item-tags', context).is(":visible")){
......@@ -671,18 +675,16 @@ var comment_list = Array();
// Submitting tag input by clicking on Add button through Ajax call.
$(".floating-box #community-tags-form .form-button", context).click(function() {
var selection = $("#ec-selection-text", context).html().replace(/\s\s+/g," ").replace(/(\n|\r)/g," ").replace(/<br \/>/g," ").replace(/<br>/g," ").replace(/<\/?[^>]+>/gi, '');