Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/form/Form.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ function getAllStyles($params) {
// Get layout information (number of columns)
if ($layout = $params['layout']) {
$layout = $params['layout'];
$class .= ' ' . $this->getStyleInfoByIdentifier('layout', $float);
$class .= ' ' . $this->getStyleInfoByIdentifier('layout', $layout);
}

return $class;
Expand Down
2 changes: 1 addition & 1 deletion classes/group/GroupDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function getLocaleFieldNames() {
* @return PKPGroup
*/
function newDataObject() {
return new PKPGroup();
return new Group();
}

/**
Expand Down
170 changes: 170 additions & 0 deletions js/controllers/ExtrasOnDemandHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/**
* @file js/controllers/ExtrasOnDemandHandler.js
*
* Copyright (c) 2000-2011 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class ExtrasOnDemandHandler
* @ingroup js_controllers
*
* @brief A basic handler for extras on demand UI pattern.
*/
(function($) {


/**
* @constructor
*
* @extends $.pkp.classes.Handler
*
* @param {jQuery} $widgetWrapper An HTML element that contains the widget.
* @param {Object} options Handler options.
*/
$.pkp.controllers.ExtrasOnDemandHandler = function($widgetWrapper, options) {
this.parent($widgetWrapper, options);

// Attach click event.
$('.toggleExtras', $widgetWrapper).click(this.callbackWrapper(this.toggleExtras));

// Hide extras (default initial widget state).
this.deactivateExtraContent_();
};
$.pkp.classes.Helper.inherits(
$.pkp.controllers.ExtrasOnDemandHandler, $.pkp.classes.Handler);


//
// Public methods
//
/**
* Event handler that is called when toggle extras div is clicked.
*
* @param {HTMLElement} toggleExtras The div that is clicked to toggle extras.
*/
$.pkp.controllers.ExtrasOnDemandHandler.prototype.toggleExtras =
function(toggleExtras) {

$widgetWrapper = this.getHtmlElement();

if ($(toggleExtras, $widgetWrapper).hasClass('active')) {
this.deactivateExtraContent_('slow');
} else {
this.activateExtraContent_('slow');
}
};


//
// Private methods
//
/**
* Activate extra content.
* @optional
* @param {String} opt_duration The effect duration.
*/
$.pkp.controllers.ExtrasOnDemandHandler.prototype.activateExtraContent_ =
function(opt_duration) {

var $widgetWrapper = this.getHtmlElement();

// Hide the inactive version of the toggle extras span.
$('.toggleExtras .toggleExtras-inactive', $widgetWrapper).hide();

// Show the active version of the toggle extras span and the extras container.
$('.extrasContainer', $widgetWrapper).show(opt_duration);
$('.toggleExtras .toggleExtras-active', $widgetWrapper).show();

// Adapt styling of the toggle extras div.
$('.toggleExtras', $widgetWrapper).removeClass('inactive').addClass('active');

// Change the toggle icon into a triangle pointing downwards.
$('.ui-icon', $widgetWrapper).removeClass('ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s');

// Identify if there is a scrollable parent.
var $scrollable = $widgetWrapper.closest('.scrollable');
if ($scrollable.size() > 0) {

// Scroll the parent so that all extra content in extras container is visible.
if ($.browser.msie && parseInt($.browser.version.substring(0,1), 10) <= 7) {

// IE7 is old and slow and returns before repainting everything,
// so wait half a second for the page to repaint before going on.
setTimeout(function(){this.scrollToMakeVisible_($widgetWrapper, $scrollable);}, 500);
} else {

// Other browsers can proceed immediately.
this.scrollToMakeVisible_($widgetWrapper, $scrollable);
}
}
};

/**
* Deactivate extra content.
* @optional
* @param {String} opt_duration The effect duration.
*/
$.pkp.controllers.ExtrasOnDemandHandler.prototype.deactivateExtraContent_ =
function(opt_duration) {

var $widgetWrapper = this.getHtmlElement();

// Hide the active version of the toggle extras span and the extras container.
$('.extrasContainer', $widgetWrapper).hide(opt_duration);
$('.toggleExtras .toggleExtras-active', $widgetWrapper).hide();

// Show the inactive version of the toggle extras span.
$('.toggleExtras .toggleExtras-inactive', $widgetWrapper).show();

// Adapt styling of the toggle extras div.
$('.toggleExtras', $widgetWrapper).removeClass('active').addClass('inactive');

// Change the toggle icon into a triangle pointing to the right.
$('.ui-icon', $widgetWrapper).removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e');
};

/**
* Scroll a scrollable element to make the
* given content element visible. The content element
* must be a descendant of a scrollable
* element (needs to have class "scrollable").
*
* NB: This method depends on the position() method
* to refer to the same parent element for both the
* content element and the scrollable element.
*
* @param {JQuery} $widgetWrapper The element to be made visible.
* @param {JQuery} $scrollable The parent scrollable element.
*/
$.pkp.controllers.ExtrasOnDemandHandler.prototype.scrollToMakeVisible_ =
function($widgetWrapper, $scrollable) {

var extrasWidgetTop = $widgetWrapper.position().top;
var scrollingWidgetTop = $scrollable.position().top;
var currentScrollingTop = $scrollable.scrollTop();

// Do we have to scroll down or scroll up?
if (extrasWidgetTop > scrollingWidgetTop) {
// Consider scrolling down...

// Calculate the number of hidden pixels of the child
// element within the scrollable element.
var hiddenPixels = Math.ceil(extrasWidgetTop + $widgetWrapper.height() - $scrollable.height());

// Scroll down if parts or all of this widget are hidden.
if (hiddenPixels > 0) {
$scrollable.scrollTop(currentScrollingTop + hiddenPixels);
}
} else {
// Scroll up...

// Calculate the new scrolling top.
var newScrollingTop = Math.max(Math.floor(currentScrollingTop + extrasWidgetTop - scrollingWidgetTop), 0);

// Set the new scrolling top.
$scrollable.scrollTop(newScrollingTop);
}
};


/** @param {jQuery} $ jQuery closure. */
}(jQuery));
26 changes: 26 additions & 0 deletions styles/controllers/extrasOnDemand.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @defgroup pkp_controllers_extrasOnDemand
*/

/**
* @file styles/controllers/extrasOnDemand.less
*
* Copyright (c) 2003-2011 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @ingroup pkp_controllers_extrasOnDemand
*
* @brief Styles for pkp_controllers_extrasOnDemand
*/

.pkp_controllers_extrasOnDemand {
.ui-icon {
float:left;
}
.toggleExtras {
margin-top:15px;
margin-bottom:15px;
cursor:pointer;
float:left;
}
}
28 changes: 28 additions & 0 deletions styles/controllers/form/flags.less
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,49 @@
@pkp_controllers_form_flag_mixin {
margin: 0;
background-repeat: no-repeat;
}

@pkp_controllers_form_input_flag_mixin {
background-position: 98% 50%;
}

@pkp_controllers_form_textArea_flag_mixin {
background-position: 98% 97%;
}

input.locale_en_US {
@pkp_controllers_form_flag_mixin;
@pkp_controllers_form_input_flag_mixin;
background-image: url(../lib/pkp/templates/images/structure/flags/en_US.png) !important;
}

input.locale_fr_CA {
@pkp_controllers_form_flag_mixin;
@pkp_controllers_form_input_flag_mixin;
background-image: url(../lib/pkp/templates/images/structure/flags/fr_CA.png) !important;
}

input.locale_te_ST {
@pkp_controllers_form_flag_mixin;
@pkp_controllers_form_input_flag_mixin;
background-image: url(../lib/pkp/templates/images/structure/flags/te_ST.png) !important;
}

textarea.locale_en_US {
@pkp_controllers_form_flag_mixin;
@pkp_controllers_form_textArea_flag_mixin;
background-image: url(../lib/pkp/templates/images/structure/flags/en_US.png) !important;
}

textarea.locale_fr_CA {
@pkp_controllers_form_flag_mixin;
@pkp_controllers_form_textArea_flag_mixin;
background-image: url(../lib/pkp/templates/images/structure/flags/fr_CA.png) !important;
}

textarea.locale_te_ST {
@pkp_controllers_form_flag_mixin;
@pkp_controllers_form_textArea_flag_mixin;
background-image: url(../lib/pkp/templates/images/structure/flags/te_ST.png) !important;
}
}
26 changes: 26 additions & 0 deletions templates/controllers/extrasOnDemand.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{**
* controllers/extrasOnDemand.tpl
*
* Copyright (c) 2003-2011 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* Basic markup for extras on demand widget.
*}
<script type="text/javascript">
// Initialise JS handler.
$(function() {ldelim}
$('{$widgetWrapper}').pkpHandler(
'$.pkp.controllers.ExtrasOnDemandHandler');
{rdelim});
</script>
<div class="pkp_controllers_extrasOnDemand">
<div class="toggleExtras">
<span class="ui-icon"></span>
<span class="toggleExtras-inactive">{translate key=$moreDetailsText}</span>
<span class="toggleExtras-active">{translate key=$lessDetailsText}</span>
</div>
<div style="clear:both;"></div>
<div class="extrasContainer">
{$extraContent}
</div>
</div>
40 changes: 38 additions & 2 deletions templates/form/textarea.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,42 @@
* form text area
*}

