Skip to content

Commit

Permalink
Update 1.0.1
Browse files Browse the repository at this point in the history
Updated jquery.snow.js to the latest.
Added two more color options: you can now have three different colors on
the flakes.
Added option to change the dingbat used: you now have 20 different
characters to choose from.
Changed the default values of the snowflake sizes a bit.
Changed the z-index to 20 instead of 999!
Using <div class="flake"> instead of <div=id"flake"> since ID should be
unice.
  • Loading branch information
BlackSkorpio committed Dec 22, 2015
1 parent 6fb0dee commit 4bb6819
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 31 deletions.
Binary file added jquery-snow.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions jquery.snow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* jquery.snow - jQuery Snow Effect Plugin
*
* Available under MIT licence
*
* @version 1 (21. Jan 2012)
* @author Ivan Lazarevic
* @requires jQuery
* @see http://workshop.rs
*
* @params flakeChar - the HTML char to animate
* @params minSize - min size of snowflake, 10 by default
* @params maxSize - max size of snowflake, 20 by default
* @params newOn - frequency in ms of appearing of new snowflake, 500 by default
* @params flakeColors - array of colors , #FFFFFF by default
* @params durationMillis - stop effect after duration
* @example $.fn.snow({ maxSize: 200, newOn: 1000 });
*/
(function($){

$.fn.snow = function(options){

var $flake = $('<div class="flake" />').css({'position': 'absolute', 'top': '-50px'}),
documentHeight = $(document).height(),
documentWidth = $(document).width(),
defaults = {
flakeChar : "&#10052;",
minSize : 10,
maxSize : 20,
newOn : 500,
flakeColor : ["#ffffff"],
durationMillis: null
},
options = $.extend({}, defaults, options);

$flake.html(options.flakeChar);

var interval = setInterval( function(){
var startPositionLeft = Math.random() * documentWidth - 100,
startOpacity = 0.5 + Math.random(),
sizeFlake = options.minSize + Math.random() * options.maxSize,
endPositionTop = documentHeight - defaults.maxSize - 40,
endPositionLeft = startPositionLeft - 100 + Math.random() * 200,
durationFall = documentHeight * 10 + Math.random() * 5000;
$flake
.clone()
.appendTo('body')
.css(
{
left: startPositionLeft,
opacity: startOpacity,
'font-size': sizeFlake,
color: options.flakeColor[Math.floor((Math.random() * options.flakeColor.length))]
}
)
.animate(
{
top: endPositionTop,
left: endPositionLeft,
opacity: 0.2
},
durationFall,
'linear',
function() {
$(this).remove()
}
);
}, options.newOn);

if (options.durationMillis) {
setTimeout(function() {
removeInterval(interval);
}, options.durationMillis);
}
};

})(jQuery);
18 changes: 0 additions & 18 deletions jquery.snow.min.1.0.js

This file was deleted.

