[feature/jquery_clock] Add jQuery-based clock to prosilver clock_side

The clock we currently use needs flash support. As newer browsers and
mobile devices are moving on from flash to HTML5 we should do the same and
replace our flash clock with a jQuery based clock.
It is using image sprites which means we only have to load 2 images. One
for the single digits and one for the double digit hours.
This is currently only added to prosilver and the obsolete settings in the
clock module still need to be removed.

B3P-218
This commit is contained in:
Marc Alexander
2013-03-02 14:06:22 +01:00
parent ce300a78a6
commit 53186f7060
8 changed files with 550 additions and 7 deletions

View File

@@ -1,9 +1,32 @@
{$LR_BLOCK_H_L}<!-- IF $S_BLOCK_ICON --><img src="{$IMAGE_SRC}" width="{$IMAGE_WIDTH}" height="{$IMAGE_HEIGHT}" alt="" />&nbsp;<!-- ENDIF -->{$TITLE}{$LR_BLOCK_H_R} {$LR_BLOCK_H_L}<!-- IF $S_BLOCK_ICON --><img src="{$IMAGE_SRC}" width="{$IMAGE_WIDTH}" height="{$IMAGE_HEIGHT}" alt="" />&nbsp;<!-- ENDIF -->{$TITLE}{$LR_BLOCK_H_R}
<div style="text-align: center;"> <div style="text-align: center; min-height: 5em; margin: 0 auto;">
<br /> <div id="portal-clock" style="margin-top: 10px; margin-bottom: 10px;">
<object type="application/x-shockwave-flash" data="{T_EXT_THEME_PATH}/images/portal/{CLOCK_SRC}" width="140" height="140"> <div id="portal-clock-back">
<param name="wmode" value="transparent" /> <div id="portal-clock-back-upper">
<param name="movie" value="{T_THEME_PATH}/images/portal/board3clock.swf" /> <img src="{T_EXT_THEME_PATH}/images/portal/spacer_up.png" style="float: left;" /><div id="portal-clock-back-hours-up"></div>
</object> <div id="portal-clock-back-minutes-up-left" ></div><div id="portal-clock-back-minutes-up-right"></div>
<div id="portal-clock-back-seconds-up-left"></div><div id="portal-clock-back-seconds-up-right"></div>
</div>
<div id="portal-clock-back-lower">
<img src="{T_EXT_THEME_PATH}/images/portal/spacer_down.png" style="float: left;" /><div id="portal-clock-back-hours-down"></div>
<div id="portal-clock-back-minutes-down-left"></div><div id="portal-clock-back-minutes-down-right"></div>
<div id="portal-clock-back-seconds-down-left"></div><div id="portal-clock-back-seconds-down-right"></div>
</div>
</div>
<div id="portal-clock-front">
<div id="portal-clock-front-upper">
<img src="{T_EXT_THEME_PATH}/images/portal/spacer_up.png" style="float: left;" /><div id="portal-clock-front-hours-up"></div>
<div id="portal-clock-front-minutes-up-left"></div><div id="portal-clock-front-minutes-up-right"></div>
<div id="portal-clock-front-seconds-up-left"></div><div id="portal-clock-front-seconds-up-right"></div>
</div>
<div id="portal-clock-front-lower">
<img src="{T_EXT_THEME_PATH}/images/portal/spacer_down.png" style="float: left;" /><div id="portal-clock-front-hours-down"></div>
<div id="portal-clock-front-minutes-down-left"></div><div id="portal-clock-front-minutes-down-right"></div>
<div id="portal-clock-front-seconds-down-left"></div><div id="portal-clock-front-seconds-down-right"></div>
</div>
</div>
</div> </div>
</div>
<!-- INCLUDEJS template/portal/modules/jquery.easing.1.3.js -->
<!-- INCLUDEJS template/portal/modules/portal_clock.js -->
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R} {$LR_BLOCK_F_L}{$LR_BLOCK_F_R}

View File

