mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 04:53:26 +00:00
Fix JS codestyle
This commit is contained in:
@@ -1,29 +1,27 @@
|
||||
(function($){
|
||||
$.fn.nicoslider = function(options)
|
||||
{
|
||||
(function ($) {
|
||||
$.fn.nicoslider = function (options) {
|
||||
var defaults = {
|
||||
start : 0,
|
||||
color : '#F6F2F1',
|
||||
sliderHeight : false
|
||||
start: 0,
|
||||
color: '#F6F2F1',
|
||||
sliderHeight: false
|
||||
};
|
||||
|
||||
var opts = $.extend({}, $.fn.nicoslider.defaults,defaults, options);
|
||||
var opts = $.extend({}, $.fn.nicoslider.defaults, defaults, options);
|
||||
|
||||
return this.each(function(){
|
||||
return this.each(function () {
|
||||
new nicoslide(this, opts);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
var nicoslide = function(slider, o)
|
||||
{
|
||||
var nicoslide = function (slider, o) {
|
||||
var $slider = $(slider);
|
||||
|
||||
$sliderWidth = $slider.parent().innerWidth();
|
||||
|
||||
$sliderCss = {
|
||||
'width':$sliderWidth,
|
||||
'background-color':o.color
|
||||
'width': $sliderWidth,
|
||||
'background-color': o.color
|
||||
};
|
||||
|
||||
$slider.css($sliderCss);
|
||||
@@ -32,36 +30,34 @@
|
||||
var ulWidth = 0;
|
||||
var liHeight = 0;
|
||||
|
||||
$slider.find("li").each(function(){
|
||||
$slider.find("li").each(function () {
|
||||
ulWidth += $(this).width() + 5;
|
||||
ulWidth += parseInt($(this).css("padding-left"));
|
||||
ulWidth += parseInt($(this).css("padding-right"));
|
||||
ulWidth += parseInt($(this).css("margin-left"));
|
||||
ulWidth += parseInt($(this).css("margin-right"));
|
||||
liHeight = Math.max(liHeight,$(this).outerHeight());
|
||||
liHeight = Math.max(liHeight, $(this).outerHeight());
|
||||
});
|
||||
//5 % of slider width
|
||||
$scrollWidth = Math.round(parseInt($sliderWidth) * parseFloat("0.05"));
|
||||
//min 30 px;
|
||||
if($scrollWidth < 30)
|
||||
{
|
||||
if ($scrollWidth < 30) {
|
||||
$scrollWidth = 30;
|
||||
}
|
||||
|
||||
var $wrapperWidth = Math.round(parseInt($sliderWidth) - ( 2 * $scrollWidth ));
|
||||
|
||||
if(ulWidth > $wrapperWidth)
|
||||
{
|
||||
if (ulWidth > $wrapperWidth) {
|
||||
ul.wrapAll("<div class='wrapper'></div>");
|
||||
$wrapper = $slider.find(".wrapper");
|
||||
$ulHeight = ul.height();
|
||||
$wrapper.width($wrapperWidth);
|
||||
$wrapper.height($ulHeight);
|
||||
|
||||
$wrapperCss= {
|
||||
'overflow':'hidden',
|
||||
'float':'left',
|
||||
'position':'relative'
|
||||
$wrapperCss = {
|
||||
'overflow': 'hidden',
|
||||
'float': 'left',
|
||||
'position': 'relative'
|
||||
};
|
||||
|
||||
$wrapper.css($wrapperCss);
|
||||
@@ -79,19 +75,19 @@
|
||||
$("div.rb").css('float', 'right');
|
||||
|
||||
rightCss = {
|
||||
'width' : $scrollWidth - ($wrapper.outerWidth(true) - $wrapper.innerWidth()),
|
||||
'height' : liHeight + 5,
|
||||
'float' : 'right',
|
||||
'background-color' : o.color,
|
||||
'width': $scrollWidth - ($wrapper.outerWidth(true) - $wrapper.innerWidth()),
|
||||
'height': liHeight + 5,
|
||||
'float': 'right',
|
||||
'background-color': o.color,
|
||||
'cursor': 'pointer',
|
||||
' user-select': 'none'
|
||||
};
|
||||
|
||||
leftCss = {
|
||||
'width' : $scrollWidth - ($wrapper.outerWidth(true) - $wrapper.innerWidth()),
|
||||
'height' : liHeight + 5,
|
||||
'float' : 'left',
|
||||
'background-color' : o.color,
|
||||
'width': $scrollWidth - ($wrapper.outerWidth(true) - $wrapper.innerWidth()),
|
||||
'height': liHeight + 5,
|
||||
'float': 'left',
|
||||
'background-color': o.color,
|
||||
'cursor': 'pointer',
|
||||
' user-select': 'none'
|
||||
};
|
||||
@@ -108,13 +104,12 @@
|
||||
|
||||
|
||||
//scroll a droite
|
||||
rightScroll.bind("click", function(e){
|
||||
rightScroll.bind("click", function (e) {
|
||||
var x = e.pageX - ($(this).offset().left);
|
||||
scrollXpos = Math.round((x / rightScrollWidth) * scrollStepSpeed);
|
||||
shift += (scrollXpos * speed);
|
||||
shift += (scrollXpos * speed);
|
||||
|
||||
if(shift > (ulWidth - $wrapperWidth) + 50)
|
||||
{
|
||||
if (shift > (ulWidth - $wrapperWidth) + 50) {
|
||||
shift = (ulWidth - $wrapperWidth) + 50;
|
||||
}
|
||||
ul.animate({
|
||||
@@ -123,14 +118,13 @@
|
||||
});
|
||||
|
||||
//scroll a gauche
|
||||
leftScroll.bind("click", function(e){
|
||||
leftScroll.bind("click", function (e) {
|
||||
var x = $(this).innerWidth() - (e.pageX - $(this).offset().left);
|
||||
|
||||
scrollXpos = Math.round((x / leftScrollWidth) * scrollStepSpeed);
|
||||
shift -= (scrollXpos * speed);
|
||||
shift -= (scrollXpos * speed);
|
||||
|
||||
if(shift < 0)
|
||||
{
|
||||
if (shift < 0) {
|
||||
shift = 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user