diff --git a/README.md b/README.md index 01ce30c..6374ad3 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ -H5P Pictusel +H5P Image Slider ========== -Displays a greeting card +Displays an image slider ## License (The MIT License) -Copyright (c) 2017 Svein-Tore Griff With +Copyright (c) 2017 Joubel AS Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..f7edc64 --- /dev/null +++ b/icon.svg @@ -0,0 +1,56 @@ + + + diff --git a/pictusel.css b/image-slider.css similarity index 58% rename from pictusel.css rename to image-slider.css index 456a3d7..792bed0 100644 --- a/pictusel.css +++ b/image-slider.css @@ -1,8 +1,8 @@ -.h5p-pictusel { +.h5p-image-slider { overflow: hidden; } -.h5p-pictusel-slides:after { +.h5p-image-slider-slides:after { content: "."; display: block; height: 0; @@ -10,12 +10,12 @@ visibility: hidden; } -.h5p-pictusel-slides-holder { +.h5p-image-slider-slides-holder { position: relative; margin-bottom: 2.5em; } -.h5p-pictusel-button { +.h5p-image-slider-button { position: absolute; top: 0; width: 15%; @@ -26,16 +26,24 @@ z-index: 3; } -.h5p-pictusel-button-text { +.h5p-image-slider-button-text { position: absolute; - left: calc(50% - 1.25em); - top: calc(50% - 1.25em); + top: calc(50% - 1.5em); background-color: #ffffff; - height: 2.5em; - width: 2.5em; + height: 3em; + width: 3em; } -.h5p-pictusel-button-background { +.h5p-image-slider-left-button .h5p-image-slider-button-text { + left: 20%; +} + +.h5p-image-slider-right-button .h5p-image-slider-button-text { + right: 20%; +} + + +.h5p-image-slider-button-background { position: absolute; height: 100%; width: 100%; @@ -44,37 +52,37 @@ transition: opacity 0.3s; } -.h5p-pictusel-button:hover .h5p-pictusel-button-background { +.h5p-image-slider-button:hover .h5p-image-slider-button-background { opacity: 1; } -.h5p-pictusel-left-button { +.h5p-image-slider-left-button { left: 0; transition: height 0.2s; } -.h5p-pictusel-left-button .h5p-pictusel-button-background { +.h5p-image-slider-left-button .h5p-image-slider-button-background { background: linear-gradient(90deg, rgba(1,1,1,0.3), rgba(1,1,1,0)); } -.h5p-pictusel-right-button { +.h5p-image-slider-right-button { left: 85%; transition: height 0.2s; } -.h5p-pictusel-right-button .h5p-pictusel-button-text { +.h5p-image-slider-right-button .h5p-image-slider-button-text { background: no-repeat url('images/arrow-right.svg'); } -.h5p-pictusel-left-button .h5p-pictusel-button-text { +.h5p-image-slider-left-button .h5p-image-slider-button-text { background: no-repeat url('images/arrow-left.svg'); } -.h5p-pictusel-no-transition { +.h5p-image-slider-no-transition { transition: none !important; } -.h5p-pictusel-progress { +.h5p-image-slider-progress { margin: 0 auto; padding: 0.75em 0; text-align: center; @@ -85,7 +93,7 @@ line-height: 0.5em; } -.h5p-pictusel-progress-element { +.h5p-image-slider-progress-element { list-style: none; display: inline-block; width: 1em; @@ -96,51 +104,51 @@ cursor: pointer; } -.h5p-pictusel-current-progress-element { +.h5p-image-slider-current-progress-element { background: no-repeat url('images/circle-active.svg'); } -.h5p-pictu-slide-holder { +.h5p-image-slide-holder { float: left; margin-left: -100%; } -.h5p-pictusel-dragging { +.h5p-image-slider-dragging { transition: none !important; left: 0 !important; } -.h5p-pictu-slide-holder:first-child { +.h5p-image-slide-holder:first-child { display: block; margin-left: 0; } -.h5p-pictu-slide-holder.h5p-pictusel-current { +.h5p-image-slide-holder.h5p-image-slider-current { transition: left 0.32s; left: 0; display: block; z-index: 2; } -.h5p-pictusel-future { +.h5p-image-slider-future { transition: left 0.35s; left: 100.1%; } -.h5p-pictusel-past { +.h5p-image-slider-past { transition: left 0.35s; left: -100.1%; } -.h5p-pictusel-removing { +.h5p-image-slider-removing { display: block; } -.h5p-pictusel-past.h5p-pictusel-no-transition { +.h5p-image-slider-past.h5p-image-slider-no-transition { left: -100.0%; } -.h5p-pictusel-future.h5p-pictusel-no-transition { +.h5p-image-slider-future.h5p-image-slider-no-transition { left: 100.0%; } .h5p-content-controls { z-index: 4; } -.h5p-pictusel .h5p-enable-fullscreen { +.h5p-image-slider .h5p-enable-fullscreen { width: 2.25em; height: 1.83em; background: no-repeat url('images/full-screen-enter.svg'); @@ -150,10 +158,10 @@ font-size: 1em; } -.h5p-pictusel .h5p-enable-fullscreen:before { +.h5p-image-slider .h5p-enable-fullscreen:before { content: ''; } -.h5p-pictusel .h5p-enable-fullscreen:hover { +.h5p-image-slider .h5p-enable-fullscreen:hover { background-color: rgba(0,0,0,0.35); } \ No newline at end of file diff --git a/pictusel.js b/image-slider.js similarity index 74% rename from pictusel.js rename to image-slider.js index 67eb053..7087eb7 100644 --- a/pictusel.js +++ b/image-slider.js @@ -1,6 +1,6 @@ var H5P = H5P || {}; -H5P.Pictusel = (function ($) { +H5P.ImageSlider = (function ($) { /** * Constructor function. */ @@ -11,9 +11,9 @@ H5P.Pictusel = (function ($) { H5P.EventDispatcher.call(this); // Extend defaults with provided options this.options = $.extend(true, {}, { - pictuSlides: [ + imageSlides: [ { - 'pictuSlide': null + 'imageSlide': null } ], "i18n": { @@ -30,18 +30,18 @@ H5P.Pictusel = (function ($) { // Keep provided id. this.id = id; this.currentSlideId = 0; - this.pictuSlides = []; - this.pictuSlideHolders = []; + this.imageSlides = []; + this.imageSlideHolders = []; this.determineAspectRatio(); - for (var i = 0; i < this.options.pictuSlides.length; i++) { - this.pictuSlides[i] = H5P.newRunnable(this.options.pictuSlides[i], this.id, undefined, undefined, { + for (var i = 0; i < this.options.imageSlides.length; i++) { + this.imageSlides[i] = H5P.newRunnable(this.options.imageSlides[i], this.id, undefined, undefined, { aspectRatio: this.aspectRatio }); - this.pictuSlides[i].on('loaded', function() { + this.imageSlides[i].on('loaded', function() { self.trigger('resize'); }); - this.pictuSlideHolders[i] = false; + this.imageSlideHolders[i] = false; } this.on('enterFullScreen', function() { @@ -56,8 +56,8 @@ H5P.Pictusel = (function ($) { if (fullScreenOn) { self.$slides.css('height', ''); var newAspectRatio = window.innerWidth / (window.innerHeight - self.$progressBar.outerHeight()); - for (var i = 0; i < self.pictuSlides.length; i++) { - self.pictuSlides[i].setAspectRatio(newAspectRatio); + for (var i = 0; i < self.imageSlides.length; i++) { + self.imageSlides[i].setAspectRatio(newAspectRatio); } } else { @@ -74,7 +74,7 @@ H5P.Pictusel = (function ($) { C.prototype.constructor = C; /** - * Set the aspect ratio for this pictusel + * Set the aspect ratio for this image-slider */ C.prototype.determineAspectRatio = function() { // Set aspectRatio to default @@ -84,8 +84,8 @@ H5P.Pictusel = (function ($) { switch (this.options.aspectRatioMode) { case 'auto': var imageRatios = []; - for (var i = 0; i < this.options.pictuSlides.length; i++) { - var imageFile = this.options.pictuSlides[i].params.picture.params.file; + for (var i = 0; i < this.options.imageSlides.length; i++) { + var imageFile = this.options.imageSlides[i].params.image.params.file; imageRatios[i] = imageFile.width / imageFile.height; } imageRatios.sort(function(a, b){return a - b}); @@ -113,19 +113,19 @@ H5P.Pictusel = (function ($) { this.$container = $container; // Set class on container to identify it as a greeting card // container. Allows for styling later. - $container.addClass("h5p-pictusel"); + $container.addClass("h5p-image-slider"); this.$slidesHolder = $('