19 changes: 19 additions & 0 deletions jquery.snow.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* jquery.snow - jQuery Snow Effect Plugin
*
* Available under MIT licence
*
* @version 1 (21. Jan 2012)
* @author Ivan Lazarevic
* @requires jQuery
* @see http://workshop.rs
*
* @params flakeChar - the HTML char to animate
* @params minSize - min size of snowflake, 10 by default
* @params maxSize - max size of snowflake, 20 by default
* @params newOn - frequency in ms of appearing of new snowflake, 500 by default
* @params flakeColors - array of colors , #FFFFFF by default
* @params durationMillis - stop effect after duration
* @example $.fn.snow({ maxSize: 200, newOn: 1000 });
*/
(function($){$.fn.snow = function(options){var $flake = $('<div class="flake" style="z-index:20;" />').css({'position': 'absolute', 'top': '-50px'}),documentHeight= $(document).height(),documentWidth= $(document).width(),defaults= {flakeChar: "&#10052;", minSize: 10,maxSize: 20, newOn: 500, flakeColor: ["#ffffff"], durationMillis: null},options = $.extend({}, defaults, options);$flake.html(options.flakeChar);var interval = setInterval( function(){var startPositionLeft = Math.random() * documentWidth - 100,startOpacity = 0.5 + Math.random(),sizeFlake = options.minSize + Math.random() * options.maxSize,endPositionTop = documentHeight - defaults.maxSize - 40,endPositionLeft = startPositionLeft - 100 + Math.random() * 200,durationFall = documentHeight * 10 + Math.random() * 5000;$flake.clone().appendTo('body').css({left: startPositionLeft,opacity: startOpacity,'font-size': sizeFlake,color: options.flakeColor[Math.floor((Math.random() * options.flakeColor.length))]}).animate({top: endPositionTop,left: endPositionLeft,opacity: 0.2},durationFall,'linear',function() {$(this).remove()});}, options.newOn);if (options.durationMillis) {setTimeout(function() {removeInterval(interval);}, options.durationMillis);}};})(jQuery);
50 changes: 45 additions & 5 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,77 @@
{
"name": "Let It Snow",
"description": "Let it snow on your site",
"version": "1.0.0",
"version": "1.0.1",
"demo": "http://varoystrand.se/sidor/let-it-snow-for-koken/",
"author": {
"name": "Bjarne Varoystrand",
"link": "http://varoystrand.se/"
},

"data": {
"let_it_snow_char": {
"label": "Flake character",
"info": "Character used for the flake. See http://www.w3schools.com/charsets/ref_utf_dingbats.asp for reference.",
"type": "select",
"options": [
{ "label": "Sparkles", "value": "&#10024;" },
{ "label": "Open centre asterisk", "value": "&#10034;" },
{ "label": "Eight spoked asterisk", "value": "&#10035;" },
{ "label": "Eight pointed pinwheel star", "value": "&#10037;" },
{ "label": "Teardrop-spoked asterisk", "value": "&#10043;" },
{ "label": "Open centre teardrop-spoked asterisk", "value": "&#10044;" },
{ "label": "Heavy teardrop-spoked asterisk", "value": "&#10045;" },
{ "label": "Six petalled black and white florette", "value": "&#10046;" },
{ "label": "Black florette", "value": "&#10047;" },
{ "label": "White florette", "value": "&#10048;" },
{ "label": "Eight petalled outlined black florette", "value": "&#10049;" },
{ "label": "Heavy teardrop-spoked pinwheel asterisk", "value": "&#10051;" },
{ "label": "Snowflake", "value": "&#10052;" },
{ "label": "Tight trifoliate snowflake", "value": "&#10053;" },
{ "label": "Heavy chevron snowflake", "value": "&#10054;" },
{ "label": "Sparkle", "value": "&#10055;" },
{ "label": "Heavy sparkle", "value": "&#10056;" },
{ "label": "Balloon-spoked asterisk", "value": "&#10057;" },
{ "label": "Eight teardrop-spoked propeller asterisk", "value": "&#10058;" },
{ "label": "Heavy eight teardrop-spoked propeller asterisk", "value": "&#10059;" }
],
"value": "&#10052;"
},
"let_it_snow_minsize": {
"label": "Min size",
"info": "Min size of snowflake.",
"type": "number",
"value": 10
"value": 20
},
"let_it_snow_maxsize": {
"label": "Max size",
"info": "Max size of snowflake.",
"type": "number",
"value": 20
"value": 50
},
"let_it_snow_newon": {
"label": "Snow frequency",
"info": "Frequency in ms of appearing of new snowflake.",
"type": "number",
"value": "500"
},
"let_it_snow_flakecolor": {
"let_it_snow_flakecolor1": {
"label": "Color",
"info": "Color of snowflake.",
"info": "Color of snowflake 1.",
"type": "color",
"value": "#FFFFFF"
},
"let_it_snow_flakecolor2": {
"label": "Color",
"info": "Color of snowflake 2.",
"type": "color",
"value": "#B8B9BA"
},
"let_it_snow_flakecolor3": {
"label": "Color",
"info": "Color of snowflake 3.",
"type": "color",
"value": "#636363"
}
}
}
19 changes: 11 additions & 8 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,27 @@ class BaldursPhotographyLetItSnow extends KokenPlugin {

function __construct()
{
$this->require_setup = true;
$this->require_setup = false;
$this->register_hook('before_closing_body', 'render');
}

function render()
{

$minsize = $this->data->let_it_snow_minsize;
$maxsize = $this->data->let_it_snow_maxsize;
$newon = $this->data->let_it_snow_newon;
$flakecolor = $this->data->let_it_snow_flakecolor;
$path = $this->get_path();
$flakeChar = $this->data->let_it_snow_char;
$minsize = $this->data->let_it_snow_minsize;
$maxsize = $this->data->let_it_snow_maxsize;
$newon = $this->data->let_it_snow_newon;
$flakecolor1 = $this->data->let_it_snow_flakecolor1;
$flakecolor2 = $this->data->let_it_snow_flakecolor2;
$flakecolor3 = $this->data->let_it_snow_flakecolor3;
$path = $this->get_path();

echo <<<OUT
<script src="{$path}/jquery.snow.min.1.0.js"></script>
<script src="{$path}/jquery.snow.min.js"></script>
<script>
$(document).ready( function(){
$.fn.snow({ minSize: {$minsize}, maxSize: {$maxsize}, newOn: {$newon}, flakeColor: '{$flakecolor}' });
$.fn.snow({ flakeChar: "{$flakeChar}", minSize: {$minsize}, maxSize: {$maxsize}, newOn: {$newon}, flakeColor: ["{$flakecolor1}", "{$flakecolor2}", "{$flakecolor3}"] });
});
</script>
OUT;
Expand Down

0 comments on commit 4bb6819

Please sign in to comment.