Browse Source

Move the Toast notifications to a proper Toast widget

Fix a few focusing issues in the notifications
Remove favico.js dependency
pull/978/head
Timothée Jaussoin 5 years ago
parent
commit
045f5a226b
  1. 3
      CHANGELOG.md
  2. 1
      app/views/accountnext.tpl
  3. 1
      app/views/chat.tpl
  4. 1
      app/views/community.tpl
  5. 1
      app/views/conf.tpl
  6. 1
      app/views/contact.tpl
  7. 1
      app/views/help.tpl
  8. 1
      app/views/login.tpl
  9. 1
      app/views/news.tpl
  10. 4
      app/views/page.tpl
  11. 1
      app/views/post.tpl
  12. 1
      app/views/publish.tpl
  13. 1
      app/views/tag.tpl
  14. 1
      app/widgets/About/about.tpl
  15. 12
      app/widgets/Account/Account.php
  16. 12
      app/widgets/AccountNext/AccountNext.php
  17. 2
      app/widgets/AdHoc/AdHoc.php
  18. 2
      app/widgets/Api/Api.php
  19. 4
      app/widgets/Avatar/Avatar.php
  20. 28
      app/widgets/Chat/Chat.php
  21. 12
      app/widgets/CommunitiesServer/CommunitiesServer.php
  22. 6
      app/widgets/CommunitiesServers/CommunitiesServers.php
  23. 6
      app/widgets/CommunityAffiliations/CommunityAffiliations.php
  24. 6
      app/widgets/CommunityConfig/CommunityConfig.php
  25. 8
      app/widgets/CommunityHeader/CommunityHeader.php
  26. 6
      app/widgets/Config/Config.php
  27. 6
      app/widgets/ContactActions/ContactActions.php
  28. 2
      app/widgets/LoginAnonymous/LoginAnonymous.php
  29. 2
      app/widgets/Navigation/Navigation.php
  30. 16
      app/widgets/Notification/Notification.php
  31. 19
      app/widgets/Notification/notification.js
  32. 4
      app/widgets/Onboarding/Onboarding.php
  33. 4
      app/widgets/Post/Post.php
  34. 4
      app/widgets/PostActions/PostActions.php
  35. 2
      app/widgets/Presence/Presence.php
  36. 10
      app/widgets/PublishBrief/PublishBrief.php
  37. 18
      app/widgets/Rooms/Rooms.php
  38. 8
      app/widgets/RoomsUtils/RoomsUtils.php
  39. 2
      app/widgets/SendTo/SendTo.php
  40. 17
      app/widgets/Toast/Toast.php
  41. 20
      app/widgets/Toast/toast.js
  42. 0
      app/widgets/Toast/toast.tpl
  43. 10
      app/widgets/Upload/Upload.php
  44. 16
      app/widgets/Vcard4/Vcard4.php
  45. 859
      public/scripts/favico.js
  46. 13
      public/scripts/movim_favicon.js
  47. 2
      src/Movim/Bootstrap.php

3
CHANGELOG.md

@ -39,6 +39,9 @@ v0.18 (trunk)
* Update XEP-0402 to urn:xmpp:bookmarks:1 and add xmpp:movim.eu/notifications:0 extension support
* Update meme and rage comic stickers pack
* Add a little indicator when saving draft in PublishBrief
* Create a new Toast widget
* Remove favico.js and rewrite it to a custom pure Javascript
* Fix some notifications issues
v0.17.1
---------------------------

1
app/views/accountnext.tpl

@ -1,4 +1,5 @@
<?php $this->widget('Notification');?>
<?php $this->widget('Toast');?>
<main>
<div>
<header>

1
app/views/chat.tpl

@ -1,5 +1,6 @@
<?php $this->widget('Search');?>
<?php $this->widget('Notification');?>
<?php $this->widget('Toast');?>
<?php $this->widget('VisioLink');?>
<?php $this->widget('Stickers');?>
<?php $this->widget('Notifications');?>

1
app/views/community.tpl

@ -1,5 +1,6 @@
<?php $this->widget('Search');?>
<?php $this->widget('Notification');?>
<?php $this->widget('Toast');?>
<?php $this->widget('VisioLink');?>
<?php $this->widget('Upload'); ?>
<?php $this->widget('Notifications');?>

1
app/views/conf.tpl

@ -1,6 +1,7 @@
<?php $this->widget('Search');?>
<?php $this->widget('VisioLink');?>
<?php $this->widget('Notification');?>
<?php $this->widget('Toast');?>
<?php $this->widget('Onboarding');?>
<?php $this->widget('Notifications');?>

1
app/views/contact.tpl

@ -1,4 +1,5 @@
<?php $this->widget('Notification');?>
<?php $this->widget('Toast');?>
<?php $this->widget('Search');?>
<?php $this->widget('VisioLink');?>
<?php $this->widget('PostActions');?>

1
app/views/help.tpl

@ -1,6 +1,7 @@
<?php $this->widget('Search');?>
<?php $this->widget('VisioLink');?>
<?php $this->widget('Notification');?>
<?php $this->widget('Toast');?>
<?php $this->widget('Notifications');?>
<nav class="color dark">

1
app/views/login.tpl

@ -1,4 +1,5 @@
<?php $this->widget('Notification');?>
<?php $this->widget('Toast');?>
<main>
<div>

1
app/views/news.tpl

@ -1,6 +1,7 @@
<?php $this->widget('Init');?>
<?php $this->widget('VisioLink');?>
<?php $this->widget('Notification');?>
<?php $this->widget('Toast');?>
<?php $this->widget('Upload');?>
<?php $this->widget('Search');?>
<?php $this->widget('Onboarding');?>

4
app/views/page.tpl

@ -8,11 +8,7 @@
<%meta%>
<meta name="application-name" content="<?php echo APP_TITLE; ?>">
<link rel="manifest" href="<?php echo \Movim\Route::urlize('manifest'); ?>" />
<!--<link rel="shortcut icon" href="<?php $this->linkFile('img/favicon.ico');?>" />-->
<!--<link rel="icon" type="image/png" href="<?php $this->linkFile('img/app/48.png');?>" sizes="48x48">
<link rel="icon" type="image/png" href="<?php $this->linkFile('img/app/96.png');?>" sizes="96x96">-->
<link rel="icon" type="image/png" href="<?php $this->linkFile('img/app/128.png');?>" sizes="128x128">
<!--<script src="<?php echo BASE_URI; ?>scripts/favico.js"></script>-->
<script src="<?php echo
\Movim\Route::urlize('system') .
'&t=' .

1
app/views/post.tpl

@ -1,6 +1,7 @@
<?php $this->widget('Init');?>
<?php $this->widget('VisioLink');?>
<?php $this->widget('Notification');?>
<?php $this->widget('Toast');?>
<?php $this->widget('Upload');?>
<?php $this->widget('Search');?>
<?php $this->widget('Notifications');?>

1
app/views/publish.tpl

@ -1,5 +1,6 @@
<?php $this->widget('Search');?>
<?php $this->widget('Notification');?>
<?php $this->widget('Toast');?>
<?php $this->widget('VisioLink');?>
<?php $this->widget('Upload'); ?>
<?php $this->widget('Notifications');?>

1
app/views/tag.tpl

