Nuevo sistema de notificaciones con toastr
This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.
-
-
Выглядит классно! Можно ли у вас попросить исходный код, если вы непротив? Я бы хотел его адаптировать под New-Star.
-
Yaro2709 wrote:
Выглядит классно! Можно ли у вас попросить исходный код, если вы непротив? Я бы хотел его адаптировать под New-Star.
-
Primero se debe añadir las librerías de toastr aqui les dejo los link para si lo necesitan toastr.
En ./scripts/game/base.js
JavaScript Source Code: base.js
- function alerta(type, msg, title) {
- var type = type;
- var msg = msg;
- var title = title;
- toastr[type](msg, title);
- }
- $(function() {
- window.setInterval(function() {
- $.ajax({
- type: 'POST',
- url: 'game.php?page=Util&ajax=1',
- data: '',
- success: function(data) {
- var data = JSON.parse(data);
- for (var i = 0; i <= data['i']; i++) {
- if (data['message'][i]) {
- //tipos de mensajes succes, info, warning, error
- switch (data['message'][i]['type']) {
- case '50':
- var type = 'success';
- break;
- default:
- var type = 'info';
- break;
- }
- alerta(type, data['message'][i]['texto'], data['message'][i]['name']);
- //Esto es para que no se repita la notificacion infinitamente
- var url = "game.php?page=Util&mode=notifi&ajax=1";
- var id = data['message'][i]['id'];
- $.ajax({
- type: 'POST',
- url: url,
- data: {mode:'notifi',id:id,ajaxReq:1},
- success: function(data)
- {
- console.log('se Notifico OK');
- }
- });
- }
- }
- return false;
- },
- });
- }, 1000);
- toastr.options = {
- "closeButton": true,
- "debug": true,
- "newestOnTop": true,
- "progressBar": true,
- "preventDuplicates": true,
- "onclick": null,
- "positionClass": "toast-top-right",
- "showDuration": "300",
- "hideDuration": "1000",
- "timeOut": "20000",
- "extendedTimeOut": "20000",
- "showEasing": "swing",
- "hideEasing": "linear",
- "showMethod": "fadeIn",
- "hideMethod": "fadeOut",
- "tapToDismiss": false,
- };
- });
Luego yo cree una pequeña pagina para realizar estas consultas
PHP Source Code: ShowUtilPage.class.php
- <?php
- class ShowUtilPage extends AbstractGamePage
- {
- public static $requireModule = 0;
- function __construct()
- {
- parent::__construct();
- $this->setWindow('ajax');
- }
- public function show()
- {
- global $USER, $PLANET, $resource, $reslist, $LNG, $pricelist, $THEME;
- $config = Config::get();
- $db = Database::get();
- $sql = "SELECT * FROM %%MESSAGES%% WHERE message_owner = :id AND message_unread = :unread AND notifi = 0 AND message_type != 0 AND message_type != 3;";
- $messages = $db->select($sql, array(
- ':unread' => 1,
- ':id' => $USER['id']
- ));
- $i = 0;
- $message = array();
- foreach ($messages as $mess) {
- $message[$i] = array(
- 'type' => $mess['message_type'],
- 'id' => $mess['message_id'],
- 'name' => $mess['message_from'],
- 'texto' => $mess['message_text'],
- );
- $i++;
- }
- $this->sendJSON(array('i' => $i, 'message' => $message));
- }
- function notifi()
- {
- $db = Database::get();
- $id = HTTP::_GP('id', 0);
- $sql = "UPDATE %%MESSAGES%% set notifi = 1 WHERE message_id = :message_id;";
- $db->update($sql, array(
- ':message_id' => $id,
- ));
- }
- }
Aquí les dejo los ficherosThe post was edited 2 times, last by Linkin ().
-
-
desde que conosco izitoast me encanto su forma de llevar a otro nivel las alertas, tambien otro sistema que esta interesante es SweetAlert2VERY SAD
-
SweetAlert2 también he pensado en incorporárselo a modo de confirmación para algunas acciones
-
Ala wrote:
SweetAlert2 también he pensado en incorporárselo a modo de confirmación para algunas acciones
Nice work
Recien implemente las alertas del xterium. pero es el mismo concepto de izitoast.VERY SAD -
-
Ambos son bastante fácil de implementar eso era un proyecto que tenia en curso de un 2moons rediseñado a lo Revolution que aún no termino
-
Share
- Facebook 0
- Twitter 0
- Google Plus 0
- Reddit 0