@@ -0,0 +1,205 @@
/*
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
*
* Uses the built in easing capabilities added In jQuery 1.1
* to offer multiple easing options
*
* TERMS OF USE - jQuery Easing
*
* Open source under the BSD License.
*
* Copyright © 2008 George McGinley Smith
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* Neither the name of the author nor the names of contributors may be used to endorse
* or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend( jQuery.easing,
{
def: 'easeOutQuad',
swing: function (x, t, b, c, d) {
//alert(jQuery.easing.default);
return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
},
easeInQuad: function (x, t, b, c, d) {
return c*(t/=d)*t + b;
},
easeOutQuad: function (x, t, b, c, d) {
return -c *(t/=d)*(t-2) + b;
},
easeInOutQuad: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return c/2*t*t + b;
return -c/2 * ((--t)*(t-2) - 1) + b;
},
easeInCubic: function (x, t, b, c, d) {
return c*(t/=d)*t*t + b;
},
easeOutCubic: function (x, t, b, c, d) {
return c*((t=t/d-1)*t*t + 1) + b;
},
easeInOutCubic: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return c/2*t*t*t + b;
return c/2*((t-=2)*t*t + 2) + b;
},
easeInQuart: function (x, t, b, c, d) {
return c*(t/=d)*t*t*t + b;
},
easeOutQuart: function (x, t, b, c, d) {
return -c * ((t=t/d-1)*t*t*t - 1) + b;
},
easeInOutQuart: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
return -c/2 * ((t-=2)*t*t*t - 2) + b;
},
easeInQuint: function (x, t, b, c, d) {
return c*(t/=d)*t*t*t*t + b;
},
easeOutQuint: function (x, t, b, c, d) {
return c*((t=t/d-1)*t*t*t*t + 1) + b;
},
easeInOutQuint: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
return c/2*((t-=2)*t*t*t*t + 2) + b;
},
easeInSine: function (x, t, b, c, d) {
return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
},
easeOutSine: function (x, t, b, c, d) {
return c * Math.sin(t/d * (Math.PI/2)) + b;
},
easeInOutSine: function (x, t, b, c, d) {
return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
},
easeInExpo: function (x, t, b, c, d) {
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
},
easeOutExpo: function (x, t, b, c, d) {
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
},
easeInOutExpo: function (x, t, b, c, d) {
if (t==0) return b;
if (t==d) return b+c;
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
},
easeInCirc: function (x, t, b, c, d) {
return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
},
easeOutCirc: function (x, t, b, c, d) {
return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
},
easeInOutCirc: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
},
easeInElastic: function (x, t, b, c, d) {
var s=1.70158;var p=0;var a=c;
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
if (a < Math.abs(c)) { a=c; var s=p/4; }
else var s = p/(2*Math.PI) * Math.asin (c/a);
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
},
easeOutElastic: function (x, t, b, c, d) {
var s=1.70158;var p=0;var a=c;
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
if (a < Math.abs(c)) { a=c; var s=p/4; }
else var s = p/(2*Math.PI) * Math.asin (c/a);
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
},
easeInOutElastic: function (x, t, b, c, d) {
var s=1.70158;var p=0;var a=c;
if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
if (a < Math.abs(c)) { a=c; var s=p/4; }
else var s = p/(2*Math.PI) * Math.asin (c/a);
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
},
easeInBack: function (x, t, b, c, d, s) {
if (s == undefined) s = 1.70158;
return c*(t/=d)*t*((s+1)*t - s) + b;
},
easeOutBack: function (x, t, b, c, d, s) {
if (s == undefined) s = 1.70158;
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
},
easeInOutBack: function (x, t, b, c, d, s) {
if (s == undefined) s = 1.70158;
if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
},
easeInBounce: function (x, t, b, c, d) {
return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
},
easeOutBounce: function (x, t, b, c, d) {
if ((t/=d) < (1/2.75)) {
return c*(7.5625*t*t) + b;
} else if (t < (2/2.75)) {
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
} else if (t < (2.5/2.75)) {
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
} else {
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
}
},
easeInOutBounce: function (x, t, b, c, d) {
if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
}
});
/*
*
* TERMS OF USE - EASING EQUATIONS
*
* Open source under the BSD License.
*
* Copyright © 2001 Robert Penner
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* Neither the name of the author nor the names of contributors may be used to endorse
* or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/

View File

@@ -0,0 +1,159 @@
/**
*
* @package Board3 Portal v2.1 - Clock
* @copyright (c) 2013 Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
(function($) { // Avoid conflicts with other libraries
"use strict";
var hour_cur = 0;
var minL_cur = 0;
var minR_cur = 0;
var secL_cur = 0;
var secR_cur = 0;
phpbb.b3pFlipClock = function(identifierUp, identifierDown, val, type) {
var backIdUp = identifierUp.replace('-front-', '-back-');
var backIdDown = identifierDown.replace('-front-', '-back-');
var backPosition = $(backIdUp).css('background-position');
var backPositionLength = backPosition.length;
var backY;
if (backPosition.substring(backPositionLength - 3, backPositionLength - 2) === '0') {
backY = '0px';
} else {
backY = backPosition.substring(backPositionLength - 5, backPositionLength);
}
backPosition = $(backIdUp).css('background-position');
$(identifierUp)
.css('background-position', backPosition)
.height('21px')
.css({'visibility': 'visible', 'display': 'inline-block' });
$(identifierDown)
.height('0px')
.css('visibility', 'visible');
// single digits will have digits 0 - 9, double 0 - 24
if (type === 'single') {
$(backIdUp).css('background-position', (val * -22) + 'px ' + backY);
} else if (type === 'double') {
if (val >= 12) {
backY = '-22px';
val = val - 12;
$(backIdUp).css('background-position', (val * -43) + 'px ' + backY);
val = val + 12;
} else {
if (val < 12 && backY !== '0px') {
backY = '0px';
}
$(backIdUp).css('background-position', (val * -43) + 'px ' + backY);
}
} else {
return;
}
// now get the vertical offset of the bottom digit
backPosition = $(identifierDown).css('background-position');
backPositionLength = backPosition.length;
if (backPosition.substring(backPositionLength - 3, backPositionLength - 2) === '0') {
backY = '0px';
} else {
backY = backPosition.substring(backPositionLength - 5, backPositionLength);
}
// single digits will have digits 0 - 9, double 0 - 24
if (type === 'single') {
$(identifierDown).css('background-position', (val * -22) + 'px ' + backY);
} else if (type === 'double') {
if (val >= 12) {
backY = '-65px';
val = val - 12;
$(identifierDown).css('background-position', (val * -43) + 'px ' + backY);
val = val + 12;
} else {
if (val < 12 && backY !== '-44px') {
backY = '-44px';
}
$(identifierDown).css('background-position', (val * -43) + 'px ' + backY);
}
} else {
return;
}
$(identifierUp).animate({
height: '0px',
'margin-top': '21px'
},
{
'duration': 150,
defaultEasing: 'easeInOutSine',
'complete': function(){
$(identifierDown).animate(
{height: '20px'},
{
'duration': 150,
defaultEasing: 'easeInOutSine',
'complete': function(){
$(backIdDown).css('background-position', $(identifierDown).css('background-position'));
$(identifierDown).css({
'visibility': 'hidden',
'display': 'inline-block'
});
$(identifierUp).css({
'visibility': 'hidden',
'display': 'inline-block',
'margin-top': '0px'
});
}
}
);
}
}
);
};
phpbb.b3pClock = function() {
var now = new Date();
var hour = now.getHours();
var minL = Math.floor(now.getMinutes() / 10);
var minR = now.getMinutes() % 10;
var secL = Math.floor(now.getSeconds() / 10);
var secR = now.getSeconds() % 10;
if (hour !== hour_cur) {
phpbb.b3pFlipClock('#portal-clock-front-hours-up', '#portal-clock-front-hours-down', hour, 'double');
hour_cur = hour;
}
if (minR !== minR_cur) {
phpbb.b3pFlipClock('#portal-clock-front-minutes-up-right', '#portal-clock-front-minutes-down-right', minR, 'single');
minR_cur = minR;
}
if (minL !== minL_cur) {
phpbb.b3pFlipClock('#portal-clock-front-minutes-up-left', '#portal-clock-front-minutes-down-left', minL, 'single');
minL_cur = minL;
}
if (secR !== secR_cur) {
phpbb.b3pFlipClock('#portal-clock-front-seconds-up-right', '#portal-clock-front-seconds-down-right', secR, 'single');
secR_cur = secR;
}
if (secL !== secL_cur) {
phpbb.b3pFlipClock('#portal-clock-front-seconds-up-left', '#portal-clock-front-seconds-down-left', secL, 'single');
secL_cur = secL;
}
};
$(document).ready(function() {
setInterval(phpbb.b3pClock, 1000);
});
})(jQuery); // Avoid conflicts with other libraries

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -92,4 +92,160 @@ span.portal-corners-top-inner, span.portal-corners-bottom-inner{
background-image: url("./images/portal/arrowbullet_rtl.gif"); background-image: url("./images/portal/arrowbullet_rtl.gif");
background-position: center right; /*custom bullet list image*/ background-position: center right; /*custom bullet list image*/
padding-right: 19px; /*link text is indented 19px*/ padding-right: 19px; /*link text is indented 19px*/
} }
/* Portal clock
-------------------------------------- */
#portal-clock {
position: relative;
width: 100%;
}
#portal-clock-front, #portal-clock-back {
position: absolute;
top: 0px;
}
#portal-clock-front-upper div {
height: 21px;
position: absolute;
vertical-align: bottom;
visibility: hidden;
}
#portal-clock-front-lower div {
height: 20px;
position: absolute;
vertical-align: top;
visibility: hidden;
}
#portal-clock-back-upper div {
position: absolute;
vertical-align: bottom;
}
#portal-clock-back-lower div {
position: absolute;
vertical-align: top;
}
#portal-clock-back-seconds-up-left, #portal-clock-back-seconds-up-right,
#portal-clock-front-minutes-up-left, #portal-clock-front-minutes-up-right,
#portal-clock-back-minutes-up-left, #portal-clock-back-minutes-up-right,
#portal-clock-front-seconds-up-left, #portal-clock-front-seconds-up-right,
#portal-clock-back-minutes-down-left, #portal-clock-back-minutes-down-right,
#portal-clock-back-seconds-down-left, #portal-clock-back-seconds-down-right,
#portal-clock-front-minutes-down-left, #portal-clock-front-minutes-down-right,
#portal-clock-front-seconds-down-left, #portal-clock-front-seconds-down-right {
width: 21px;
height: 21px;
background-position: 0 0;
background: url(./images/portal/portal_clock_single.png) no-repeat;
}
/* Minutes start
-------------------------------------- */
#portal-clock-back-minutes-up-left{
background-position: 0 0;
margin: 0 0 0 43px;
}
#portal-clock-back-minutes-up-right {
background-position: 0 -43px;
margin: 0 0 0 64px;
}
#portal-clock-front-minutes-up-left {
background-position: 0 0;
margin: 0 0 0 43px;
}
#portal-clock-front-minutes-up-right {
background-position: 0 -43px;
margin: 0 0 0 63px;
}
#portal-clock-back-minutes-down-left{
background-position: 0 -22px;
margin: 21px 0 0 43px;
}
#portal-clock-back-minutes-down-right {
background-position: 0 -65px;
margin: 21px 0 0 64px;
}
#portal-clock-front-minutes-down-left {
background-position: 0 -22px;
margin: 21px 0 0 42px;
}
#portal-clock-front-minutes-down-right {
background-position: 0 -65px;
margin: 21px 0 0 63px;
}
/* Seconds start
---------------------------------------- */
#portal-clock-back-seconds-up-left{
background-position: 0 0;
margin: 0 0 0 85px;
}
#portal-clock-back-seconds-up-right {
background-position: 0 -43px;
margin: 0 0 0 106px;
}
#portal-clock-front-seconds-up-left {
background-position: 0 0;
margin: 0 0 0 84px;
}
#portal-clock-front-seconds-up-right {
background-position: 0 -43px;
margin: 0 0 0 105px;
}
#portal-clock-back-seconds-down-left{
background-position: 0 -22px;
margin: 21px 0 0 85px;
}
#portal-clock-back-seconds-down-right {
background-position: 0 -65px;
margin: 21px 0 0 106px;
}
#portal-clock-front-seconds-down-left {
background-position: 0 -22px;
margin: 21px 0 0 84px;
}
#portal-clock-front-seconds-down-right {
background-position: 0 -65px;
margin: 21px 0 0 105px;
}
/* Hours start
---------------------------------------- */
#portal-clock-back-hours-up, #portal-clock-front-hours-up {
width: 42px;
height: 21px;
background: url(./images/portal/portal_clock_double.png) no-repeat;
background-position: 0 0;
vertical-align: bottom;
display: inline-block;
margin: 0 0 0 0;
}
#portal-clock-back-hours-down, #portal-clock-front-hours-down {
width: 42px;
height: 20px;
background: url(./images/portal/portal_clock_double.png) no-repeat;
background-position: 0 -44px;
vertical-align: top;
display: inline-block;
margin: 21px 0 0 0;
}