@ -1,6 +1,7 @@
<?php if (isLogged()) { ?>
<?php $this->widget('Search');?>
<?php $this->widget('Notification');?>
<?php $this->widget('Toast');?>
<?php $this->widget('VisioLink');?>
<?php $this->widget('Notifications');?>
<?php $this->widget('SendTo');?>

1
app/widgets/About/about.tpl

@ -45,7 +45,6 @@
<p class="all">
Pako.js <a href="https://github.com/nodeca/pako">nodeca/pako
</a> under MIT<br />
Favico.js - Miroslav Magda <a href="http://lab.ejci.net/favico.js/">lab.ejci.net/favico.js</a> under GPL and MIT<br/>
Markdown - Michel Fortin <a href="http://michelf.ca/projects/php-markdown/">michelf.ca</a> ©Michel Fortin<br/>
Template Engine - RainTPL - Federico Ulfo <a href="http://www.raintpl.com/">www.raintpl.com</a> under MIT<br/>
Embed - Oscar Otero <a href="https://github.com/oscarotero/Embed">GitHub Embed</a> under MIT<br/>

12
app/widgets/Account/Account.php

@ -23,7 +23,7 @@ class Account extends \Movim\Widget\Base
public function onPasswordChanged()
{
$this->rpc('Account.resetPassword');
Notification::toast($this->__('account.password_changed'));
Toast::send($this->__('account.password_changed'));
$this->rpc('Presence_ajaxLogout');
}
@ -38,7 +38,7 @@ class Account extends \Movim\Widget\Base
public function onRegistered()
{
$this->rpc('MovimTpl.fill', '#account_gateways', $this->prepareGateways());
Notification::toast($this->__('client.registered'));
Toast::send($this->__('client.registered'));
}
public function onRegister($package)
@ -65,7 +65,7 @@ class Account extends \Movim\Widget\Base
public function onRegisterError($packet)
{
Notification::toast(
Toast::send(
$packet->content ??
$this->__('error.oops')
);
@ -89,11 +89,11 @@ class Account extends \Movim\Widget\Base
->request();
} else {
$this->rpc('Account.resetPassword');
Notification::toast($this->__('account.password_not_same'));
Toast::send($this->__('account.password_not_same'));
}
} else {
$this->rpc('Account.resetPassword');
Notification::toast($this->__('account.password_not_valid'));
Toast::send($this->__('account.password_not_valid'));
}
}
@ -123,7 +123,7 @@ class Account extends \Movim\Widget\Base
$da = new Remove;
$da->request();
} else {
Notification::toast($this->__('account.delete_text_error'));
Toast::send($this->__('account.delete_text_error'));
}
}

12
app/widgets/AccountNext/AccountNext.php

@ -58,28 +58,28 @@ class AccountNext extends \Movim\Widget\Base
public function onError()
{
Notification::toast($this->__('error.service_unavailable'));
Toast::send($this->__('error.service_unavailable'));
}
public function onRegisterError($package)
{
$error = $package->content;
Notification::toast($error);
Toast::send($error);
}
public function onForbidden()
{
Notification::toast($this->__('error.forbidden'));
Toast::send($this->__('error.forbidden'));
}
public function onRegisterNotAcceptable()
{
Notification::toast($this->__('error.not_acceptable'));
Toast::send($this->__('error.not_acceptable'));
}
public function onServiceUnavailable()
{
Notification::toast($this->__('error.service_unavailable'));
Toast::send($this->__('error.service_unavailable'));
requestAPI('disconnect', 2, ['sid' => SESSION_ID]);
@ -108,7 +108,7 @@ class AccountNext extends \Movim\Widget\Base
{
if (isset($form->re_password)
&& $form->re_password->value != $form->password->value) {
Notification::toast($this->__('account.password_not_same'));
Toast::send($this->__('account.password_not_same'));
return;
}

2
app/widgets/AdHoc/AdHoc.php

@ -53,7 +53,7 @@ class AdHoc extends \Movim\Widget\Base
$this->rpc('AdHoc.initForm');
} elseif ((string)$command->attributes()->status === 'completed') {
$this->rpc('Dialog.clear');
Notification::toast($this->__('adhoc.completed'));
Toast::send($this->__('adhoc.completed'));
return;
}
}

2
app/widgets/Api/Api.php

@ -17,7 +17,7 @@ class Api extends Base
if (isset($json) && $json->status == 200) {
$this->rpc('MovimUtils.reloadThis');
Notification::toast($this->__('api.conf_updated'));
Toast::send($this->__('api.conf_updated'));
}
}

4
app/widgets/Avatar/Avatar.php

@ -27,13 +27,13 @@ class Avatar extends \Movim\Widget\Base
public function onGetAvatar($packet)
{
$this->rpc('MovimTpl.fill', '#avatar_form', $this->prepareForm());
Notification::toast($this->__('avatar.updated'));
Toast::send($this->__('avatar.updated'));
}
public function onMyAvatarError()
{
$this->rpc('MovimTpl.fill', '#avatar_form', $this->prepareForm());
Notification::toast($this->__('avatar.not_updated'));
Toast::send($this->__('avatar.not_updated'));
}
public function prepareForm()

28
app/widgets/Chat/Chat.php

