Commit 848877d8 authored by Marco Villegas's avatar Marco Villegas
Browse files

Issue #1016804 by udvranto, ay13, marvil07: Added Thumbs up down widget based on vote up down.

This is the 7.x-1.x port
parent 6e2a6765
Loading
Loading
Loading
Loading
+2.14 KiB
Loading image diff...
+107 −0
Changes for widgets/thumbs/thumbs.css: 107 added lines, 0 removed lines.
Original line number Diff line number Diff line
.vud-widget-thumbs {
  margin: 5px 10px;
  position: relative;
  float: left;
}

.vud-widget-thumbs p {
  margin: 0;
}

.vud-widget-thumbs a.vud-link-up span,
.vud-widget-thumbs a.vud-link-down span {
  text-decoration: none;
  margin-right: 7px;
}

.vud-widget-thumbs .up-score .up-current-score,
.vud-widget-thumbs .down-score .down-current-score {
  display: block;
  font-size: 16px;
  margin-left: 25px;
  text-align: right;
  padding-top: 2px;
}

.vud-widget-thumbs .up-score {
  color: #333;
  display: inline-block;
  border-right: 1px solid #999999;
  padding: 0 3px 0 10px;
}
.vud-widget-thumbs .down-score {
  color: #333;
  display: inline-block;
  padding-left: 3px;
}

.vote-current-score {
  padding-top: 10px;
}

.voted-how {
  font-size: 0.8em
}

.vud-widget-thumbs .up-active,
.vud-widget-thumbs .down-active {
}

.vote-thumb {
  cursor: pointer;
}

.vud-widget-thumbs .up-inactive,
.vud-widget-thumbs .down-inactive,
.vud-widget-thumbs .up-active,
.vud-widget-thumbs .down-active {
  float: left;
  display: block;
  width: 27px;
  height: 28px;
  font-weight: bold;
  text-align: center;
  background: url(thumbs.png) 0 0 no-repeat;
}

.vud-widget-thumbs .up-active {
  background-position: -54px -0px;
}
.vud-widget-thumbs .down-active {
  background-position: -27px -0px;
}
.vud-widget-thumbs .up-inactive {
  background-position: -81px -0px;
}
.vud-widget-thumbs .down-inactive {
  background-position: -0px -0px;
}
.vud-widget-thumbs .up-inactive:hover {
  background-position: -54px -0px;
}
.vud-widget-thumbs .down-inactive:hover {
  background-position: -27px -0px;
}

.vud-widget-thumbs a.ctools-ajaxing,
.vud-widget-thumbs a.ctools-ajaxing:hover {
  padding-right: 0 !important;
  background-image: url(status-active.gif);
  background-position: center;
}

/**
 * Hide elements visually, but keep them available for screen-readers.
 *
 * Used for information required for screen-reader users to understand and use
 * the site where visual display is undesirable. Information provided in this
 * manner should be kept concise, to avoid unnecessary burden on the user. Must
 * not be used for focusable elements (such as links and form elements) as this
 * causes issues for keyboard only or voice recognition users. "!important" is
 * used to prevent unintentional overrides.
 */
.element-invisible {
  position: absolute !important;
  clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
  clip: rect(1px, 1px, 1px, 1px);
}
+27 −0
Changes for widgets/thumbs/thumbs.inc: 27 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php
/**
 * @file
 *   Thumbs widget.
 */

/**
 * Implementation of hook_vud_widgets(). (Specialized)
 */
function vud_thumbs_vud_widgets() {
  return array(
    'title' => t('Thumbs up and down'),
    'widget template' => 'widget',
    'alter template variables' => 'vud_widget_thumbs_alter_template_vars',
    'js' => 'thumbs.js',
  );
}

function vud_widget_thumbs_alter_template_vars($template_type, &$variables) {
  $criteria['entity_id'] = $variables['entity_id'];
  $criteria['entity_type'] = $variables['type'];
  $criteria['value_type'] = 'points';
  $criteria['tag'] = $variables['tag'];
  $criteria['function']  = 'sum';
  $vote_sum = votingapi_select_single_result_value($criteria);
  $variables['vote_sum'] = ($vote_sum) ? $vote_sum : 0;
}
+16 −0
Changes for widgets/thumbs/thumbs.js: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line

(function ($) {

Drupal.behaviors.vud_widget_thumbs = {
  attach: function (context) {
    if (!$('.vud-widget').hasClass('vud-widget-processed')) {
      $('.vote-thumb').click(function(){
        if($(this).hasClass('up-active') || $(this).hasClass('down-active')){
          $(this).parents('.vud-widget').find('.vud-link-reset').click();
        }
      });
    }
  }
};

})(jQuery);
+2.06 KiB
Loading image diff...
Loading