<textarea name="{$FBV_name|escape}" id="{$FBV_id|escape}" {$FBV_textAreaParams} class="field textarea {$FBV_class} {if $FBV_sizeInfo}{$FBV_sizeInfo}{/if}{if $FBV_validation} {$FBV_validation|escape}{/if}{if $FBV_rich} richContent{/if}"{if $FBV_disabled} disabled="disabled"{/if}>{$FBV_value|escape}</textArea>
{if $FBV_multilingual}
{* This is a multilingual control. Enable popover display. *}
<span class="pkp_controllers_form_localization_container">
{strip}
<textarea {$FBV_textAreaParams}
class="field multilingual_primary textarea {$FBV_class} {if $FBV_sizeInfo}{$FBV_sizeInfo}{/if}{if $FBV_validation} {$FBV_validation|escape}{/if}{if $formLocale != $currentLocale} locale_{$formLocale|escape}{/if}{if $FBV_rich} richContent{/if}"
{if $FBV_disabled} disabled="disabled"{/if}
name="{$FBV_name|escape}[{$formLocale|escape}]"
id="{$FBV_id|escape}-{$formLocale|escape}">{$FBV_value[$formLocale]|escape}
</textarea>
{/strip}

{$FBV_label_content}
{$FBV_label_content}

<span>
<div class="pkp_controllers_form_localization_popover">
{foreach from=$formLocales key=thisFormLocale item=thisFormLocaleName}{if $formLocale != $thisFormLocale}
{strip}
<textarea {$FBV_textAreaParams}
placeholder="{$thisFormLocaleName|escape}"
class="field textarea multilingual_extra locale_{$thisFormLocale|escape} {$FBV_class} {if $FBV_sizeInfo}{$FBV_sizeInfo}{/if}{if $FBV_rich} richContent{/if}"
{if $FBV_disabled} disabled="disabled"{/if}
name="{$FBV_name|escape}[{$thisFormLocale|escape}]"
id="{$FBV_id|escape}-{$thisFormLocale|escape}">{$FBV_value[$thisFormLocale]|escape}
</textarea>
{/strip}
<label class="multilingual_extra_label" for="{$FBV_id|escape}-{$thisFormLocale|escape}" class="locale">({$thisFormLocaleName|escape})</label>
{/if}{/foreach}
</div>
</span>
</span>
{else}
{* This is not a multilingual control. *}
<textarea {$FBV_textAreaParams}
class="field textarea {$FBV_class} {if $FBV_sizeInfo}{$FBV_sizeInfo}{/if}{if $FBV_validation} {$FBV_validation|escape}{/if}{if $FBV_rich} richContent{/if}"
{if $FBV_disabled} disabled="disabled"{/if}
name="{$FBV_name|escape}"
id="{$FBV_id|escape}">{$FBV_value|escape}</textarea>
{/if}