@ -74,16 +74,22 @@ class Chat extends \Movim\Widget\Base
public function onNotificationCounterClear($params)
{
list($page, $first, $room) = array_pad($params, 3, null);
list($page, $jid) = array_pad($params, 3, null);
if ($page === 'chat') {
$this->prepareMessages($first, ($room === 'room'), true);
// Check if the jid is a connected chatroom
$presence = $this->user->session->presences()
->where('jid', $jid)
->where('mucjid', $this->user->id)
->first();
$this->prepareMessages($jid, ($presence), true);
}
}
public function onPublishError($packet)
{
Notification::toast(
Toast::send(
$packet->content ??
$this->__('chat.publish_error')
);
@ -196,7 +202,7 @@ class Chat extends \Movim\Widget\Base
public function onMAMRetrieved()
{
Notification::toast($this->__('chat.mam_retrieval'));
Toast::send($this->__('chat.mam_retrieval'));
}
public function onMAMMucRetrieved($packet)
@ -215,7 +221,7 @@ class Chat extends \Movim\Widget\Base
public function onRoomConfigError($packet)
{
Notification::toast($packet->content);
Toast::send($packet->content);
}
public function onRoomConfig($packet)
@ -239,7 +245,7 @@ class Chat extends \Movim\Widget\Base
$r->setTo($packet->content)
->request();
Notification::toast($this->__('chatroom.config_saved'));
Toast::send($this->__('chatroom.config_saved'));
}
private function setState(string $jid, string $message, $first = true)
@ -341,7 +347,7 @@ class Chat extends \Movim\Widget\Base
}
$this->prepareMessages($room, true);
$this->rpc('Notification.current', 'chat|'.$room.'|room');
$this->rpc('Notification.current', 'chat|'.$room);
$this->rpc('Notification.clearAndroid', $this->route('chat', [$room, 'room']));
$this->rpc('Chat.scrollToSeparator');
} else {
@ -650,7 +656,7 @@ class Chat extends \Movim\Widget\Base
if ($messages->count() > 0) {
if ($prepend) {
Notification::toast($this->__('message.history', $messages->count()));
Toast::send($this->__('message.history', $messages->count()));
} else {
$messages = $messages->reverse();
}
@ -993,11 +999,9 @@ class Chat extends \Movim\Widget\Base
}
$message->icon = firstLetterCapitalize($message->resource);
}
if ($message->seen === false) {
$message->seen = ('chat|'.$message->jidfrom.'|room' == $n->getCurrent());
}
} elseif($message->seen === false) {
if($message->seen === false) {
$message->seen = ('chat|'.$message->jidfrom == $n->getCurrent());
}

12
app/widgets/CommunitiesServer/CommunitiesServer.php

@ -22,7 +22,7 @@ class CommunitiesServer extends \Movim\Widget\Base
public function onCreate($packet)
{
Notification::toast($this->__('communitiesserver.created'));
Toast::send($this->__('communitiesserver.created'));
list($origin, $node) = array_values($packet->content);
$this->ajaxDisco($origin);
@ -44,7 +44,7 @@ class CommunitiesServer extends \Movim\Widget\Base
$this->rpc('MovimTpl.fill', '#communities_server', $this->prepareCommunitiesServer($origin));
Notification::toast($this->__('communitiesserver.disco_error'));
Toast::send($this->__('communitiesserver.disco_error'));
}
public function onTestCreate($packet)
@ -59,13 +59,13 @@ class CommunitiesServer extends \Movim\Widget\Base
public function onTestCreateError($packet)
{
Notification::toast($this->__('communitiesserver.no_creation'));
Toast::send($this->__('communitiesserver.no_creation'));
}
public function ajaxDisco($origin)
{
if (!$this->validateServer($origin)) {
Notification::toast($this->__('communitiesserver.disco_error'));
Toast::send($this->__('communitiesserver.disco_error'));
return;
}
@ -95,7 +95,7 @@ class CommunitiesServer extends \Movim\Widget\Base
$validate_name = Validator::stringType()->length(4, 80);
if (!$validate_name->validate($form->name->value)) {
Notification::toast($this->__('communitiesserver.name_error'));
Toast::send($this->__('communitiesserver.name_error'));
return;
}
@ -103,7 +103,7 @@ class CommunitiesServer extends \Movim\Widget\Base
$uri = $slugify->slugify($form->name->value);
if ($uri == '') {
Notification::toast($this->__('communitiesserver.name_error'));
Toast::send($this->__('communitiesserver.name_error'));
return;
}

6
app/widgets/CommunitiesServers/CommunitiesServers.php

@ -18,7 +18,7 @@ class CommunitiesServers extends Base
public function onDisco($packet)
{
Notification::toast($this->__('communities.disco'));
Toast::send($this->__('communities.disco'));
$this->ajaxHttpGet();
}
@ -36,13 +36,13 @@ class CommunitiesServers extends Base
public function onDiscoError($packet)
{
Notification::toast($this->__('communities.disco_error'));
Toast::send($this->__('communities.disco_error'));
}
public function ajaxDisco($origin)
{
if (!$this->validateServer($origin)) {
Notification::toast($this->__('communities.disco_error'));
Toast::send($this->__('communities.disco_error'));
return;
}

6
app/widgets/CommunityAffiliations/CommunityAffiliations.php

@ -75,7 +75,7 @@ class CommunityAffiliations extends Base
public function onAffiliationsSet($packet)
{
Notification::toast($this->__('communityaffiliation.role_set'));
Toast::send($this->__('communityaffiliation.role_set'));
}
public function onSubscriptions($packet)
@ -97,7 +97,7 @@ class CommunityAffiliations extends Base
{
if ($packet->content['server'] != $this->user->id
&& substr($packet->content['node'], 0, 29) != 'urn:xmpp:microblog:0:comments') {
Notification::toast($this->__('communityaffiliation.deleted'));
Toast::send($this->__('communityaffiliation.deleted'));
$this->rpc(
'MovimUtils.redirect',
@ -111,7 +111,7 @@ class CommunityAffiliations extends Base
public function onDelete($packet)
{
Notification::toast($this->__('communityaffiliation.deleted'));
Toast::send($this->__('communityaffiliation.deleted'));
$this->deleted($packet);
}

6
app/widgets/CommunityConfig/CommunityConfig.php

@ -42,17 +42,17 @@ class CommunityConfig extends Base
public function onAvatarSet($packet)
{
$this->rpc('Dialog_ajaxClear');
Notification::toast($this->__('avatar.updated'));
Toast::send($this->__('avatar.updated'));
}
public function onConfigSaved()
{
Notification::toast($this->__('communityaffiliation.config_saved'));
Toast::send($this->__('communityaffiliation.config_saved'));
}
public function onConfigError($packet)
{
Notification::toast(
Toast::send(
$packet->content ??
$this->__('communityaffiliation.config_error')
);

8
app/widgets/CommunityHeader/CommunityHeader.php

@ -43,7 +43,7 @@ class CommunityHeader extends Base
public function onTestPublishError($packet)
{
Notification::toast($this->__('publishbrief.no_publication'));
Toast::send($this->__('publishbrief.no_publication'));
}
public function onSubscribed($packet)
@ -52,12 +52,12 @@ class CommunityHeader extends Base
$this->ajaxGetMetadata($origin, $node);
Notification::toast($this->__('communityheader.subscribed'));
Toast::send($this->__('communityheader.subscribed'));
}
public function onSubscriptionUnsupported($packet)
{
Notification::toast($this->__('communityheader.subscription_unsupported'));
Toast::send($this->__('communityheader.subscription_unsupported'));
}
public function onUnsubscribed($packet)
@ -66,7 +66,7 @@ class CommunityHeader extends Base
$this->ajaxGetMetadata($origin, $node);
Notification::toast($this->__('communityheader.unsubscribed'));
Toast::send($this->__('communityheader.unsubscribed'));
}
public function ajaxGetMetadata($origin, $node)

6
app/widgets/Config/Config.php

@ -39,7 +39,7 @@ class Config extends Base
$this->refreshConfig();
Notification::toast($this->__('config.updated'));
Toast::send($this->__('config.updated'));
}
public function onMAMConfig($package)
@ -51,7 +51,7 @@ class Config extends Base
public function onMAMConfigSaved()
{
Notification::toast($this->__('config.mam_saved'));
Toast::send($this->__('config.mam_saved'));
}
public function ajaxMAMGetConfig()
@ -72,7 +72,7 @@ class Config extends Base
{
if (!$this->validateForm($data)) {
$this->refreshConfig();
Notification::toast($this->__('config.not_valid'));
Toast::send($this->__('config.not_valid'));
return;
}

6
app/widgets/ContactActions/ContactActions.php

@ -18,17 +18,17 @@ class ContactActions extends Base
public function onDelete($packet)
{
Notification::toast($this->__('roster.deleted'));
Toast::send($this->__('roster.deleted'));
}
public function onAdd($packet)
{
Notification::toast($this->__('roster.added'));
Toast::send($this->__('roster.added'));
}
public function onUpdate($packet = false)
{
Notification::toast($this->__('roster.updated'));
Toast::send($this->__('roster.updated'));
}
public function ajaxAddAsk($jid)

2
app/widgets/LoginAnonymous/LoginAnonymous.php

@ -25,7 +25,7 @@ class LoginAnonymous extends Base
{
$validate_user = Validator::stringType()->length(4, 40);
if (!$validate_user->validate($username)) {
Notification::toast($this->__('login_anonymous.bad_username'));
Toast::send($this->__('login_anonymous.bad_username'));
return;
}

2
app/widgets/Navigation/Navigation.php

@ -23,7 +23,7 @@ class Navigation extends Base
public function display()
{
$this->view->assign('page', $this->_view);
$this->view->assign('chatCounter', $this->prepareChatButton($this->user->unreads(null, false, true)));
$this->view->assign('chatCounter', $this->prepareChatButton($this->user->unreads(null, true, true)));
}
private function prepareChatButton(int $count = 0)

16
app/widgets/Notification/Notification.php

@ -21,11 +21,6 @@ class Notification extends Base
RPC::call('Notification.counter', 'chat', $user->unreads(null, true));
}
public static function toast($title)
{
RPC::call('Notification.toast', $title);
}
public static function rpcCall($rpc)
{
self::$rpcCall = $rpc;
@ -183,12 +178,8 @@ class Notification extends Base
$session = Session::start();
$notifs = $session->get('notifs') ?? [];
$chatCount = (\App\User::me())->unreads(null, true, true);
if ($chatCount) $notifs['chat'] = $chatCount;
if (!empty($notifs)) {
RPC::call('Notification.refresh', $notifs);
}
$notifs['chat'] = (\App\User::me())->unreads(null, true, true);
RPC::call('Notification.refresh', $notifs);
}
/**
@ -199,6 +190,9 @@ class Notification extends Base
*/
public function ajaxCurrent($key)
{
// Clear the specific keys
if (strpos($key, '|') !== false) (new Notification)->ajaxClear($key);
$session = Session::start();
// If the page was blurred

19
app/widgets/Notification/notification.js

@ -52,7 +52,6 @@ var Notification = {
sec*1000);
},
refresh : function(keys) {
console.log(keys);
var counters = document.querySelectorAll('.counter');
for(i = 0; i < counters.length; i++) {
var n = counters[i];
@ -123,24 +122,6 @@ var Notification = {
Notification.notifs_key = key;
Notification_ajaxCurrent(Notification.notifs_key);
},
toast : function(title) {
// Android notification
if (typeof Android !== 'undefined') {
Android.showToast(title);
return;
}
target = document.getElementById('toast');
if (target) {
target.innerHTML = title;
}
setTimeout(function() {
target = document.getElementById('toast');
target.innerHTML = '';
}, 3000);
},
snackbar : function(html, time) {
if (typeof Android !== 'undefined'
|| Notification.inhibed == true) return;

4
app/widgets/Onboarding/Onboarding.php

@ -30,12 +30,12 @@ class Onboarding extends Base
public function ajaxEnablePublic()
{
$this->user->setPublic();
Notification::toast($this->__('vcard.public'));
Toast::send($this->__('vcard.public'));
}
public function ajaxEnableRestricted()
{
$this->user->setPrivate();
Notification::toast($this->__('vcard.restricted'));
Toast::send($this->__('vcard.restricted'));
}
}

4
app/widgets/Post/Post.php

@ -48,14 +48,14 @@ class Post extends Base
public function onCommentPublished($packet)
{
$isLike = $packet->content;
Notification::toast($isLike
Toast::send($isLike
? $this->__('post.comment_like_published')
: $this->__('post.comment_published'));
}
public function onCommentPublishError()
{
Notification::toast($this->__('post.comment_publish_error'));
Toast::send($this->__('post.comment_publish_error'));
}
public function onComments($packet)

4
app/widgets/PostActions/PostActions.php

@ -33,9 +33,9 @@ class PostActions extends Base
list($server, $node, $id) = array_values($packet->content);
if (substr($node, 0, 29) == 'urn:xmpp:microblog:0:comments') {
Notification::toast($this->__('post.comment_deleted'));
Toast::send($this->__('post.comment_deleted'));
} else {
Notification::toast($this->__('post.deleted'));
Toast::send($this->__('post.deleted'));
$this->rpc(
'PostActions.handleDelete',

2
app/widgets/Presence/Presence.php

@ -41,7 +41,7 @@ class Presence extends Base
public function onMyPresence($packet)
{
$this->rpc('MovimTpl.fill', '#presence_widget', $this->preparePresence());
Notification::toast($this->__('status.updated'));
Toast::send($this->__('status.updated'));
}
public function start()

10
app/widgets/PublishBrief/PublishBrief.php

@ -25,7 +25,7 @@ class PublishBrief extends Base
public function onPublish($packet)
{
Notification::toast($this->__('post.published'));
Toast::send($this->__('post.published'));
list($to, $node, $id, $repost, $comments) = array_values($packet->content);
@ -111,7 +111,7 @@ class PublishBrief extends Base
Dialog::fill($view->draw('_publishbrief_preview'), true);
} else {
Notification::toast($this->__('publishbrief.no_content_preview'));
Toast::send($this->__('publishbrief.no_content_preview'));
}
}
@ -233,7 +233,7 @@ class PublishBrief extends Base
$this->ajaxGet();
} else {
$this->rpc('PublishBrief.enableSend');
Notification::toast($this->__('publishbrief.no_title'));
Toast::send($this->__('publishbrief.no_title'));
}
}
@ -255,7 +255,7 @@ class PublishBrief extends Base
}
if (!Validator::url()->validate($url)) {
Notification::toast($this->__('publishbrief.valid_url'));
Toast::send($this->__('publishbrief.valid_url'));
$this->ajaxClearEmbed();
return;
}
@ -380,7 +380,7 @@ class PublishBrief extends Base
public function ajaxDisplayPrivacy($open)
{
Notification::toast(($open)
Toast::send(($open)
? $this->__('post.public_yes')
: $this->__('post.public_no'));
}

18
app/widgets/Rooms/Rooms.php

@ -68,7 +68,7 @@ class Rooms extends Base
$this->ajaxHttpGet();
$this->rpc('Chat_ajaxGet');
Notification::toast($this->__('chatrooms.destroyed'));
Toast::send($this->__('chatrooms.destroyed'));
}
public function onConnected($packet)
@ -80,7 +80,7 @@ class Rooms extends Base
public function onDisconnected($packet)
{
$this->onPresence($packet->content);
Notification::toast($this->__('chatrooms.disconnected'));
Toast::send($this->__('chatrooms.disconnected'));
}
public function onBookmarkGet($packet)
@ -98,7 +98,7 @@ class Rooms extends Base
public function onBookmarkSynchronized($packet)
{
Notification::toast($this->__('chatrooms.synchronized', $packet->content));
Toast::send($this->__('chatrooms.synchronized', $packet->content));
}
public function onBookmarkSet($packet)
@ -109,7 +109,7 @@ class Rooms extends Base
$this->ajaxJoin($conference->conference, $conference->nick);
}
Notification::toast($this->__('bookmarks.updated'));
Toast::send($this->__('bookmarks.updated'));
$this->ajaxHttpGet();
}
@ -305,30 +305,30 @@ class Rooms extends Base
public function onConflict()
{
Notification::toast($this->__('chatrooms.conflict'));
Toast::send($this->__('chatrooms.conflict'));
}
public function onRegistrationRequired($packet)
{
Notification::toast($this->__('chatrooms.registrationrequired'));
Toast::send($this->__('chatrooms.registrationrequired'));
$this->ajaxExit($packet->content);
}
public function onRemoteServerNotFound($packet)
{
Notification::toast($this->__('chatrooms.remoteservernotfound'));
Toast::send($this->__('chatrooms.remoteservernotfound'));
$this->ajaxExit($packet->content);
}
public function onItemNotFound($packet)
{
Notification::toast($this->__('chatrooms.itemnotfound'));
Toast::send($this->__('chatrooms.itemnotfound'));
$this->ajaxExit($packet->content);
}
public function onNotAuthorized($packet)
{
Notification::toast($this->__('chatrooms.notauthorized'));
Toast::send($this->__('chatrooms.notauthorized'));
$this->ajaxExit($packet->content);
}

8
app/widgets/RoomsUtils/RoomsUtils.php

@ -99,7 +99,7 @@ class RoomsUtils extends Base
public function onAvatarSet($packet)
{
$this->rpc('Dialog_ajaxClear');
Notification::toast($this->__('avatar.updated'));
Toast::send($this->__('avatar.updated'));
}
/**
@ -193,9 +193,9 @@ class RoomsUtils extends Base
public function ajaxAddConfirm($form)
{
if (!$this->validateRoom($form->jid->value)) {
Notification::toast($this->__('chatrooms.bad_id'));
Toast::send($this->__('chatrooms.bad_id'));
} elseif (trim($form->name->value) == '') {
Notification::toast($this->__('chatrooms.empty_name'));
Toast::send($this->__('chatrooms.empty_name'));
} else {
$this->rpc('Rooms_ajaxExit', $form->jid->value);
@ -272,7 +272,7 @@ class RoomsUtils extends Base
->setInvite($form->invite->value)
->request();
Notification::toast($this->__('room.invited'));
Toast::send($this->__('room.invited'));
$this->rpc('Dialog_ajaxClear');
}
}

2
app/widgets/SendTo/SendTo.php

@ -56,7 +56,7 @@ class SendTo extends Base
{
$file->type = 'xmpp';
Notification::toast($muc
Toast::send($muc
? $this->__('sendto.shared_chatroom')
: $this->__('sendto.shared_contact')
);

17
app/widgets/Toast/Toast.php

@ -0,0 +1,17 @@
<?php
use Movim\Widget\Base;
use Movim\RPC;
class Toast extends Base
{
public function load()
{
$this->addjs('toast.js');
}
public static function send($title)
{
RPC::call('Toast.send', $title);
}
}

20
app/widgets/Toast/toast.js

@ -0,0 +1,20 @@
var Toast = {
send : function(title) {
// Android notification
if (typeof Android !== 'undefined') {
Android.showToast(title);
return;
}
target = document.getElementById('toast');
if (target) {
target.innerHTML = title;
}
setTimeout(function() {
target = document.getElementById('toast');
target.innerHTML = '';
}, 3000);
}
}

0
app/widgets/Notification/notification.tpl → app/widgets/Toast/toast.tpl

10
app/widgets/Upload/Upload.php

@ -30,22 +30,22 @@ class Upload extends Base
public function onError()
{
Notification::toast($this->__('upload.error_failed'));
Toast::send($this->__('upload.error_failed'));
}
public function onErrorFileTooLarge()
{
Notification::toast($this->__('upload.error_filesize'));
Toast::send($this->__('upload.error_filesize'));
}
public function onErrorResourceConstraint()
{
Notification::toast($this->__('upload.error_resource_constraint'));
Toast::send($this->__('upload.error_resource_constraint'));
}
public function onErrorNotAllowed()
{
Notification::toast($this->__('upload.error_not_allowed'));
Toast::send($this->__('upload.error_not_allowed'));
}
public function ajaxRequest()
@ -72,6 +72,6 @@ class Upload extends Base
public function ajaxFailed()
{
Notification::toast($this->__('upload.error_failed'));
Toast::send($this->__('upload.error_failed'));
}
}

16
app/widgets/Vcard4/Vcard4.php

@ -34,7 +34,7 @@ class Vcard4 extends Base
{
$html = $this->prepareForm($packet->content);
Notification::toast($this->__('vcard.updated'));
Toast::send($this->__('vcard.updated'));
$this->rpc('MovimTpl.fill', '#vcard_form', $html);
$this->rpc('MovimUtils.applyAutoheight');
@ -42,12 +42,12 @@ class Vcard4 extends Base
public function onMyVcard4Received()
{
Notification::toast($this->__('vcard.updated'));
Toast::send($this->__('vcard.updated'));
}
public function onMyVcard4NotReceived()
{
Notification::toast($this->__('vcard.not_updated'));
Toast::send($this->__('vcard.not_updated'));
}
public function ajaxGetVcard()
@ -115,7 +115,7 @@ class Vcard4 extends Base
{
if (Validator::regex('/^[a-z_\-\d]{3,64}$/i')->validate($nickname)) {
if (\App\User::where('nickname', $nickname)->where('id', '!=', $this->user->id)->first()) {
Notification::toast($this->__('profile.nickname_conflict'));
Toast::send($this->__('profile.nickname_conflict'));
return;
}
@ -124,9 +124,9 @@ class Vcard4 extends Base
$this->ajaxGetVcard();
(new Dialog)->ajaxClear();
Notification::toast($this->__('profile.nickname_saved'));
Toast::send($this->__('profile.nickname_saved'));
} else {
Notification::toast($this->__('profile.nickname_error'));
Toast::send($this->__('profile.nickname_error'));
}
}
@ -134,10 +134,10 @@ class Vcard4 extends Base
{
if ($value == true) {
$this->user->setPublic();
Notification::toast($this->__('vcard.public'));
Toast::send($this->__('vcard.public'));
} else {
$this->user->setPrivate();
Notification::toast($this->__('vcard.restricted'));
Toast::send($this->__('vcard.restricted'));
}
}

859
public/scripts/favico.js

@ -1,859 +0,0 @@
/**
* @license MIT or GPL-2.0
* @fileOverview Favico animations
* @author Miroslav Magda, http://blog.ejci.net
* @version 0.3.10
*/
/**
* Create new favico instance
* @param {Object} Options
* @return {Object} Favico object
* @example
* var favico = new Favico({
* bgColor : '#d00',
* textColor : '#fff',
* fontFamily : 'sans-serif',
* fontStyle : 'bold',
* position : 'down',
* type : 'circle',
* animation : 'slide',
* dataUrl: function(url) {},
* win: top
* });
*/
(function () {
var Favico = (function (opt) {
'use strict';
opt = (opt) ? opt : {};
var _def = {
bgColor: '#d00',
textColor: '#fff',
fontFamily: 'sans-serif', //Arial,Verdana,Times New Roman,serif,sans-serif,...
fontStyle: 'bold', //normal,italic,oblique,bold,bolder,lighter,100,200,300,400,500,600,700,800,900
type: 'circle',
position: 'down', // down, up, left, leftup (upleft)
animation: 'slide',
elementId: false,
dataUrl: false,
win: window
};
var _opt, _orig, _h, _w, _canvas, _context, _img, _ready, _lastBadge, _running, _readyCb, _stop, _browser, _animTimeout, _drawTimeout, _doc;
_browser = {};
_browser.ff = typeof InstallTrigger != 'undefined';
_browser.chrome = !!window.chrome;
_browser.opera = !!window.opera || navigator.userAgent.indexOf('Opera') >= 0;
_browser.ie = /*@cc_on!@*/false;
_browser.safari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
_browser.supported = (_browser.chrome || _browser.ff || _browser.opera);
var _queue = [];
_readyCb = function () {
};
_ready = _stop = false;
/**
* Initialize favico
*/
var init = function () {
//merge initial options
_opt = merge(_def, opt);
_opt.bgColor = hexToRgb(_opt.bgColor);
_opt.textColor = hexToRgb(_opt.textColor);
_opt.position = _opt.position.toLowerCase();
_opt.animation = (animation.types['' + _opt.animation]) ? _opt.animation : _def.animation;
_doc = _opt.win.document;
var isUp = _opt.position.indexOf('up') > -1;
var isLeft = _opt.position.indexOf('left') > -1;
//transform the animations
if (isUp || isLeft) {
for (var a in animation.types) {
for (var i = 0; i < animation.types[a].length; i++) {
var step = animation.types[a][i];
if (isUp) {
if (step.y < 0.6) {
step.y = step.y - 0.4;
} else {
step.y = step.y - 2 * step.y + (1 - step.w);
}
}
if (isLeft) {
if (step.x < 0.6) {
step.x = step.x - 0.4;
} else {
step.x = step.x - 2 * step.x + (1 - step.h);
}
}
animation.types[a][i] = step;
}
}
}
_opt.type = (type['' + _opt.type]) ? _opt.type : _def.type;
_orig = link.getIcon();
//create temp canvas
_canvas = document.createElement('canvas');
//create temp image
_img = document.createElement('img');
if (_orig.hasAttribute('href')) {
_img.setAttribute('crossOrigin', 'anonymous');
//get width/height
_img.onload = function () {
_h = (_img.height > 0) ? _img.height : 32;
_w = (_img.width > 0) ? _img.width : 32;
_canvas.height = _h;
_canvas.width = _w;
_context = _canvas.getContext('2d');
icon.ready();
};
_img.setAttribute('src', _orig.getAttribute('href'));
} else {
_img.onload = function () {
_h = 32;
_w = 32;
_img.height = _h;
_img.width = _w;
_canvas.height = _h;
_canvas.width = _w;
_context = _canvas.getContext('2d');
icon.ready();
};
_img.setAttribute('src', '');
}
};
/**
* Icon namespace
*/
var icon = {};
/**
* Icon is ready (reset icon) and start animation (if ther is any)
*/
icon.ready = function () {
_ready = true;
icon.reset();
_readyCb();
};
/**
* Reset icon to default state
*/
icon.reset = function () {
//reset
if (!_ready) {
return;
}
_queue = [];
_lastBadge = false;
_running = false;
_context.clearRect(0, 0, _w, _h);
_context.drawImage(_img, 0, 0, _w, _h);
//_stop=true;
link.setIcon(_canvas);
//webcam('stop');
//video('stop');
window.clearTimeout(_animTimeout);
window.clearTimeout(_drawTimeout);
};
/**
* Start animation
*/
icon.start = function () {
if (!_ready || _running) {
return;
}
var finished = function () {
_lastBadge = _queue[0];
_running = false;
if (_queue.length > 0) {
_queue.shift();
icon.start();
} else {
}
};
if (_queue.length > 0) {
_running = true;
var run = function () {
// apply options for this animation
['type', 'animation', 'bgColor', 'textColor', 'fontFamily', 'fontStyle'].forEach(function (a) {
if (a in _queue[0].options) {
_opt[a] = _queue[0].options[a];
}
});
animation.run(_queue[0].options, function () {
finished();
}, false);
};
if (_lastBadge) {
animation.run(_lastBadge.options, function () {
run();
}, true);
} else {
run();
}
}
};
/**
* Badge types
*/
var type = {};
var options = function (opt) {
opt.n = ((typeof opt.n) === 'number') ? Math.abs(opt.n | 0) : opt.n;
opt.x = _w * opt.x;
opt.y = _h * opt.y;
opt.w = _w * opt.w;
opt.h = _h * opt.h;
opt.len = ("" + opt.n).length;
return opt;
};
/**
* Generate circle
* @param {Object} opt Badge options
*/
type.circle = function (opt) {
opt = options(opt);
var more = false;
if (opt.len === 2) {
opt.x = opt.x - opt.w * 0.4;
opt.w = opt.w * 1.4;
more = true;
} else if (opt.len >= 3) {
opt.x = opt.x - opt.w * 0.65;
opt.w = opt.w * 1.65;
more = true;
}
_context.clearRect(0, 0, _w, _h);
_context.drawImage(_img, 0, 0, _w, _h);
_context.beginPath();
_context.font = _opt.fontStyle + " " + Math.floor(opt.h * (opt.n > 99 ? 0.85 : 1)) + "px " + _opt.fontFamily;
_context.textAlign = 'center';
if (more) {
_context.moveTo(opt.x + opt.w / 2, opt.y);
_context.lineTo(opt.x + opt.w - opt.h / 2, opt.y);
_context.quadraticCurveTo(opt.x + opt.w, opt.y, opt.x + opt.w, opt.y + opt.h / 2);
_context.lineTo(opt.x + opt.w, opt.y + opt.h - opt.h / 2);
_context.quadraticCurveTo(opt.x + opt.w, opt.y + opt.h, opt.x + opt.w - opt.h / 2, opt.y + opt.h);
_context.lineTo(opt.x + opt.h / 2, opt.y + opt.h);
_context.quadraticCurveTo(opt.x, opt.y + opt.h, opt.x, opt.y + opt.h - opt.h / 2);
_context.lineTo(opt.x, opt.y + opt.h / 2);
_context.quadraticCurveTo(opt.x, opt.y, opt.x + opt.h / 2, opt.y);
} else {
_context.arc(opt.x + opt.w / 2, opt.y + opt.h / 2, opt.h / 2, 0, 2 * Math.PI);
}
_context.fillStyle = 'rgba(' + _opt.bgColor.r + ',' + _opt.bgColor.g + ',' + _opt.bgColor.b + ',' + opt.o + ')';
_context.fill();
_context.closePath();
_context.beginPath();
_context.stroke();
_context.fillStyle = 'rgba(' + _opt.textColor.r + ',' + _opt.textColor.g + ',' + _opt.textColor.b + ',' + opt.o + ')';
//_context.fillText((more) ? '9+' : opt.n, Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.15));
if ((typeof opt.n) === 'number' && opt.n > 999) {
_context.fillText(((opt.n > 9999) ? 9 : Math.floor(opt.n / 1000)) + 'k+', Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.2));
} else {
_context.fillText(opt.n, Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.15));
}
_context.closePath();
};
/**
* Generate rectangle
* @param {Object} opt Badge options
*/
type.rectangle = function (opt) {
opt = options(opt);
var more = false;
if (opt.len === 2) {
opt.x = opt.x - opt.w * 0.4;
opt.w = opt.w * 1.4;
more = true;
} else if (opt.len >= 3) {
opt.x = opt.x - opt.w * 0.65;
opt.w = opt.w * 1.65;
more = true;
}
_context.clearRect(0, 0, _w, _h);
_context.drawImage(_img, 0, 0, _w, _h);
_context.beginPath();
_context.font = _opt.fontStyle + " " + Math.floor(opt.h * (opt.n > 99 ? 0.9 : 1)) + "px " + _opt.fontFamily;
_context.textAlign = 'center';
_context.fillStyle = 'rgba(' + _opt.bgColor.r + ',' + _opt.bgColor.g + ',' + _opt.bgColor.b + ',' + opt.o + ')';
_context.fillRect(opt.x, opt.y, opt.w, opt.h);
_context.fillStyle = 'rgba(' + _opt.textColor.r + ',' + _opt.textColor.g + ',' + _opt.textColor.b + ',' + opt.o + ')';
//_context.fillText((more) ? '9+' : opt.n, Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.15));
if ((typeof opt.n) === 'number' && opt.n > 999) {
_context.fillText(((opt.n > 9999) ? 9 : Math.floor(opt.n / 1000)) + 'k+', Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.2));
} else {
_context.fillText(opt.n, Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.15));
}
_context.closePath();
};
/**
* Set badge
*/
var badge = function (number, opts) {
opts = ((typeof opts) === 'string' ? {
animation: opts
} : opts) || {};
_readyCb = function () {
try {
if (typeof (number) === 'number' ? (number > 0) : (number !== '')) {
var q = {
type: 'badge',
options: {
n: number
}
};
if ('animation' in opts && animation.types['' + opts.animation]) {
q.options.animation = '' + opts.animation;
}
if ('type' in opts && type['' + opts.type]) {
q.options.type = '' + opts.type;
}
['bgColor', 'textColor'].forEach(function (o) {
if (o in opts) {
q.options[o] = hexToRgb(opts[o]);
}
});
['fontStyle', 'fontFamily'].forEach(function (o) {
if (o in opts) {
q.options[o] = opts[o];
}
});
_queue.push(q);
if (_queue.length > 100) {
throw new Error('Too many badges requests in queue.');
}
icon.start();
} else {
icon.reset();
}
} catch (e) {
throw new Error('Error setting badge. Message: ' + e.message);
}
};
if (_ready) {
_readyCb();
}
};
/**
* Set image as icon
*/
var image = function (imageElement) {
_readyCb = function () {
try {
var w = imageElement.width;
var h = imageElement.height;
var newImg = document.createElement('img');
var ratio = (w / _w < h / _h) ? (w / _w) : (h / _h);
newImg.setAttribute('crossOrigin', 'anonymous');
newImg.onload=function() {
_context.clearRect(0, 0, _w, _h);
_context.drawImage(newImg, 0, 0, _w, _h);
link.setIcon(_canvas);
};
newImg.setAttribute('src', imageElement.getAttribute('src'));
newImg.height = (h / ratio);
newImg.width = (w / ratio);
} catch (e) {
throw new Error('Error setting image. Message: ' + e.message);
}
};
if (_ready) {
_readyCb();
}
};
/**
* Set video as icon
*/
var video = function (videoElement) {
_readyCb = function () {
try {
if (videoElement === 'stop') {
_stop = true;
icon.reset();
_stop = false;
return;
}
//var w = videoElement.width;
//var h = videoElement.height;
//var ratio = (w / _w < h / _h) ? (w / _w) : (h / _h);
videoElement.addEventListener('play', function () {
drawVideo(this);
}, false);
} catch (e) {
throw new Error('Error setting video. Message: ' + e.message);
}
};
if (_ready) {
_readyCb();
}
};
/**
* Set video as icon
*/
var webcam = function (action) {
//UR
if (!window.URL || !window.URL.createObjectURL) {
window.URL = window.URL || {};
window.URL.createObjectURL = function (obj) {
return obj;
};
}
if (_browser.supported) {
var newVideo = false;
navigator.getUserMedia = navigator.getUserMedia || navigator.oGetUserMedia || navigator.msGetUserMedia || navigator.mozGetUserMedia || navigator.webkitGetUserMedia;
_readyCb = function () {
try {
if (action === 'stop') {
_stop = true;
icon.reset();
_stop = false;
return;
}
newVideo = document.createElement('video');
newVideo.width = _w;
newVideo.height = _h;
navigator.getUserMedia({
video: true,
audio: false
}, function (stream) {
newVideo.src = URL.createObjectURL(stream);
newVideo.play();
drawVideo(newVideo);
}, function () {
});
} catch (e) {
throw new Error('Error setting webcam. Message: ' + e.message);
}
};
if (_ready) {
_readyCb();
}
}
};
/**
* Draw video to context and repeat :)
*/
function drawVideo(video) {
if (video.paused || video.ended || _stop) {
return false;
}
//nasty hack for FF webcam (Thanks to Julian Ćwirko, kontakt@redsunmedia.pl)
try {
_context.clearRect(0, 0, _w, _h);
_context.drawImage(video, 0, 0, _w, _h);
} catch (e) {
}
_drawTimeout = setTimeout(function () {
drawVideo(video);
}, animation.duration);
link.setIcon(_canvas);
}
var link = {};
/**
* Get icon from HEAD tag or create a new <link> element
*/
link.getIcon = function () {
var elm = false;
//get link element
var getLink = function () {
var link = _doc.getElementsByTagName('head')[0].getElementsByTagName('link');
for (var l = link.length, i = (l - 1); i >= 0; i--) {
if ((/(^|\s)icon(\s|$)/i).test(link[i].getAttribute('rel'))) {
return link[i];
}
}
return false;
};
if (_opt.element) {
elm = _opt.element;
} else if (_opt.elementId) {
//if img element identified by elementId
elm = _doc.getElementById(_opt.elementId);
elm.setAttribute('href', elm.getAttribute('src'));
} else {
//if link element
elm = getLink();
if (elm === false) {
elm = _doc.createElement('link');
elm.setAttribute('rel', 'icon');
_doc.getElementsByTagName('head')[0].appendChild(elm);
}
}
elm.setAttribute('type', 'image/png');
return elm;
};
link.setIcon = function (canvas) {
var url = canvas.toDataURL('image/png');
if (_opt.dataUrl) {
//if using custom exporter
_opt.dataUrl(url);
}
if (_opt.element) {
_opt.element.setAttribute('href', url);
_opt.element.setAttribute('src', url);
} else if (_opt.elementId) {
//if is attached to element (image)
var elm = _doc.getElementById(_opt.elementId);
elm.setAttribute('href', url);
elm.setAttribute('src', url);
} else {
//if is attached to fav icon
if (_browser.ff || _browser.opera) {
//for FF we need to "recreate" element, atach to dom and remove old <link>
//var originalType = _orig.getAttribute('rel');
var old = _orig;
_orig = _doc.createElement('link');
//_orig.setAttribute('rel', originalType);
if (_browser.opera) {
_orig.setAttribute('rel', 'icon');
}
_orig.setAttribute('rel', 'icon');
_orig.setAttribute('type', 'image/png');
_doc.getElementsByTagName('head')[0].appendChild(_orig);
_orig.setAttribute('href', url);
if (old.parentNode) {
old.parentNode.removeChild(old);
}
} else {
_orig.setAttribute('href', url);
}
}
};
//http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb#answer-5624139
//HEX to RGB convertor
function hexToRgb(hex) {
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, function (m, r, g, b) {
return r + r + g + g + b + b;
});
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : false;
}
/**
* Merge options
*/
function merge(def, opt) {
var mergedOpt = {};
var attrname;
for (attrname in def) {
mergedOpt[attrname] = def[attrname];
}
for (attrname in opt) {
mergedOpt[attrname] = opt[attrname];
}
return mergedOpt;
}
/**
* Cross-browser page visibility shim
* http://stackoverflow.com/questions/12536562/detect-whether-a-window-is-visible
*/
function isPageHidden() {
return _doc.hidden || _doc.msHidden || _doc.webkitHidden || _doc.mozHidden;
}
/**
* @namespace animation
*/
var animation = {};
/**
* Animation "frame" duration
*/
animation.duration = 40;
/**
* Animation types (none,fade,pop,slide)
*/
animation.types = {};
animation.types.fade = [{
x: 0.4,
y: 0.4,
w: 0.6,
h: 0.6,
o: 0.0
}, {
x: 0.4,
y: 0.4,
w: 0.6,
h: 0.6,
o: 0.1
}, {
x: 0.4,
y: 0.4,
w: 0.6,
h: 0.6,
o: 0.2
}, {
x: 0.4,
y: 0.4,
w: 0.6,
h: 0.6,
o: 0.3
}, {
x: 0.4,
y: 0.4,
w: 0.6,
h: 0.6,
o: 0.4
}, {
x: 0.4,
y: 0.4,
w: 0.6,
h: 0.6,
o: 0.5
}, {
x: 0.4,
y: 0.4,
w: 0.6,
h: 0.6,
o: 0.6
}, {
x: 0.4,
y: 0.4,
w: 0.6,
h: 0.6,
o: 0.7
}, {
x: 0.4,
y: 0.4,
w: 0.6,
h: 0.6,
o: 0.8
}, {
x: 0.4,
y: 0.4,
w: 0.6,
h: 0.6,
o: 0.9
}, {
x: 0.4,
y: 0.4,
w: 0.6,
h: 0.6,
o: 1.0
}];
animation.types.none = [{
x: 0.4,
y: 0.4,
w: 0.6,
h: 0.6,
o: 1
}];
animation.types.pop = [{
x: 1,
y: 1,
w: 0,
h: 0,
o: 1
}, {
x: 0.9,
y: 0.9,
w: 0.1,
h: 0.1,
o: 1
}, {
x: 0.8,
y: 0.8,
w: 0.2,
h: 0.2,
o: 1
}, {
x: 0.7,
y: 0.7,
w: 0.3,
h: 0.3,
o: 1
}, {
x: 0.6,
y: 0.6,
w: 0.4,
h: 0.4,
o: 1
}, {
x: 0.5,
y: 0.5,
w: 0.5,
h: 0.5,
o: 1
}, {
x: 0.4,
y: 0.4,
w: 0.6,
h: 0.6,
o: 1
}];
animation.types.popFade = [{
x: 0.75,
y: 0.75,
w: 0,
h: 0,
o: 0
}, {
x: 0.65,
y: 0.65,
w: 0.1,
h: 0.1,
o: 0.2
}, {
x: 0.6,
y: 0.6,
w: 0.2,
h: 0.2,
o: 0.4
}, {
x: 0.55,
y: 0.55,
w: 0.3,
h: 0.3,
o: 0.6
}, {
x: 0.50,
y: 0.50,
w: 0.4,
h: 0.4,
o: 0.8
}, {
x: 0.45,
y: 0.45,
w: 0.5,
h: 0.5,
o: 0.9
}, {
x: 0.4,
y: 0.4,
w: 0.6,
h: 0.6,
o: 1
}];
animation.types.slide = [{
x: 0.4,
y: 1,
w: 0.6,
h: 0.6,
o: 1
}, {
x: 0.4,
y: 0.9,
w: 0.6,
h: 0.6,
o: 1
}, {
x: 0.4,
y: 0.9,
w: 0.6,
h: 0.6,
o: 1
}, {
x: 0.4,
y: 0.8,
w: 0.6,
h: 0.6,
o: 1
}, {
x: 0.4,
y: 0.7,
w: 0.6,
h: 0.6,
o: 1
}, {
x: 0.4,
y: 0.6,
w: 0.6,
h: 0.6,
o: 1
}, {
x: 0.4,
y: 0.5,
w: 0.6,
h: 0.6,
o: 1
}, {
x: 0.4,
y: 0.4,
w: 0.6,
h: 0.6,
o: 1
}];
/**
* Run animation
* @param {Object} opt Animation options
* @param {Object} cb Callabak after all steps are done
* @param {Object} revert Reverse order? true|false
* @param {Object} step Optional step number (frame bumber)
*/
animation.run = function (opt, cb, revert, step) {
var animationType = animation.types[isPageHidden() ? 'none' : _opt.animation];
if (revert === true) {
step = (typeof step !== 'undefined') ? step : animationType.length - 1;
} else {
step = (typeof step !== 'undefined') ? step : 0;
}
cb = (cb) ? cb : function () {
};
if ((step < animationType.length) && (step >= 0)) {
type[_opt.type](merge(opt, animationType[step]));
_animTimeout = setTimeout(function () {
if (revert) {
step = step - 1;
} else {
step = step + 1;
}
animation.run(opt, cb, revert, step);
}, animation.duration);
link.setIcon(_canvas);
} else {
cb();
return;
}
};
//auto init
init();
return {
badge: badge,
video: video,
image: image,
webcam: webcam,
reset: icon.reset,
browser: {
supported: _browser.supported
}
};
});
// AMD / RequireJS
if (typeof define !== 'undefined' && define.amd) {
define([], function () {
return Favico;
});
}
// CommonJS
else if (typeof module !== 'undefined' && module.exports) {
module.exports = Favico;
}
// included directly via <script> tag
else {
this.Favico = Favico;
}
})();

