diff --git a/VERSIONS_DEV/community_slider_navigation_percent b/VERSIONS_DEV/community_slider_navigation_percent new file mode 100644 index 0000000000000000000000000000000000000000..eb33c2db6ceb442429444b94808a528962415502 --- /dev/null +++ b/VERSIONS_DEV/community_slider_navigation_percent @@ -0,0 +1 @@ + - Développement communautaire : ajout du paramètre % dans la configuration de taille du widget. \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Accueil/Base.php b/library/ZendAfi/View/Helper/Accueil/Base.php index d145397e3cee706ecdecedc4a6596e70b63e8863..bed44f14b14fe69bddd38f01c44b2d77c005e12b 100644 --- a/library/ZendAfi/View/Helper/Accueil/Base.php +++ b/library/ZendAfi/View/Helper/Accueil/Base.php @@ -375,6 +375,7 @@ class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstrac $options->width = $preferences['op_navigation_window_width']; $options->height= $preferences['op_navigation_window_height']; $options->strategy = $preferences['op_navigation_mode']; + $options->unit = isset($preferences['op_navigation_unit']) ? $preferences['op_navigation_unit'] : 'px'; $options->cycle = isset($preferences['op_navigation_cycle']) ? $preferences['op_navigation_cycle'] : 0 ; Class_ScriptLoader::getInstance() diff --git a/library/ZendAfi/View/Helper/Admin/ImageViewersOptions.php b/library/ZendAfi/View/Helper/Admin/ImageViewersOptions.php index 236f17c1680035f89f53529b00974d0583c04cd0..c2ae791a15994067ac5e92d3f1361abd9dbb82e6 100644 --- a/library/ZendAfi/View/Helper/Admin/ImageViewersOptions.php +++ b/library/ZendAfi/View/Helper/Admin/ImageViewersOptions.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -26,9 +26,9 @@ class ZendAfi_View_Helper_Admin_ImageViewersOptions extends ZendAfi_View_Helper_ const STYLE_TYPE_FLASH= 'flash'; - protected - $_preferences, - $_propertiesPath, + protected + $_preferences, + $_propertiesPath, $_valuesPath, $_styles = [self::STYLE_TYPE_JAVA => ['diaporama' => 'Diaporama', 'diaporama_navigation' => 'Diaporama avec navigation', @@ -41,13 +41,13 @@ class ZendAfi_View_Helper_Admin_ImageViewersOptions extends ZendAfi_View_Helper_ $this->_preferences = $preferences; $html = $this->_getComboStyles(); $this->_ensureOneStyle(); - $html.= (isset($preferences['style_liste']) + $html.= (isset($preferences['style_liste']) ? (new ZendAfi_View_Helper_Admin_PropertiesReader()) ->setView($this->view) ->propertiesReader($preferences['style_liste'], $preferences) : ''); - + return $html; } @@ -58,17 +58,17 @@ class ZendAfi_View_Helper_Admin_ImageViewersOptions extends ZendAfi_View_Helper_ . '<option value="none">Liste</option>' . $this->_getComboTypedStyles(self::STYLE_TYPE_JAVA, $this->translate()->_('Objets java-script')) - . $this->_getComboTypedStyles(self::STYLE_TYPE_FLASH, + . $this->_getComboTypedStyles(self::STYLE_TYPE_FLASH, $this->translate()->_('Objets flash')) . '</select>' . '<input type="hidden" id="styles_reload" name="styles_reload" value="0">'; } - /** + /** * @param string $styleKey * @param string $groupLabel - * @return string + * @return string */ protected function _getComboTypedStyles($styleKey, $groupLabel) { $html = ''; @@ -81,7 +81,7 @@ class ZendAfi_View_Helper_Admin_ImageViewersOptions extends ZendAfi_View_Helper_ $html .= '<optgroup label="' . $groupLabel . '" style="font-style:normal;color:#FF6600">'; foreach ($this->_styles[$styleKey] as $k => $v) { - $current = (array_key_exists('style_liste', $this->_preferences) + $current = (array_key_exists('style_liste', $this->_preferences) && $this->_preferences['style_liste'] == $k); $html .= '<option style="color:#666666" value="' . $k . '" ' . (($current) ? 'selected="selected"' : '') . '>' . $v . '</option>'; } diff --git a/public/opac/java/diaporama_navigation/defaults.ini b/public/opac/java/diaporama_navigation/defaults.ini index b1840be32dd2270c607cffde56d0dfc824593493..ca6e0dc6f16e10a54888a3b1a48fcd1064b96f7a 100644 --- a/public/opac/java/diaporama_navigation/defaults.ini +++ b/public/opac/java/diaporama_navigation/defaults.ini @@ -1,4 +1,5 @@ navigation_mode="buttons" navigation_window_width="350" navigation_window_height="250" +navigation_unit="px" navigation_cycle=0 \ No newline at end of file diff --git a/public/opac/java/diaporama_navigation/properties.phtml b/public/opac/java/diaporama_navigation/properties.phtml index ac59d570fe7f29f0fe9774dcd8835d740f01a565..398ef01aacf58d1fe3a06854905ba307e808a2b2 100644 --- a/public/opac/java/diaporama_navigation/properties.phtml +++ b/public/opac/java/diaporama_navigation/properties.phtml @@ -8,14 +8,24 @@ $form 'multiOptions' => ['buttons' => $this->_('Un bouton pour chaque élément'), 'next_previous' => $this->_('Boutons précédent et suivant'), 'preview' => $this->_('Une miniature pour chaque élément')]]) + +->addElement('select', + 'op_navigation_unit', + ['label' => $this->_('Unité utilisée pour la largeur du widget'), + 'value' => $this->preferences['op_navigation_unit'], + 'multiOptions' => ['px' => $this->_('Pixels'), + '%' => $this->_('Pourcentages')]]) + ->addElement('text', 'op_navigation_window_width', - ['label' => $this->_('Largeur du widget en pixels'), + ['label' => $this->_('Largeur du widget'), 'value' => $this->preferences['op_navigation_window_width']]) + ->addElement('text', 'op_navigation_window_height', ['label' => $this->_('Hauteur du widget en pixels'), 'value' => $this->preferences['op_navigation_window_height']]) + ->addElement('text', 'op_navigation_cycle', ['label' => $this->_('Délai de défilement en millisecondes'), diff --git a/public/opac/java/slider_navigation/slider_navigation.js b/public/opac/java/slider_navigation/slider_navigation.js index 613e2cec709d8daea13430c6f80e85685b31ac1e..fc5cf1748a58675d06a931efe63ae1c26f268a3d 100755 --- a/public/opac/java/slider_navigation/slider_navigation.js +++ b/public/opac/java/slider_navigation/slider_navigation.js @@ -30,8 +30,8 @@ return html; html = upgradeHtml(html); - html = setWindowAndArticleSize(html, 'width:' + options.width + 'px;height:' + options.height + 'px'); - html = placeArticlesWithPosition(html, 0, options.width); + html = setWindowAndArticleSize(html, options); + html = placeArticlesWithPosition(html, options); var strategy = getStrategy(options.strategy); html = strategy.generateButtons(html); @@ -71,27 +71,59 @@ } - function setWindowAndArticleSize(html, size) { - html.find('article').attr('style', size); + function setWindowAndArticleSize(html, properties) { + var article_size = properties.width + properties.unit; + var size = 'width:' + article_size + '; height:' + properties.height + 'px'; + html.find('div.window').attr('style', size); + html.find('article').attr('style', size); + + if(properties.unit == '%') { + article_size = (properties.width / html.find('article').length) + properties.unit; + html.find('article').css('width', article_size); + } + + html.find('div.news_row').attr('data-article-width', article_size); return html; } - function placeArticlesWithPosition(html, position, width) { - html.find('div.news_row').css('margin-left', position + 'px'); - html.find('div.news_row').width(html.find('article').length * width); + function placeArticlesWithPosition(html, properties) { + var nb_of_articles = html.find('article').length; + var news_row_width = (nb_of_articles * properties.width) + properties.unit; + html.find('div.news_row').css('margin-left', 0); + html.find('div.news_row').css('width', news_row_width); + html.find('div.news_row').attr('data-width', news_row_width); + html.find('div.news_row').attr('data-margin-inc', properties.width); + html.find('div.news_row').attr('data-position', 0); + html.find('div.news_row').attr('data-max-position', nb_of_articles - 1); return html; } }; - function initCssForHorizontalSlide(length) { - return {'margin-left': length+'px', + function initCssForHorizontalSlide(length, unit) { + return {'margin-left': length + unit, 'transition-property': 'all', 'transition-duration': '0.8s'}; } + + function slideToRight(html, position, properties) { + var margin_inc = html.find('div.news_row').data('margin-inc'); + html.find('div.news_row').attr('data-position', position+1); + html.find('div.news_row').css(initCssForHorizontalSlide((-1 * (margin_inc * (position+1))), properties.unit)); + return html; + } + + + function slideToLeft(html, position, properties) { + var margin_inc = html.find('div.news_row').data('margin-inc'); + html.find('div.news_row').attr('data-position', position-1); + html.find('div.news_row').css(initCssForHorizontalSlide((-1 * (margin_inc * (position-1))), properties.unit)); + return html; + } + function Strategy() { this.current_position = 0; @@ -118,7 +150,7 @@ html.find('div[data-article]').removeClass('selected'); $(this).addClass('selected'); my.current_position = $(this).data('article'); - html.find('div.news_row').css(initCssForHorizontalSlide(((-1) * ((my.current_position-1) * properties.width)))); + html.find('div.news_row').css(initCssForHorizontalSlide(((-1) * ((my.current_position-1) * properties.width)), properties.unit)); }); return html; } @@ -128,8 +160,6 @@ function Strategy_Next_Previous() { this.next = function(html) { - if(parseInt( html.find('div.news_row').css('margin-left')) == this.right_cleat) - return html.find('div.news_row').css(initCssForHorizontalSlide(this.left_cleat)); return html.find('div[data-event="next"]').trigger('click'); } @@ -141,28 +171,18 @@ }; this.implementsButtons = function(html, properties) { - var right_cleat = ((html.find('article').length * properties.width) - properties.width) * (-1); - this.right_cleat = right_cleat; - var left_cleat = 0; - this.left_cleat = left_cleat; + var max_position = html.find('div.news_row').data('max-position'); html.find('div[data-event="next"]').click(function() { - var old_margin = parseInt( html.find('div.news_row').css('margin-left')); - var length = (old_margin > right_cleat && (old_margin % properties.width == 0)) - ? old_margin - parseInt( properties.width ) - : right_cleat; - - html.find('div.news_row').css(initCssForHorizontalSlide(length)); + var current_position = parseInt(html.find('div.news_row').attr('data-position')); + if(current_position < max_position) + return slideToRight(html, current_position, properties); }); - html.find('div[data-event="previous"]').click(function() { - var old_margin = parseInt( html.find('div.news_row').css('margin-left')); - var length = (old_margin < left_cleat && (old_margin % properties.width == 0)) - ? old_margin + parseInt( properties.width ) - : 0; - - html.find('div.news_row').css(initCssForHorizontalSlide(length)); + var current_position = parseInt(html.find('div.news_row').attr('data-position')); + if(current_position > 0) + return slideToLeft(html, current_position, properties); }); return html; diff --git a/public/opac/java/slider_navigation/tests/agenda_slider_test.js b/public/opac/java/slider_navigation/tests/agenda_slider_test.js index dc075a3b807849c6491390009c2c65c901b3e960..dc6cbeeef1be6ef741df1d8ea7a24e803b09d51c 100644 --- a/public/opac/java/slider_navigation/tests/agenda_slider_test.js +++ b/public/opac/java/slider_navigation/tests/agenda_slider_test.js @@ -28,7 +28,7 @@ QUnit.module('slider_navigation', { +'<article>Bokeh la biquette</article>' +'</div>'); - fixture.slider_navigation({width:110, height:80, strategy:'next_previous', cycle: 500}); + fixture.slider_navigation({width: 110, height: 80, strategy: 'next_previous', cycle: 500, unit: 'px'}); } }); @@ -38,6 +38,11 @@ test('slider buttons should be next_event type', function() { }); +test('news row should be initialize with data-position = 0 and data-margin-inc = 110 and data-width = 330', function() { + deepEqual(fixture.find('div.news_row[data-position="0"][data-margin-inc="110"][data-article-width="110px"][data-width="330px"][data-max-position="2"]').length, 1, fixture.html()); +}); + + test('Click on next button should display "Biquette"', function() { fixture.find('div.slider_button[data-event="next"]').trigger('click'); deepEqual(fixture.find('div.news_row').css('margin-left'), '-110px', fixture.html()); @@ -74,6 +79,14 @@ test('Click 3 times on next should display "Bokeh la biquette"', function() { }); +test('Click 3 times on next should let data-position to 2 ', function() { + fixture.find('div.slider_button[data-event="next"]').trigger('click'); + fixture.find('div.slider_button[data-event="next"]').trigger('click'); + fixture.find('div.slider_button[data-event="next"]').trigger('click'); + deepEqual(fixture.find('div.news_row').attr('data-position'), '2', fixture.html()); +}); + + test('Click on previous should stay on "Bokeh"', function() { fixture.find('div.slider_button[data-event="previous"]').trigger('click'); deepEqual(fixture.find('div.news_row').css('margin-left'), '0px', fixture.html()); @@ -81,12 +94,12 @@ test('Click on previous should stay on "Bokeh"', function() { test('window width should be 110px', function() { - deepEqual(fixture.find('div.window').attr('style'), 'width:110px;height:80px', fixture.html()); + deepEqual(fixture.find('div.window').attr('style'), 'width:110px; height:80px', fixture.html()); }); test('window height should be 80px', function() { - deepEqual(fixture.find('div.window').attr('style'), 'width:110px;height:80px', fixture.html()); + deepEqual(fixture.find('div.window').attr('style'), 'width:110px; height:80px', fixture.html()); }); diff --git a/public/opac/java/slider_navigation/tests/news_slider_test.js b/public/opac/java/slider_navigation/tests/news_slider_test.js index b3165015027cfcd346c6225190bd8535582de325..f49248906d228a0148d6e04ce9abc545018b7d5e 100644 --- a/public/opac/java/slider_navigation/tests/news_slider_test.js +++ b/public/opac/java/slider_navigation/tests/news_slider_test.js @@ -29,7 +29,7 @@ QUnit.module('slider_navigation', { +'<article>Biquette</article>' +'</div>'); - fixture.slider_navigation({width:50, height:300}); + fixture.slider_navigation({width:50, height:300, unit: 'px'}); } }); diff --git a/public/opac/java/slider_navigation/tests/preview_slider_test.js b/public/opac/java/slider_navigation/tests/preview_slider_test.js index 9d51664013bbda3cbcb5356508256dd905468a52..f542836d1ef5721e899d330e38364edac6938780 100644 --- a/public/opac/java/slider_navigation/tests/preview_slider_test.js +++ b/public/opac/java/slider_navigation/tests/preview_slider_test.js @@ -27,7 +27,7 @@ QUnit.module('slider_navigation', { +'<article>Bokeh la biquette</article>' +'</div>'); - fixture.slider_navigation({width:110, height:80, strategy:'preview', cycle: '500'}); + fixture.slider_navigation({width:110, height:80, strategy:'preview', cycle: '500', unit: 'px'}); } }); diff --git a/tests/application/modules/admin/controllers/AccueilControllerCmsTest.php b/tests/application/modules/admin/controllers/AccueilControllerCmsTest.php index 3e5cc481d36c2eec43aeeec578d5269b6bfecd14..90c2ab6bac8c136b40458f4159dfe50f3df7db13 100644 --- a/tests/application/modules/admin/controllers/AccueilControllerCmsTest.php +++ b/tests/application/modules/admin/controllers/AccueilControllerCmsTest.php @@ -92,6 +92,12 @@ class Admin_AccueilControllerCmsTestWithDefaultDiaporamaNavigation extends Admin $this->assertXPath('//input[@type="radio"][@name="display_order"][@value="CommentCount"]', $this->_response->getBody()); } + + + /** @test */ + public function unitShouldBeSetToPx() { + $this->assertXPath('//div[@id="objet_props"]//select[@name="op_navigation_unit"]/option[@value="px"]'); + } } diff --git a/tests/library/ZendAfi/View/Helper/Accueil/CalendarTest.php b/tests/library/ZendAfi/View/Helper/Accueil/CalendarTest.php index 957c13f79ac3a513728271370c4d6e94d9bca8f4..d5fe7a364d19968fae3f7919138c025c6a23dd32 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/CalendarTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/CalendarTest.php @@ -941,7 +941,8 @@ abstract class CalendarHelperDisplayModeTestCase extends CalendarViewHelperTestC 'mode-affichage' => 'diaporama_navigation', 'op_navigation_window_width' => '350', 'op_navigation_window_height' => '250', - 'op_navigation_mode' => 'next_previous']]; + 'op_navigation_mode' => 'next_previous', + 'op_navigation_unit' => 'px']]; $this->setupParams($params); $helper = new ZendAfi_View_Helper_Accueil_Calendar(12, $params); @@ -974,7 +975,7 @@ class CalendarHelperWithDiaporamaNavigationModeTest extends CalendarHelperDispla public function sliderNavigationShouldBeCallForWidget12() { $this->assertXPathContentContains($this->_head_script, '//script[@type="text/javascript"]', - '$(function(){$("#boite_12").slider_navigation({"width":"350","height":"250","strategy":"next_previous","cycle":0});});', + '$(function(){$("#boite_12").slider_navigation({"width":"350","height":"250","strategy":"next_previous","unit":"px","cycle":0});});', $this->_head_script); } diff --git a/tests/library/ZendAfi/View/Helper/Accueil/NewsTest.php b/tests/library/ZendAfi/View/Helper/Accueil/NewsTest.php index facb71d25d93ab8809ec8415c41853d97d223037..9d79e64880d00fa94948d19468e55e19567a8d8d 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/NewsTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/NewsTest.php @@ -629,7 +629,7 @@ class NewsHelperWithThreeArticlesInDiaporamaNavigationModeTest extends NewsHelpe public function sliderNavigationShouldBeCallForWidget12() { $this->assertXPathContentContains($this->_head_script, '//script[@type="text/javascript"]', - '$(function(){$("#boite_12").slider_navigation({"width":"350","height":"250","strategy":"buttons","cycle":0});});', + '$(function(){$("#boite_12").slider_navigation({"width":"350","height":"250","strategy":"buttons","unit":"px","cycle":0});});', $this->_head_script); } @@ -638,7 +638,7 @@ class NewsHelperWithThreeArticlesInDiaporamaNavigationModeTest extends NewsHelpe public function sliderNavigationShouldBeCallWithDefaultWidthAndHeight() { $this->assertXPathContentContains($this->_head_script, '//script[@type="text/javascript"]', - '$(function(){$("#boite_12").slider_navigation({"width":"350","height":"250","strategy":"buttons","cycle":0});});', + '$(function(){$("#boite_12").slider_navigation({"width":"350","height":"250","strategy":"buttons","unit":"px","cycle":0});});', $this->_head_script); } } @@ -679,7 +679,7 @@ class NewsHelperWithThreeArticlesInDiaporamaNavigationModeNextPreviousTest exten public function sliderNavigationShouldBeCallWithNextPreviousStrategy() { $this->assertXPathContentContains($this->_head_script, '//script[@type="text/javascript"]', - '$(function(){$("#boite_12").slider_navigation({"width":"350","height":"250","strategy":"next_previous","cycle":0});});', + '$(function(){$("#boite_12").slider_navigation({"width":"350","height":"250","strategy":"next_previous","unit":"px","cycle":0});});', $this->_head_script); } }