Javascript-форум (https://javascript.ru/forum/)
-   jQuery (https://javascript.ru/forum/jquery/)
-   -   Помогите с уведомлениям. Пожалуйста. (https://javascript.ru/forum/jquery/56446-pomogite-s-uvedomleniyam-pozhalujjsta.html)

dezytube 16.06.2015 16:31

Помогите с уведомлениям. Пожалуйста.
 
Здравствуйте, помогите пожалуйста с Уведомлениями хочу сделать так что бы уведомления показывалось не при нажатие кнопки, а просто выскакивало и только один раз.
скачал скрипт вот здесь
А вот код Html

<button id="notification-trigger" class="progress-button">
<span class="content">Show Notification</span>
<span class="progress"></span>
</button>


И JS

<script>
			(function() {
				var bttn = document.getElementById( 'notification-trigger' );

				// make sure..
				bttn.disabled = false;

				bttn.addEventListener( 'click', function() {

						
						
						// create the notification
						var notification = new NotificationFx({
							message : '<span class="icon icon-settings"></span><p>Your preferences have been saved successfully. See all your settings in your <a href="#">profile overview</a>.</p>',
							layout : 'bar',
							effect : 'exploader',
							ttl : 9000000,
							type : 'notice', // notice, warning or error
							onClose : function() {
								bttn.disabled = false;
							}
						});

						// show the notification
						notification.show();

					
					
					// disable the button (for demo purposes only)
					this.disabled = true;
				} );
			})();
		</script>

рони 16.06.2015 18:19

notificationFx
 
dezytube,
так выкиньте всё что связано с кнопкой
<!DOCTYPE HTML>

<html>

<head>
  <title>Untitled</title>
  <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="http://tympanus.net/Development/NotificationStyles/css/demo.css">
  <link rel="stylesheet" type="text/css" href="http://tympanus.net/Development/NotificationStyles/css/ns-style-bar.css">
   <link rel="stylesheet" type="text/css" href="http://tympanus.net/Development/NotificationStyles/css/ns-default.css">
 <style type="text/css">
 body{
   background-color: rgb(0, 128, 128);
 }

 </style>
</head>

<body>


<script src="http://tympanus.net/Development/NotificationStyles/js/modernizr.custom.js"></script>
<script src="http://tympanus.net/Development/NotificationStyles/js/classie.js"></script>
<script src="http://tympanus.net/Development/NotificationStyles/js/notificationFx.js"></script>
<script>
			(function() {

						// create the notification
						var notification = new NotificationFx({
							message : '<span class="icon icon-settings"></span><p>Your preferences have been saved successfully. See all your settings in your <a href="#">profile overview</a>.</p>',
							layout : 'bar',
							effect : 'exploader',
							ttl : 9000000,
							type : 'notice', // notice, warning or error
							onClose : function() {

							}
						});

						// show the notification
						notification.show();


			})();
</script>
</body>
</html>

dezytube 16.06.2015 18:33

рони,
Спасибо но это я сделал я говорю о том как мне сделать что бы показывало только один раз что бы не напрягать гостя.

dd_smol 16.06.2015 18:36

cookie - флаг повести

рони 16.06.2015 19:47

cookie через localStorage показать 1 раз
 
dezytube,
в строке 37 установите время(месяц, год) через которое сообщение снова появится при заходе на сайт ... сейчас строит запрет на 20 секунд.
<!DOCTYPE HTML>

<html>

<head>
  <title>Untitled</title>
  <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="http://tympanus.net/Development/NotificationStyles/css/demo.css">
  <link rel="stylesheet" type="text/css" href="http://tympanus.net/Development/NotificationStyles/css/ns-style-bar.css">
   <link rel="stylesheet" type="text/css" href="http://tympanus.net/Development/NotificationStyles/css/ns-default.css">
 <style type="text/css">
 body{
   background-color: rgb(0, 128, 128);
 }
 </style>
</head>

<body>


<script src="http://tympanus.net/Development/NotificationStyles/js/modernizr.custom.js"></script>
<script src="http://tympanus.net/Development/NotificationStyles/js/classie.js"></script>
<script src="http://tympanus.net/Development/NotificationStyles/js/notificationFx.js"></script>
<script>
(function() {
    function show() {
        var notification = new NotificationFx({
            message: '<span class="icon icon-settings"></span><p>Your preferences have been saved successfully. See all your settings in your <a href="#">profile overview</a>.</p>',
            layout: "bar",
            effect: "exploader",
            ttl: 9E6,
            type: "notice",
            onClose: function() {}
        });
        notification.show()
    }
    var limit = 20 * 1E3; //24 * 3600 * 1000;  24 часа
    var localStorageInitTime = localStorage.getItem("localStorageInitTime");
    if (localStorageInitTime === null) {
        localStorage.setItem("localStorageInitTime", +new Date);
        show()
    } else if (+new Date - localStorageInitTime > limit) {
        localStorage.clear();
        localStorage.setItem("localStorageInitTime", +new Date);
        show()
    }
})();
</script>
</body>
</html>

dezytube 16.06.2015 22:53

рони,
Очень тебе благодарен..

dezytube 16.06.2015 22:59

рони,
Ты хороший человек..


Часовой пояс GMT +3, время: 02:15.