src/ztfy/myams/resources/js/myams-notify.js
changeset 142 0201f1422bd7
parent 38 173b951c6aef
child 206 02a40997d8cb
equal deleted inserted replaced
141:a4200ce41c25 142:0201f1422bd7
     3  * Version 0.1.2
     3  * Version 0.1.2
     4  * ©2014 Thierry Florac <tflorac@ulthar.net>
     4  * ©2014 Thierry Florac <tflorac@ulthar.net>
     5  */
     5  */
     6 
     6 
     7 
     7 
     8 (function ($) {
     8 (function ($, globals) {
       
     9 
       
    10 	'use strict';
     9 
    11 
    10 	$(document).ready(function () {
    12 	$(document).ready(function () {
    11 		$("body").append("<div id='divSmallBoxes'></div>")
    13 		$("body").append("<div id='divSmallBoxes'></div>")
    12 				 .append("<div id='divMiniIcons'></div>")
    14 				 .append("<div id='divMiniIcons'></div>")
    13 				 .append("<div id='divBigBoxes'></div>");
    15 				 .append("<div id='divBigBoxes'></div>");
    18 		$(".divMessageBox").fadeOut(300, function () {
    20 		$(".divMessageBox").fadeOut(300, function () {
    19 			$(this).remove();
    21 			$(this).remove();
    20 		});
    22 		});
    21 		$(".LoadingBoxContainer").fadeOut(300, function () {
    23 		$(".LoadingBoxContainer").fadeOut(300, function () {
    22 			$(this).remove();
    24 			$(this).remove();
    23 		})
    25 		});
    24 	}
    26 	}
    25 
    27 
    26 	var ExistMsg = 0,
    28 	var ExistMsg = 0,
    27 		SmartMSGboxCount = 0,
    29 		SmartMSGboxCount = 0,
    28 		PrevTop = 0,
    30 		heightPrev,
    29 		BigBoxes = 0,
    31 		BigBoxes = 0,
    30 		SmallBoxes = 0,
    32 		SmallBoxes = 0,
    31 		SmallCount = 0,
       
    32 		SmallBoxesAnchos = 0;
    33 		SmallBoxesAnchos = 0;
    33 
    34 
       
    35 
       
    36 	var MyAMS = globals.MyAMS;
    34 
    37 
    35 	MyAMS.notify = {
    38 	MyAMS.notify = {
    36 
    39 
    37 		messageBox: function (options, callback) {
    40 		messageBox: function (options, callback) {
    38 
    41 
    47 				buttons: undefined,
    50 				buttons: undefined,
    48 				input: undefined,
    51 				input: undefined,
    49 				placeholder: "",
    52 				placeholder: "",
    50 				options: undefined,
    53 				options: undefined,
    51 				sound: undefined
    54 				sound: undefined
    52 			}
    55 			};
    53 			var settings = $.extend({}, defaults, options);
    56 			var settings = $.extend({}, defaults, options);
    54 
    57 
    55 			if (settings.sound && (isIE8 == 0)) {
    58 			if (settings.sound && (isIE8 === 0)) {
    56 				var audioElement = document.createElement("audio");
    59 				var audioElement = document.createElement("audio");
    57 				if (navigator.userAgent.match("Firefox/")) {
    60 				if (navigator.userAgent.match("Firefox/")) {
    58 					audioElement.setAttribute("src", MyAMS.baseURL + '../sound/message.ogg');
    61 					audioElement.setAttribute("src", MyAMS.baseURL + '../sound/message.ogg');
    59 				} else {
    62 				} else {
    60 					audioElement.setAttribute("src", MyAMS.baseURL + '../sound/message.mp3');
    63 					audioElement.setAttribute("src", MyAMS.baseURL + '../sound/message.mp3');
    61 				}
    64 				}
    62 				$.get();
    65 				$.get();
    63 				audioElement.addEventListener("load", function () {
    66 				audioElement.addEventListener("load", function () {
    64 					audioElement.play()
    67 					audioElement.play();
    65 				}, true);
    68 				}, true);
    66 				audioElement.pause();
    69 				audioElement.pause();
    67 				audioElement.play();
    70 				audioElement.play();
    68 			}
    71 			}
    69 			SmartMSGboxCount = SmartMSGboxCount + 1;
    72 			SmartMSGboxCount = SmartMSGboxCount + 1;
    70 			if (ExistMsg == 0) {
    73 			if (ExistMsg === 0) {
    71 				ExistMsg = 1;
    74 				ExistMsg = 1;
    72 				SmartMSG = "<div class='MessageBox animated fadeIn fast' id='MsgBoxBack'></div>";
    75 				SmartMSG = "<div class='MessageBox animated fadeIn fast' id='MsgBoxBack'></div>";
    73 				$("body").append(SmartMSG);
    76 				$("body").append(SmartMSG);
    74 				if (MyAMS.browser.isIE8orlower() == 1) {
    77 				if (MyAMS.browser.isIE8orlower() === 1) {
    75 					$("#MsgBoxBack").addClass("MessageIE");
    78 					$("#MsgBoxBack").addClass("MessageIE");
    76 				}
    79 				}
    77 			}
    80 			}
       
    81 			var i;
    78 			var InputType = "";
    82 			var InputType = "";
    79 			var HasInput = 0;
    83 			var HasInput = 0;
    80 			var Name = "";
    84 			var Name = "";
    81 			var NumButtons = 0;
    85 			var NumButtons = 0;
    82 			if (settings.input != undefined) {
    86 			if (settings.input !== undefined) {
    83 				HasInput = 1;
    87 				HasInput = 1;
    84 				settings.input = settings.input.toLowerCase();
    88 				settings.input = settings.input.toLowerCase();
    85 				switch (settings.input) {
    89 				switch (settings.input) {
    86 					case "text":
    90 					case "text":
    87 						InputType = "<input class='form-control' type='" + settings.input + "' id='txt" + SmartMSGboxCount + "' placeholder='" + settings.placeholder + "'/><br/><br/>";
    91 						InputType = "<input class='form-control' type='" + settings.input + "' id='txt" + SmartMSGboxCount + "' placeholder='" + settings.placeholder + "'/><br/><br/>";
    88 						break;
    92 						break;
    89 					case "password":
    93 					case "password":
    90 						InputType = "<input class='form-control' type='" + settings.input + "' id='txt" + SmartMSGboxCount + "' placeholder='" + settings.placeholder + "'/><br/><br/>";
    94 						InputType = "<input class='form-control' type='" + settings.input + "' id='txt" + SmartMSGboxCount + "' placeholder='" + settings.placeholder + "'/><br/><br/>";
    91 						break;
    95 						break;
    92 					case "select":
    96 					case "select":
    93 						if (settings.options == undefined) {
    97 						if (settings.options === undefined) {
    94 							alert("For this type of input, the options parameter is required.");
    98 							if (globals.alert) {
       
    99 								globals.alert("For this type of input, the options parameter is required.");
       
   100 							}
    95 						} else {
   101 						} else {
    96 							InputType = "<select class='form-control' id='txt" + SmartMSGboxCount + "'>";
   102 							InputType = "<select class='form-control' id='txt" + SmartMSGboxCount + "'>";
    97 							for (var i = 0; i <= settings.options.length - 1; i++) {
   103 							for (i=0; i <= settings.options.length - 1; i++) {
    98 								if (settings.options[i] == "[") {
   104 								if (settings.options[i] === "[") {
    99 									Name = "";
   105 									Name = "";
   100 								} else {
   106 								} else {
   101 									if (settings.options[i] == "]") {
   107 									if (settings.options[i] === "]") {
   102 										NumButtons = NumButtons + 1;
   108 										NumButtons = NumButtons + 1;
   103 										Name = "<option>" + Name + "</option>";
   109 										Name = "<option>" + Name + "</option>";
   104 										InputType += Name;
   110 										InputType += Name;
   105 									} else {
   111 									} else {
   106 										Name += settings.options[i];
   112 										Name += settings.options[i];
   109 							}
   115 							}
   110 							InputType += "</select>";
   116 							InputType += "</select>";
   111 						}
   117 						}
   112 						break;
   118 						break;
   113 					default:
   119 					default:
   114 						alert("That type of input is not handled yet");
   120 						if (globals.alert) {
       
   121 							globals.alert("That type of input is not handled yet");
       
   122 						}
   115 				}
   123 				}
   116 			}
   124 			}
   117 			Content = "<div class='MessageBoxContainer animated fadeIn fast' id='Msg" + SmartMSGboxCount + "'>";
   125 			Content = "<div class='MessageBoxContainer animated fadeIn fast' id='Msg" + SmartMSGboxCount + "'>";
   118 			Content += "<div class='MessageBoxMiddle'>";
   126 			Content += "<div class='MessageBoxMiddle'>";
   119 			Content += "<span class='MsgTitle'>" + settings.title + "</span class='MsgTitle'>";
   127 			Content += "<span class='MsgTitle'>" + settings.title + "</span class='MsgTitle'>";
   120 			Content += "<p class='pText'>" + settings.content + "</p>";
   128 			Content += "<p class='pText'>" + settings.content + "</p>";
   121 			Content += InputType;
   129 			Content += InputType;
   122 			Content += "<div class='MessageBoxButtonSection'>";
   130 			Content += "<div class='MessageBoxButtonSection'>";
   123 			if (settings.buttons == undefined) {
   131 			if (settings.buttons === undefined) {
   124 				settings.buttons = "[Accept]";
   132 				settings.buttons = "[Accept]";
   125 			}
   133 			}
   126 			settings.buttons = $.trim(settings.buttons);
   134 			settings.buttons = $.trim(settings.buttons);
   127 			settings.buttons = settings.buttons.split("");
   135 			settings.buttons = settings.buttons.split("");
   128 			if (settings.NormalButton == undefined) {
   136 			if (settings.NormalButton === undefined) {
   129 				settings.NormalButton = "#232323";
   137 				settings.NormalButton = "#232323";
   130 			}
   138 			}
   131 			if (settings.ActiveButton == undefined) {
   139 			if (settings.ActiveButton === undefined) {
   132 				settings.ActiveButton = "#ed145b";
   140 				settings.ActiveButton = "#ed145b";
   133 			}
   141 			}
   134 			for (var i = 0; i <= settings.buttons.length - 1; i++) {
   142 			for (i=0; i <= settings.buttons.length - 1; i++) {
   135 				if (settings.buttons[i] == "[") {
   143 				if (settings.buttons[i] === "[") {
   136 					Name = "";
   144 					Name = "";
   137 				} else {
   145 				} else {
   138 					if (settings.buttons[i] == "]") {
   146 					if (settings.buttons[i] === "]") {
   139 						NumButtons = NumButtons + 1;
   147 						NumButtons = NumButtons + 1;
   140 						Name = "<button id='bot" + NumButtons + "-Msg" + SmartMSGboxCount + "' class='btn btn-default btn-sm botTempo'> " + Name + "</button>";
   148 						Name = "<button id='bot" + NumButtons + "-Msg" + SmartMSGboxCount + "' class='btn btn-default btn-sm botTempo'> " + Name + "</button>";
   141 						Content += Name;
   149 						Content += Name;
   142 					} else {
   150 					} else {
   143 						Name += settings.buttons[i];
   151 						Name += settings.buttons[i];
   150 			if (SmartMSGboxCount > 1) {
   158 			if (SmartMSGboxCount > 1) {
   151 				$(".MessageBoxContainer").hide();
   159 				$(".MessageBoxContainer").hide();
   152 				$(".MessageBoxContainer").css("z-index", 99999);
   160 				$(".MessageBoxContainer").css("z-index", 99999);
   153 			}
   161 			}
   154 			$(".MessageBox").append(Content);
   162 			$(".MessageBox").append(Content);
   155 			if (HasInput == 1) {
   163 			if (HasInput === 1) {
   156 				$("#txt" + SmartMSGboxCount).focus();
   164 				$("#txt" + SmartMSGboxCount).focus();
   157 			}
   165 			}
   158 			$(".botTempo").hover(function () {
   166 			$(".botTempo").hover(function () {
   159 				var ThisID = $(this).attr("id");
   167 				var ThisID = $(this).attr("id");
   160 			}, function () {
   168 			}, function () {
   162 			});
   170 			});
   163 			$(".botTempo").click(function () {
   171 			$(".botTempo").click(function () {
   164 				var ThisID = $(this).attr("id");
   172 				var ThisID = $(this).attr("id");
   165 				var MsgBoxID = ThisID.substr(ThisID.indexOf("-") + 1);
   173 				var MsgBoxID = ThisID.substr(ThisID.indexOf("-") + 1);
   166 				var Press = $.trim($(this).text());
   174 				var Press = $.trim($(this).text());
   167 				if (HasInput == 1) {
   175 				if (HasInput === 1) {
   168 					if (typeof callback == "function") {
   176 					if (typeof callback === "function") {
   169 						var IDNumber = MsgBoxID.replace("Msg", "");
   177 						var IDNumber = MsgBoxID.replace("Msg", "");
   170 						var Value = $("#txt" + IDNumber).val();
   178 						var Value = $("#txt" + IDNumber).val();
   171 						if (callback) {
   179 						if (callback) {
   172 							callback(Press, Value);
   180 							callback(Press, Value);
   173 						}
   181 						}
   174 					}
   182 					}
   175 				} else {
   183 				} else {
   176 					if (typeof callback == "function") {
   184 					if (typeof callback === "function") {
   177 						if (callback) {
   185 						if (callback) {
   178 							callback(Press);
   186 							callback(Press);
   179 						}
   187 						}
   180 					}
   188 					}
   181 				}
   189 				}
   182 				$("#" + MsgBoxID).addClass("animated fadeOut fast");
   190 				$("#" + MsgBoxID).addClass("animated fadeOut fast");
   183 				SmartMSGboxCount = SmartMSGboxCount - 1;
   191 				SmartMSGboxCount = SmartMSGboxCount - 1;
   184 				if (SmartMSGboxCount == 0) {
   192 				if (SmartMSGboxCount === 0) {
   185 					$("#MsgBoxBack").removeClass("fadeIn").addClass("fadeOut").delay(300).queue(function () {
   193 					$("#MsgBoxBack").removeClass("fadeIn").addClass("fadeOut").delay(300).queue(function () {
   186 						ExistMsg = 0;
   194 						ExistMsg = 0;
   187 						$(this).remove();
   195 						$(this).remove();
   188 					})
   196 					});
   189 				}
   197 				}
   190 			})
   198 			});
   191 		},
   199 		},
   192 
   200 
   193 		bigBox: function (settings, callback) {
   201 		bigBox: function (settings, callback) {
   194 			var boxBig, content;
   202 			var boxBig, content;
   195 			settings = $.extend({
   203 			settings = $.extend({
   202 				timeout: undefined,
   210 				timeout: undefined,
   203 				colortime: 1500,
   211 				colortime: 1500,
   204 				colors: undefined
   212 				colors: undefined
   205 			}, settings);
   213 			}, settings);
   206 			if (settings.sound === true) {
   214 			if (settings.sound === true) {
   207 				if (MyAMS.browser.isIE8orlower() == 0) {
   215 				if (MyAMS.browser.isIE8orlower() === 0) {
   208 					var audioElement = document.createElement("audio");
   216 					var audioElement = document.createElement("audio");
   209 					if (navigator.userAgent.match("Firefox/")) {
   217 					if (navigator.userAgent.match("Firefox/")) {
   210 						audioElement.setAttribute("src", MyAMS.baseURL + '../snd/bigbox.ogg');
   218 						audioElement.setAttribute("src", MyAMS.baseURL + '../snd/bigbox.ogg');
   211 					} else {
   219 					} else {
   212 						audioElement.setAttribute("src", MyAMS.baseURL + '../snd/bigbox.mp3');
   220 						audioElement.setAttribute("src", MyAMS.baseURL + '../snd/bigbox.mp3');
   219 					audioElement.play();
   227 					audioElement.play();
   220 				}
   228 				}
   221 			}
   229 			}
   222 			BigBoxes = BigBoxes + 1;
   230 			BigBoxes = BigBoxes + 1;
   223 			boxBig = "<div id='bigBox" + BigBoxes + "' class='BigBox animated fadeIn fast'><div id='bigBoxColor" + BigBoxes + "'><i class='btnClose fa fa-times' id='btnClose" + BigBoxes + "'></i>";
   231 			boxBig = "<div id='bigBox" + BigBoxes + "' class='BigBox animated fadeIn fast'><div id='bigBoxColor" + BigBoxes + "'><i class='btnClose fa fa-times' id='btnClose" + BigBoxes + "'></i>";
   224 			if (settings.icon == undefined) {
   232 			if (settings.icon === undefined) {
   225 				settings.icon = "fa fa-cloud";
   233 				settings.icon = "fa fa-cloud";
   226 			}
   234 			}
   227 			boxBig += "<span><i class='" + settings.icon + "'></i>&nbsp; " + settings.title + "</span>";
   235 			boxBig += "<span><i class='" + settings.icon + "'></i>&nbsp; " + settings.title + "</span>";
   228 			boxBig += "<p>" + settings.content + "</p>";
   236 			boxBig += "<p>" + settings.content + "</p>";
   229 			boxBig += "<div class='bigboxnumber'>";
   237 			boxBig += "<div class='bigboxnumber'>";
   230 			if (settings.number != undefined) {
   238 			if (settings.number !== undefined) {
   231 				boxBig += settings.number;
   239 				boxBig += settings.number;
   232 			}
   240 			}
   233 			boxBig += "</div></div>";
   241 			boxBig += "</div></div>";
   234 			boxBig += "</div>";
   242 			boxBig += "</div>";
   235 			$("#divBigBoxes").append(boxBig);
   243 			$("#divBigBoxes").append(boxBig);
   236 			if (settings.color == undefined) {
   244 			if (settings.color === undefined) {
   237 				settings.color = "#004d60";
   245 				settings.color = "#004d60";
   238 			}
   246 			}
   239 			$("#bigBox" + BigBoxes).css("background-color", settings.color);
   247 			$("#bigBox" + BigBoxes).css("background-color", settings.color);
   240 			$("#divMiniIcons").append("<div id='miniIcon" + BigBoxes + "' class='cajita animated fadeIn' style='background-color: " + settings.color + ";'><i class='" + settings.icon + "'/></i></div>");
   248 			$("#divMiniIcons").append("<div id='miniIcon" + BigBoxes + "' class='cajita animated fadeIn' style='background-color: " + settings.color + ";'><i class='" + settings.icon + "'/></i></div>");
   241 			$("#miniIcon" + BigBoxes).bind("click", function () {
   249 			$("#miniIcon" + BigBoxes).bind("click", function () {
   250 				$("#" + FrontBigBox).css("z-index", 9999);
   258 				$("#" + FrontBigBox).css("z-index", 9999);
   251 				$("#" + FronBigBoxColor).removeClass("animated fadeIn").delay(1).queue(function () {
   259 				$("#" + FronBigBoxColor).removeClass("animated fadeIn").delay(1).queue(function () {
   252 					$(this).show();
   260 					$(this).show();
   253 					$(this).addClass("animated fadeIn");
   261 					$(this).addClass("animated fadeIn");
   254 					$(this).clearQueue();
   262 					$(this).clearQueue();
   255 				})
   263 				});
   256 			});
   264 			});
   257 			var ThisBigBoxCloseCross = $("#btnClose" + BigBoxes);
   265 			var ThisBigBoxCloseCross = $("#btnClose" + BigBoxes);
   258 			var ThisBigBox = $("#bigBox" + BigBoxes);
   266 			var ThisBigBox = $("#bigBox" + BigBoxes);
   259 			var ThisMiniIcon = $("#miniIcon" + BigBoxes);
   267 			var ThisMiniIcon = $("#miniIcon" + BigBoxes);
   260 			var ColorTimeInterval;
   268 			var ColorTimeInterval;
   261 			if (settings.colors != undefined && settings.colors.length > 0) {
   269 			if (settings.colors !== undefined && settings.colors.length > 0) {
   262 				ThisBigBoxCloseCross.attr("colorcount", "0");
   270 				ThisBigBoxCloseCross.attr("colorcount", "0");
   263 				ColorTimeInterval = setInterval(function () {
   271 				ColorTimeInterval = setInterval(function () {
   264 					var ColorIndex = ThisBigBoxCloseCross.attr("colorcount");
   272 					var ColorIndex = ThisBigBoxCloseCross.attr("colorcount");
   265 					ThisBigBoxCloseCross.animate({
   273 					ThisBigBoxCloseCross.animate({
   266 						backgroundColor: settings.colors[ColorIndex].color
   274 						backgroundColor: settings.colors[ColorIndex].color
   278 					}
   286 					}
   279 				}, settings.colortime);
   287 				}, settings.colortime);
   280 			}
   288 			}
   281 			ThisBigBoxCloseCross.bind("click", function () {
   289 			ThisBigBoxCloseCross.bind("click", function () {
   282 				clearInterval(ColorTimeInterval);
   290 				clearInterval(ColorTimeInterval);
   283 				if (typeof callback == "function") {
   291 				if (typeof callback === "function") {
   284 					if (callback) {
   292 					if (callback) {
   285 						callback();
   293 						callback();
   286 					}
   294 					}
   287 				}
   295 				}
   288 				var FrontBox = $(this).attr("id");
   296 				var FrontBox = $(this).attr("id");
   295 				});
   303 				});
   296 				$("#" + miniIcon).removeClass("fadeIn fast");
   304 				$("#" + miniIcon).removeClass("fadeIn fast");
   297 				$("#" + miniIcon).addClass("fadeOut fast").delay(300).queue(function () {
   305 				$("#" + miniIcon).addClass("fadeOut fast").delay(300).queue(function () {
   298 					$(this).clearQueue();
   306 					$(this).clearQueue();
   299 					$(this).remove();
   307 					$(this).remove();
   300 				})
   308 				});
   301 			});
   309 			});
   302 			if (settings.timeout != undefined) {
   310 			if (settings.timeout !== undefined) {
   303 				var TimedID = BigBoxes;
   311 				var TimedID = BigBoxes;
   304 				setTimeout(function () {
   312 				setTimeout(function () {
   305 					clearInterval(ColorTimeInterval);
   313 					clearInterval(ColorTimeInterval);
   306 					var box = $("#bigBox" + TimedID);
   314 					var box = $("#bigBox" + TimedID);
   307 					box.removeClass("fadeIn fast");
   315 					box.removeClass("fadeIn fast");
   312 					var icon = $("#miniIcon" + TimedID);
   320 					var icon = $("#miniIcon" + TimedID);
   313 					icon.removeClass("fadeIn fast");
   321 					icon.removeClass("fadeIn fast");
   314 					icon.addClass("fadeOut fast").delay(300).queue(function () {
   322 					icon.addClass("fadeOut fast").delay(300).queue(function () {
   315 						$(this).clearQueue();
   323 						$(this).clearQueue();
   316 						$(this).remove();
   324 						$(this).remove();
   317 					})
   325 					});
   318 				}, settings.timeout);
   326 				}, settings.timeout);
   319 			}
   327 			}
   320 		},
   328 		},
   321 
   329 
   322 		smallBox: function (settings, callback) {
   330 		smallBox: function (settings, callback) {
   331 				timeout: undefined,
   339 				timeout: undefined,
   332 				colortime: 1500,
   340 				colortime: 1500,
   333 				colors: undefined
   341 				colors: undefined
   334 			}, settings);
   342 			}, settings);
   335 			if (settings.sound === true) {
   343 			if (settings.sound === true) {
   336 				if (MyAMS.browser.isIE8orlower() == 0) {
   344 				if (MyAMS.browser.isIE8orlower() === 0) {
   337 					var audioElement = document.createElement("audio");
   345 					var audioElement = document.createElement("audio");
   338 					if (navigator.userAgent.match("Firefox/")) {
   346 					if (navigator.userAgent.match("Firefox/")) {
   339 						audioElement.setAttribute("src", MyAMS.baseURL + '../snd/smallbox.ogg');
   347 						audioElement.setAttribute("src", MyAMS.baseURL + '../snd/smallbox.ogg');
   340 					} else {
   348 					} else {
   341 						audioElement.setAttribute("src", MyAMS.baseURL + '../snd/smallbox.mp3');
   349 						audioElement.setAttribute("src", MyAMS.baseURL + '../snd/smallbox.mp3');
   350 			}
   358 			}
   351 			SmallBoxes = SmallBoxes + 1;
   359 			SmallBoxes = SmallBoxes + 1;
   352 			BoxSmall = "";
   360 			BoxSmall = "";
   353 			var IconSection = "",
   361 			var IconSection = "",
   354 				CurrentIDSmallbox = "smallbox" + SmallBoxes;
   362 				CurrentIDSmallbox = "smallbox" + SmallBoxes;
   355 			if (settings.iconSmall == undefined) {
   363 			if (settings.iconSmall === undefined) {
   356 				IconSection = "<div class='miniIcon'></div>";
   364 				IconSection = "<div class='miniIcon'></div>";
   357 			} else {
   365 			} else {
   358 				IconSection = "<div class='miniIcon'><i class='miniPic " + settings.iconSmall + "'></i></div>";
   366 				IconSection = "<div class='miniIcon'><i class='miniPic " + settings.iconSmall + "'></i></div>";
   359 			} if (settings.icon == undefined) {
   367 			} if (settings.icon === undefined) {
   360 				BoxSmall = "<div id='smallbox" + SmallBoxes + "' class='SmallBox animated fadeInRight fast'><div class='textoFull'><span>" + settings.title + "</span><p>" + settings.content + "</p></div>" + IconSection + "</div>";
   368 				BoxSmall = "<div id='smallbox" + SmallBoxes + "' class='SmallBox animated fadeInRight fast'><div class='textoFull'><span>" + settings.title + "</span><p>" + settings.content + "</p></div>" + IconSection + "</div>";
   361 			} else {
   369 			} else {
   362 				BoxSmall = "<div id='smallbox" + SmallBoxes + "' class='SmallBox animated fadeInRight fast'><div class='foto'><i class='" + settings.icon + "'></i></div><div class='textoFoto'><span>" + settings.title + "</span><p>" + settings.content + "</p></div>" + IconSection + "</div>";
   370 				BoxSmall = "<div id='smallbox" + SmallBoxes + "' class='SmallBox animated fadeInRight fast'><div class='foto'><i class='" + settings.icon + "'></i></div><div class='textoFoto'><span>" + settings.title + "</span><p>" + settings.content + "</p></div>" + IconSection + "</div>";
   363 			} if (SmallBoxes == 1) {
   371 			} if (SmallBoxes === 1) {
   364 				$("#divSmallBoxes").append(BoxSmall);
   372 				$("#divSmallBoxes").append(BoxSmall);
   365 				SmallBoxesAnchos = $("#smallbox" + SmallBoxes).height() + 40;
   373 				SmallBoxesAnchos = $("#smallbox" + SmallBoxes).height() + 40;
   366 			} else {
   374 			} else {
   367 				var SmartExist = $(".SmallBox").size();
   375 				var SmartExist = $(".SmallBox").size();
   368 				if (SmartExist == 0) {
   376 				if (SmartExist === 0) {
   369 					$("#divSmallBoxes").append(BoxSmall);
   377 					$("#divSmallBoxes").append(BoxSmall);
   370 					SmallBoxesAnchos = $("#smallbox" + SmallBoxes).height() + 40;
   378 					SmallBoxesAnchos = $("#smallbox" + SmallBoxes).height() + 40;
   371 				} else {
   379 				} else {
   372 					$("#divSmallBoxes").append(BoxSmall);
   380 					$("#divSmallBoxes").append(BoxSmall);
   373 					$("#smallbox" + SmallBoxes).css("top", SmallBoxesAnchos);
   381 					$("#smallbox" + SmallBoxes).css("top", SmallBoxesAnchos);
   374 					SmallBoxesAnchos = SmallBoxesAnchos + $("#smallbox" + SmallBoxes).height() + 20;
   382 					SmallBoxesAnchos = SmallBoxesAnchos + $("#smallbox" + SmallBoxes).height() + 20;
   375 					$(".SmallBox").each(function (index) {
   383 					$(".SmallBox").each(function (index) {
   376 						if (index == 0) {
   384 						if (index === 0) {
   377 							$(this).css("top", 20);
   385 							$(this).css("top", 20);
   378 							heightPrev = $(this).height() + 40;
   386 							heightPrev = $(this).height() + 40;
   379 							SmallBoxesAnchos = $(this).height() + 40;
   387 							SmallBoxesAnchos = $(this).height() + 40;
   380 						} else {
   388 						} else {
   381 							$(this).css("top", heightPrev);
   389 							$(this).css("top", heightPrev);
   382 							heightPrev = heightPrev + $(this).height() + 20;
   390 							heightPrev = heightPrev + $(this).height() + 20;
   383 							SmallBoxesAnchos = SmallBoxesAnchos + $(this).height() + 20;
   391 							SmallBoxesAnchos = SmallBoxesAnchos + $(this).height() + 20;
   384 						}
   392 						}
   385 					})
   393 					});
   386 				}
   394 				}
   387 			}
   395 			}
   388 			var ThisSmallBox = $("#smallbox" + SmallBoxes);
   396 			var ThisSmallBox = $("#smallbox" + SmallBoxes);
   389 			if (settings.color == undefined) {
   397 			if (settings.color === undefined) {
   390 				ThisSmallBox.css("background-color", "#004d60")
   398 				ThisSmallBox.css("background-color", "#004d60");
   391 			} else {
   399 			} else {
   392 				ThisSmallBox.css("background-color", settings.color)
   400 				ThisSmallBox.css("background-color", settings.color);
   393 			}
   401 			}
   394 			var ColorTimeInterval;
   402 			var ColorTimeInterval;
   395 			if (settings.colors != undefined && settings.colors.length > 0) {
   403 			if (settings.colors !== undefined && settings.colors.length > 0) {
   396 				ThisSmallBox.attr("colorcount", "0");
   404 				ThisSmallBox.attr("colorcount", "0");
   397 				ColorTimeInterval = setInterval(function () {
   405 				ColorTimeInterval = setInterval(function () {
   398 					var ColorIndex = ThisSmallBox.attr("colorcount");
   406 					var ColorIndex = ThisSmallBox.attr("colorcount");
   399 					ThisSmallBox.animate({
   407 					ThisSmallBox.animate({
   400 						backgroundColor: settings.colors[ColorIndex].color
   408 						backgroundColor: settings.colors[ColorIndex].color
   404 					} else {
   412 					} else {
   405 						ThisSmallBox.attr("colorcount", 0);
   413 						ThisSmallBox.attr("colorcount", 0);
   406 					}
   414 					}
   407 				}, settings.colortime);
   415 				}, settings.colortime);
   408 			}
   416 			}
   409 			if (settings.timeout != undefined) {
   417 			if (settings.timeout !== undefined) {
   410 				setTimeout(function () {
   418 				setTimeout(function () {
   411 					clearInterval(ColorTimeInterval);
   419 					clearInterval(ColorTimeInterval);
   412 					var ThisHeight = $(this).height() + 20;
   420 					var ThisHeight = $(this).height() + 20;
   413 					var ID = CurrentIDSmallbox;
   421 					var ID = CurrentIDSmallbox;
   414 					var ThisTop = $("#" + CurrentIDSmallbox).css("top");
   422 					var ThisTop = $("#" + CurrentIDSmallbox).css("top");
   415 					if ($("#" + CurrentIDSmallbox + ":hover").length != 0) {
   423 					if ($("#" + CurrentIDSmallbox + ":hover").length !== 0) {
   416 						$("#" + CurrentIDSmallbox).on("mouseleave", function () {
   424 						$("#" + CurrentIDSmallbox).on("mouseleave", function () {
   417 							SmallBoxesAnchos = SmallBoxesAnchos - ThisHeight;
   425 							SmallBoxesAnchos = SmallBoxesAnchos - ThisHeight;
   418 							$("#" + CurrentIDSmallbox).remove();
   426 							$("#" + CurrentIDSmallbox).remove();
   419 							if (typeof callback == "function") {
   427 							if (typeof callback === "function") {
   420 								if (callback) {
   428 								if (callback) {
   421 									callback();
   429 									callback();
   422 								}
   430 								}
   423 							}
   431 							}
   424 							var Primero = 1;
   432 							var Primero = 1;
   425 							var heightPrev = 0;
   433 							var heightPrev = 0;
   426 							$(".SmallBox").each(function (index) {
   434 							$(".SmallBox").each(function (index) {
   427 								if (index == 0) {
   435 								if (index === 0) {
   428 									$(this).animate({
   436 									$(this).animate({
   429 										top: 20
   437 										top: 20
   430 									}, 300);
   438 									}, 300);
   431 									heightPrev = $(this).height() + 40;
   439 									heightPrev = $(this).height() + 40;
   432 									SmallBoxesAnchos = $(this).height() + 40;
   440 									SmallBoxesAnchos = $(this).height() + 40;
   435 										top: heightPrev
   443 										top: heightPrev
   436 									}, 350);
   444 									}, 350);
   437 									heightPrev = heightPrev + $(this).height() + 20;
   445 									heightPrev = heightPrev + $(this).height() + 20;
   438 									SmallBoxesAnchos = SmallBoxesAnchos + $(this).height() + 20;
   446 									SmallBoxesAnchos = SmallBoxesAnchos + $(this).height() + 20;
   439 								}
   447 								}
   440 							})
   448 							});
   441 						})
   449 						});
   442 					} else {
   450 					} else {
   443 						clearInterval(ColorTimeInterval);
   451 						clearInterval(ColorTimeInterval);
   444 						SmallBoxesAnchos = SmallBoxesAnchos - ThisHeight;
   452 						SmallBoxesAnchos = SmallBoxesAnchos - ThisHeight;
   445 						if (typeof callback == "function") {
   453 						if (typeof callback === "function") {
   446 							if (callback) {
   454 							if (callback) {
   447 								callback();
   455 								callback();
   448 							}
   456 							}
   449 						}
   457 						}
   450 						$("#" + CurrentIDSmallbox).removeClass().addClass("SmallBox").animate({
   458 						$("#" + CurrentIDSmallbox).removeClass().addClass("SmallBox").animate({
   452 						}, 300, function () {
   460 						}, 300, function () {
   453 							$(this).remove();
   461 							$(this).remove();
   454 							var Primero = 1;
   462 							var Primero = 1;
   455 							var heightPrev = 0;
   463 							var heightPrev = 0;
   456 							$(".SmallBox").each(function (index) {
   464 							$(".SmallBox").each(function (index) {
   457 								if (index == 0) {
   465 								if (index === 0) {
   458 									$(this).animate({
   466 									$(this).animate({
   459 										top: 20
   467 										top: 20
   460 									}, 300);
   468 									}, 300);
   461 									heightPrev = $(this).height() + 40;
   469 									heightPrev = $(this).height() + 40;
   462 									SmallBoxesAnchos = $(this).height() + 40;
   470 									SmallBoxesAnchos = $(this).height() + 40;
   465 										top: heightPrev
   473 										top: heightPrev
   466 									});
   474 									});
   467 									heightPrev = heightPrev + $(this).height() + 20;
   475 									heightPrev = heightPrev + $(this).height() + 20;
   468 									SmallBoxesAnchos = SmallBoxesAnchos + $(this).height() + 20;
   476 									SmallBoxesAnchos = SmallBoxesAnchos + $(this).height() + 20;
   469 								}
   477 								}
   470 							})
   478 							});
   471 						});
   479 						});
   472 					}
   480 					}
   473 				}, settings.timeout)
   481 				}, settings.timeout);
   474 			}
   482 			}
   475 			$("#smallbox" + SmallBoxes).bind("click", function () {
   483 			$("#smallbox" + SmallBoxes).bind("click", function () {
   476 				clearInterval(ColorTimeInterval);
   484 				clearInterval(ColorTimeInterval);
   477 				if (typeof callback == "function") {
   485 				if (typeof callback === "function") {
   478 					if (callback) {
   486 					if (callback) {
   479 						callback();
   487 						callback();
   480 					}
   488 					}
   481 				}
   489 				}
   482 				var ThisHeight = $(this).height() + 20;
   490 				var ThisHeight = $(this).height() + 20;
   488 				}, 300, function () {
   496 				}, 300, function () {
   489 					$(this).remove();
   497 					$(this).remove();
   490 					var Primero = 1;
   498 					var Primero = 1;
   491 					var heightPrev = 0;
   499 					var heightPrev = 0;
   492 					$(".SmallBox").each(function (index) {
   500 					$(".SmallBox").each(function (index) {
   493 						if (index == 0) {
   501 						if (index === 0) {
   494 							$(this).animate({
   502 							$(this).animate({
   495 								top: 20
   503 								top: 20
   496 							}, 300);
   504 							}, 300);
   497 							heightPrev = $(this).height() + 40;
   505 							heightPrev = $(this).height() + 40;
   498 							SmallBoxesAnchos = $(this).height() + 40;
   506 							SmallBoxesAnchos = $(this).height() + 40;
   505 						}
   513 						}
   506 					});
   514 					});
   507 				});
   515 				});
   508 			});
   516 			});
   509 		}
   517 		}
   510 	}
   518 	};
   511 
   519 
   512 })(jQuery);
   520 })(jQuery, this);