13
public/scripts/movim_favicon.js

@ -58,22 +58,13 @@ var MovimFavicon = {
},
set: function(url) {
document.querySelector('link[sizes="' + MovimFavicon.sizes + '"]').remove();
// We create a favicon link
var linkElement = document.createElement('link');
linkElement.rel = 'icon';
linkElement.sizes = MovimFavicon.sizes;
linkElement.type = 'image/png';
linkElement.href = url;
document.head.appendChild(linkElement);
link = document.querySelector('link[sizes="' + MovimFavicon.sizes + '"]');
link.href = url;
},
init: function() {
link = document.querySelector('link[sizes="' + MovimFavicon.sizes + '"]');
MovimFavicon.originalUrl = link.href;
MovimFavicon.set(link.href);
}
}

2
src/Movim/Bootstrap.php

@ -274,7 +274,7 @@ class Bootstrap
'Confirm','ContactActions','Chat','Chats','Config','ContactData','ContactHeader',
'Dialog','Drawer','Init','Login','LoginAnonymous','Menu','Navigation',
'Notification', 'Notifications','Post','PostActions','Presence','PublishBrief','Rooms',
'RoomsExplore', 'RoomsUtils', 'Stickers','Upload','Vcard4','Visio','VisioLink'];
'RoomsExplore', 'RoomsUtils', 'Stickers','Toast','Upload','Vcard4','Visio','VisioLink'];
}
/**

Loading…
Cancel
Save