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]; |
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({ |
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> " + settings.title + "</span>"; |
235 boxBig += "<span><i class='" + settings.icon + "'></i> " + 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 |
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"); |
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; |