<ol class="pollResultList">
{foreach from=$poll->getOptions(true) item=option}
<li class="pollResultItem">
- <span class="pollMeter" style="width: {if $option->getRelativeVotes($poll)}{@$option->getRelativeVotes($poll)}%{else}0{/if}"> </span>
- <div class="caption">
- <span class="optionName">{$option->optionValue} ({#$option->votes})</span>
- <span class="relativeVotes">{@$option->getRelativeVotes($poll)}%</span>
+ <div class="pollResultItemCaption">
+ <span class="pollOptionName">{$option->optionValue} ({#$option->votes})</span>
+ <span class="pollOptionRelativeValue">{@$option->getRelativeVotes($poll)}%</span>
+ </div>
+ <div class="pollMeter">
+ <div class="pollMeterValue" style="width: {if $option->getRelativeVotes($poll)}{@$option->getRelativeVotes($poll)}%{else}0{/if}"></div>
</div>
</li>
{/foreach}
/**
* number of options
- * @var integer
+ * @var int
*/
_count: 0,
- /**
- * width for input-elements
- * @var integer
- */
- _inputSize: 0,
-
/**
* maximum allowed number of options
- * @var integer
+ * @var int
*/
_maxOptions: 0,
this._createOptionList(optionList);
// bind event listener
- $(window).resize($.proxy(this._resize, this));
this._container.parents('form').submit($.proxy(this._submit, this));
// init sorting
- new WCF.Sortable.List(containerID, '', undefined, undefined, true);
-
- // trigger resize event for field length calculation
- this._resize();
-
- // update size on tab select
- var self = this;
- this._container.closest('.messageTabMenu').on('messagetabmenushow', function(event, data) {
- if (data.activeTab.name == 'poll') {
- self._resize();
- }
- });
+ new WCF.Sortable.List(containerID, '', undefined, {
+ toleranceElement: '> div'
+ }, true);
},
/**
}
// insert buttons
- var $buttonContainer = $('<span class="sortableButtonContainer" />').appendTo($listItem);
- $('<span class="icon icon16 fa-plus jsTooltip jsAddOption pointer" title="' + WCF.Language.get('wcf.poll.button.addOption') + '" />').click($.proxy(this._addOption, this)).appendTo($buttonContainer);
- $('<span class="icon icon16 fa-times jsTooltip jsDeleteOption pointer" title="' + WCF.Language.get('wcf.poll.button.removeOption') + '" />').click($.proxy(this._removeOption, this)).appendTo($buttonContainer);
+ var $container = $('<div class="pollOptionInput" />').appendTo($listItem);
+ $('<span class="icon icon16 fa-plus jsTooltip jsAddOption pointer" title="' + WCF.Language.get('wcf.poll.button.addOption') + '" />').click($.proxy(this._addOption, this)).appendTo($container);
+ $('<span class="icon icon16 fa-times jsTooltip jsDeleteOption pointer" title="' + WCF.Language.get('wcf.poll.button.removeOption') + '" />').click($.proxy(this._removeOption, this)).appendTo($container);
// insert input field
- var $input = $('<input type="text" value="' + optionValue + '" maxlength="255" />').css({ width: this._inputSize + "px" }).keydown($.proxy(this._keyDown, this)).appendTo($listItem);
+ var $input = $('<input type="text" value="' + optionValue + '" maxlength="255" />').keydown($.proxy(this._keyDown, this)).appendTo($container);
$input.click(function() {
// work-around for some weird focus issue on iOS/Android
if (document.activeElement !== this) {
}
},
- /**
- * Handles the 'resize'-event to adjust input-width.
- */
- _resize: function() {
- var $containerWidth = this._container.innerWidth();
-
- // select first option to determine dimensions
- var $listItem = this._container.children('li:eq(0)');
- var $buttonWidth = $listItem.children('.sortableButtonContainer').outerWidth();
- var $inputSize = $containerWidth - $buttonWidth;
-
- if ($inputSize != this._inputSize) {
- this._inputSize = $inputSize;
-
- // update width of <input /> elements
- this._container.find('li > input').css({ width: this._inputSize + 'px' });
- }
- },
-
/**
* Inserts hidden input elements storing the option values.
*/
var $options = [ ];
this._container.children('li').each(function(index, listItem) {
var $listItem = $(listItem);
- var $optionValue = $.trim($listItem.children('input').val());
+ var $optionValue = $.trim($listItem.find('input').val());
// ignore empty values
if ($optionValue != '') {
--- /dev/null
+/* poll create/edit form */
+#pollOptionContainer .pollOptionInput {
+ align-items: center;
+ margin: 5px 0;
+
+ /* using `display: flex` inside a native list-item is pretty weird */
+ display: inline-flex;
+ width: 100%;
+
+ > .icon {
+ flex: 0 0 auto;
+ margin: 0 5px;
+ }
+
+ > input {
+ flex: 1 1 auto;
+ margin-left: 5px;
+ }
+}
+
+/* displayed poll */
+.pollContainer {
+ border: 1px solid $wcfContentBorder;
+ border-width: 1px 0;
+ float: left;
+ margin: 0 20px 10px 0;
+ max-width: 50%;
+ min-width: 300px;
+ padding: 10px 0;
+
+ h2 {
+ @include wcfFontHeadline;
+ }
+
+ .pollInnerContainer {
+ margin-top: 30px;
+
+ dd:not(:last-child) {
+ margin-bottom: 5px;
+ }
+ }
+
+ .formSubmit {
+ border-top: 1px solid $wcfContentBorderInner;
+ padding-top: 10px;
+ }
+
+ .pollResultItem {
+ & + .pollResultItem {
+ margin-top: 20px;
+ }
+
+ /* option name in result list */
+ .pollResultItemCaption {
+ align-items: flex-end;
+ display: flex;
+
+ > .pollOptionName {
+ flex: 1 1 auto;
+ }
+
+ > .pollOptionRelativeValue {
+ color: rgb(125, 130, 135);
+ flex: 0 0 50px;
+ text-align: right;
+ }
+ }
+
+ /* visual representation of relative votes per option */
+ .pollMeter {
+ background-color: $wcfContentBorderInner;
+ height: 5px;
+ margin-top: 5px;
+
+ > .pollMeterValue {
+ background-color: $wcfContentBorder;
+ height: 100%;
+ }
+ }
+ }
+}