better logout, link color settings and api

This commit is contained in:
Hannes Mannerheim 2013-08-25 20:11:53 +02:00
parent d4240edf68
commit 1bb75cfd76
15 changed files with 1892 additions and 55 deletions

View File

@ -6,10 +6,11 @@
* actions/apicheckhub.php New api action (not used yet)
* actions/apiexternalprofileshow.php New api action
* actions/apigroupadmins.php New api action
* actions/apiaccountupdatelinkcolor.php New api action
* lib/apiaction.php
- add urls to larger avatars and groupcount field
- add urls to larger avatars, groupcount and linkcolor field
~LINE 213
$avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
@ -23,6 +24,7 @@
Avatar::defaultImage(AVATAR_PROFILE_SIZE);
$twitter_user['groups_count'] = $profile->getGroups(0, null)->N;
$twitter_user['linkcolor'] = $user->linkcolor;
- add the uri-field
@ -85,6 +87,9 @@
array('action' => 'ApiGroupAdmins',
'id' => Nickname::INPUT_FMT,
'format' => '(xml|json)'));
$m->connect('api/account/update_link_color.json',
array('action' => 'ApiAccountUpdateLinkColor'));
- also, tags need regexp to work with unicode charachters, e.g. farsi and arabic:
@ -173,3 +178,12 @@
// $final = common_shorten_links($content);
// }
* classes/User.php
- add field "linkcolor" to user table (do this is the db too!)
~ line 64 public $linkcolor; // varchar(6)
~ line 105 'linkcolor' => array('type' => 'varchar', 'length' => 6, 'description' => 'hex link color'),

View File

@ -0,0 +1,109 @@
<?php
/**
* StatusNet, the distributed open-source microblogging tool
*
* Update a user's link color
*
* PHP version 5
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category API
* @package StatusNet
* @author Hannes Mannerheim <h@nnesmannerhe.im>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
if (!defined('STATUSNET')) {
exit(1);
}
require_once INSTALLDIR . '/lib/apiauth.php';
class ApiAccountUpdateLinkColorAction extends ApiAuthAction
{
var $linkcolor = null;
/**
* Take arguments for running
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*/
function prepare($args)
{
parent::prepare($args);
$this->user = $this->auth_user;
$this->linkcolor = $this->trimmed('linkcolor');
return true;
}
/**
* Handle the request
*
* Try to save the user's colors in her design. Create a new design
* if the user doesn't already have one.
*
* @param array $args $_REQUEST data (unused)
*
* @return void
*/
function handle($args)
{
parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
$this->clientError(
_('This method requires a POST.'),
400, $this->format
);
return;
}
$validhex = preg_match('/^[a-f0-9]{6}$/i',$this->linkcolor);
if($validhex === false || $validhex == 0) {
$this->clientError(_('Not a valid hex color.'),404,'json');
return;
}
// save the new color
$original = clone($this->user);
$this->user->linkcolor = $this->linkcolor;
if (!$this->user->update($original)) {
$this->clientError(_('Error updating user.'),404,'json');
return;
}
$profile = $this->user->getProfile();
if (empty($profile)) {
$this->clientError(_('User has no profile.'),'json');
return;
}
$twitter_user = $this->twitterUserArray($profile, true);
$this->initDocument('json');
$this->showJsonObjects($twitter_user);
$this->endDocument('json');
}
}

File diff suppressed because it is too large Load Diff

View File

@ -220,11 +220,13 @@ class ApiAction extends Action
$twitter_user['profile_image_url_original'] = ($avatar) ? $avatar->displayUrl() :
Avatar::defaultImage(AVATAR_PROFILE_SIZE);
$twitter_user['groups_count'] = $profile->getGroups(0, null)->N;
$twitter_user['groups_count'] = $profile->getGroups(0, null)->N;
$twitter_user['linkcolor'] = $user->linkcolor;
$twitter_user['url'] = ($profile->homepage) ? $profile->homepage : null;
$twitter_user['protected'] = (!empty($user) && $user->private_stream) ? true : false;
$twitter_user['followers_count'] = $profile->subscriberCount();
// Note: some profiles don't have an associated user

View File

@ -483,7 +483,10 @@ class Router
$m->connect('api/statusnet/groups/admins/:id.:format',
array('action' => 'ApiGroupAdmins',
'id' => Nickname::INPUT_FMT,
'format' => '(xml|json)'));
'format' => '(xml|json)'));
$m->connect('api/account/update_link_color.json',
array('action' => 'ApiAccountUpdateLinkColor'));
// users

102
css/1.css
View File

@ -47,7 +47,6 @@ body {
}
a, a:visited, a:active {
text-decoration:none;
color:#0084B4;
}
ul, li {
margin:0;
@ -74,6 +73,10 @@ button.icon.nav-search {
background-image:url("../img/logo.png");
}
#settingslink {
display:none;
}
.topbar {
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25);
left: 0;
@ -346,6 +349,12 @@ button.icon.nav-search span {
color: #FFFFFF;
text-decoration: none;
}
.dropdown-menu li.dropdown-divider {
border-bottom: 1px solid #DDDDDD;
margin: 5px 1px 6px;
padding-top: 1px;
width:123px;
}
#birds-top {
display:block;
@ -667,7 +676,6 @@ button#submit-login:hover {
margin-bottom:10px;
}
#user-header:hover #user-name {
color: #0084B4;
text-decoration:underline;
}
@ -692,7 +700,6 @@ button#submit-login:hover {
.menu-container div {
cursor:pointer;
background-color: #FFFFFF;
color: #0084B4;
text-decoration: none;
padding: 8px 12px;
position: relative;
@ -743,6 +750,40 @@ button#submit-login:hover {
#history-container {
display:none;
}
#settings-container {
padding:10px 10px 300px 10px;
}
#settings-container label {
float: left;
padding-top: 5px;
text-align: right;
width: 120px;
color: #333333;
cursor: pointer;
display: block;
margin-bottom: 5px;
padding-right:10px;
font-size: 13px;
line-height: 20px;
font-family: "Helvetica Neue",Arial,sans-serif;
}
#settings-container input {
font-family: "Helvetica Neue",Arial,sans-serif;
font-size: 13px;
line-height: 20px;
background-color: #FFFFFF;
border: 1px solid #CCCCCC;
border-radius: 3px 3px 3px 3px;
display: inline-block;
outline: 0 none;
height:26px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) inset, 0 1px 0 rgba(255, 255, 255, 0.075);
transition: background 0.2s linear 0s;
padding-right: 5px;
}
#feed {
display:none;
@ -849,7 +890,6 @@ button#submit-login:hover {
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6);
top: -1px;
z-index: 2;
color: #0084B4;
}
#new-queets-bar:hover {
background-color: #eee;
@ -905,7 +945,6 @@ button#submit-login:hover {
font-style:italic;
}
.show-full-conversation:hover {
color:#0084B4;
text-decoration:underline;
}
.queet {
@ -959,7 +998,6 @@ body.rtl .queet:not(.rtl) .stream-item-header {
background-color:#F6F6F6;
}
.queet:hover .stream-item-expand {
color:#0084B4;
}
.queet:hover .stream-item-expand:hover {
text-decoration:underline;
@ -1032,8 +1070,7 @@ body.rtl .view-more-container-bottom { direction:rtl; }
}
.stream-item-header a.account-group:hover .name {
text-decoration:underline;
color:#0084B4;
text-decoration:underline;
}
.stream-item-header .avatar {
@ -1101,7 +1138,6 @@ body.rtl .view-more-container-bottom { direction:rtl; }
}
.stream-item-header .created-at a:hover {
text-decoration: underline;
color:#0084B4;
}
.dogear {
@ -1163,8 +1199,7 @@ body.rtl .view-more-container-bottom { direction:rtl; }
margin:0;padding:0;
}
.queet-text span.attachment.more {
color:#0084B4;
.queet-text span.attachment.more {
}
.queet-text span.attachment.more:hover {
text-decoration:underline;
@ -1240,8 +1275,7 @@ ul.queet-actions {
ul.queet-actions li {
display:inline;
}
ul.queet-actions li .with-icn {
color: #0084B4;
ul.queet-actions li .with-icn {
margin-left: 8px;
}
ul.queet-actions li .with-icn b {
@ -1253,7 +1287,6 @@ ul.queet-actions li .with-icn b:hover {
text-decoration:underline;
}
ul.queet-actions li .icon {
background-color: #0084B4;
background-repeat: no-repeat;
display: inline-block;
vertical-align: text-top;
@ -1392,7 +1425,6 @@ ul.queet-actions li .icon.sm-fav {
}
.stream-item-footer .with-icn .requeet-text a b:hover {
text-decoration:underline;
color:#0084B4;
}
.stream-item-expand {
@ -1413,7 +1445,6 @@ ul.queet-actions li .icon.sm-fav {
transition: all 0.1s ease;
}
.stream-item.expanded > .queet .stream-item-expand {
color: #0084B4;
}
.stream-item.expanded .stream-item-expand:hover {
text-decoration:underline;
@ -1564,7 +1595,6 @@ ul.stats .avatar-row .avatar {
}
.permalink-link:hover {
text-decoration:underline;
color:#0084B4;
}
.inline-reply-queetbox {
@ -1800,7 +1830,6 @@ ul.stats li:hover a,
ul.stats li:hover a strong,
#user-body a:hover div strong,
#user-body a:hover div div {
color:#0084B4;
}
#user-footer {
@ -2051,23 +2080,23 @@ ul.stats li:hover a strong,
background-position:0 0;
cursor:pointer;
}
#logolink:hover #logo {
#logo:hover {
background-position: 0 34px;
}
#logolink:hover i.nav-session {
#settingslink:hover i.nav-session {
background-position: -160px -80px;
}
#logolink:hover .caret {
#settingslink:hover .caret {
border-top:4px solid #fff;
}
#logolink .dropdown-toggle {
#settingslink .dropdown-toggle {
left: 50%;
margin-left: -340px;
position: fixed;
z-index: 1001;
}
#logolink .caret {
#settingslink .caret {
display:block;
position:absolute;
margin-left:25px;
@ -2628,6 +2657,15 @@ body.rtl .modal-footer div.right {
border-color: #096EB3;
color: #FFFFFF;
}
.modal-footer button.primary.disabled {
background-color: #DDDDDD;
background-image: none;
border-color: #CCCCCC;
color: #777777;
cursor: default;
opacity: 0.65;
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
}
body.rtl .modal-footer button {
font-family:Tahoma,Arial,sans-serif;
margin-left: 10px;
@ -2820,18 +2858,18 @@ body.rtl .dropdown-toggle .caret {
margin-left:0;
}
body.rtl #logolink .dropdown-toggle {
body.rtl #settingslink .dropdown-toggle {
left: auto;
right:50%;
margin-left:0;
margin-right: -343px;
direction:rtl;
}
body.rtl #logolink .nav-session {
body.rtl #settingslink .nav-session {
margin-left:6px;
margin-right:0;
}
body.rtl #logolink .caret {
body.rtl #settingslink .caret {
display:block;
position:absolute;
margin-left:0;
@ -2920,10 +2958,10 @@ body.rtl #feed-header-inner h2 {
body.rtl #logo {
margin-right:-265px;
}
#logolink .dropdown-toggle {
#settingslink .dropdown-toggle {
margin-left: -187px;
}
body.rtl #logolink .dropdown-toggle {
body.rtl #settingslink .dropdown-toggle {
margin-right: -189px;
margin-left:0;
}
@ -2949,7 +2987,7 @@ body.rtl #feed-header-inner h2 {
#logo{
margin-left: -48.5%;
}
#logolink .dropdown-toggle {
#settingslink .dropdown-toggle {
left:0;
padding-left:5px;
margin-left: 95px;
@ -2964,7 +3002,7 @@ body.rtl #feed-header-inner h2 {
margin-left:0;
margin-right:15px;
}
body.rtl #logolink .dropdown-toggle {
body.rtl #settingslink .dropdown-toggle {
left:auto;
right:0;
padding-left:0;
@ -3023,10 +3061,10 @@ body.rtl #feed-header-inner h2 {
#logo {
display:none;
}
#logolink .dropdown-toggle {
#settingslink .dropdown-toggle {
margin-left:5px;
}
body.rtl #logolink .dropdown-toggle {
body.rtl #settingslink .dropdown-toggle {
margin-right:5px;
}

245
css/jquery.minicolors.css Executable file
View File

@ -0,0 +1,245 @@
.minicolors {
position: relative;
}
.minicolors-swatch {
position: absolute;
vertical-align: middle;
background: url(../img/jquery.minicolors.png) -80px 0;
border: solid 1px #ccc;
cursor: text;
padding: 0;
margin: 0;
display: inline-block;
}
.minicolors-swatch-color {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.minicolors input[type=hidden] + .minicolors-swatch {
width: 28px;
position: static;
cursor: pointer;
}
/* Panel */
.minicolors-panel {
position: absolute;
width: 173px;
height: 152px;
background: white;
border: solid 1px #CCC;
box-shadow: 0 0 20px rgba(0, 0, 0, .2);
z-index: 99999;
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
display: none;
}
.minicolors-panel.minicolors-visible {
display: block;
}
/* Panel positioning */
.minicolors-position-top .minicolors-panel {
top: -154px;
}
.minicolors-position-right .minicolors-panel {
right: 0;
}
.minicolors-position-bottom .minicolors-panel {
top: auto;
}
.minicolors-position-left .minicolors-panel {
left: 0;
}
.minicolors-with-opacity .minicolors-panel {
width: 194px;
}
.minicolors .minicolors-grid {
position: absolute;
top: 1px;
left: 1px;
width: 150px;
height: 150px;
background: url(../img/jquery.minicolors.png) -120px 0;
cursor: crosshair;
}
.minicolors .minicolors-grid-inner {
position: absolute;
top: 0;
left: 0;
width: 150px;
height: 150px;
background: none;
}
.minicolors-slider-saturation .minicolors-grid {
background-position: -420px 0;
}
.minicolors-slider-saturation .minicolors-grid-inner {
background: url(../img/jquery.minicolors.png) -270px 0;
}
.minicolors-slider-brightness .minicolors-grid {
background-position: -570px 0;
}
.minicolors-slider-brightness .minicolors-grid-inner {
background: black;
}
.minicolors-slider-wheel .minicolors-grid {
background-position: -720px 0;
}
.minicolors-slider,
.minicolors-opacity-slider {
position: absolute;
top: 1px;
left: 152px;
width: 20px;
height: 150px;
background: white url(../img/jquery.minicolors.png) 0 0;
cursor: row-resize;
}
.minicolors-slider-saturation .minicolors-slider {
background-position: -60px 0;
}
.minicolors-slider-brightness .minicolors-slider {
background-position: -20px 0;
}
.minicolors-slider-wheel .minicolors-slider {
background-position: -20px 0;
}
.minicolors-opacity-slider {
left: 173px;
background-position: -40px 0;
display: none;
}
.minicolors-with-opacity .minicolors-opacity-slider {
display: block;
}
/* Pickers */
.minicolors-grid .minicolors-picker {
position: absolute;
top: 70px;
left: 70px;
width: 12px;
height: 12px;
border: solid 1px black;
border-radius: 10px;
margin-top: -6px;
margin-left: -6px;
background: none;
}
.minicolors-grid .minicolors-picker > div {
position: absolute;
top: 0;
left: 0;
width: 8px;
height: 8px;
border-radius: 8px;
border: solid 2px white;
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
}
.minicolors-picker {
position: absolute;
top: 0;
left: 0;
width: 18px;
height: 2px;
background: white;
border: solid 1px black;
margin-top: -2px;
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
}
/* Inline controls */
.minicolors-inline {
display: inline-block;
}
.minicolors-inline .minicolors-input {
display: none !important;
}
.minicolors-inline .minicolors-panel {
position: relative;
top: auto;
left: auto;
box-shadow: none;
z-index: auto;
display: inline-block;
}
/* Default theme */
.minicolors-theme-default .minicolors-swatch {
top: 5px;
left: 5px;
width: 18px;
height: 18px;
}
.minicolors-theme-default.minicolors-position-right .minicolors-swatch {
left: auto;
right: 5px;
}
.minicolors-theme-default.minicolors {
width: auto;
display: inline-block;
}
.minicolors-theme-default .minicolors-input {
height: 20px;
width: auto;
display: inline-block;
padding-left: 26px;
}
.minicolors-theme-default.minicolors-position-right .minicolors-input {
padding-right: 26px;
padding-left: inherit;
}
/* Bootstrap theme */
.minicolors-theme-bootstrap .minicolors-swatch {
top: 3px;
left: 3px;
width: 28px;
height: 28px;
border-radius: 3px;
}
.minicolors-theme-bootstrap.minicolors-position-right .minicolors-swatch {
left: auto;
right: 3px;
}
.minicolors-theme-bootstrap .minicolors-input {
padding-left: 44px;
}
.minicolors-theme-bootstrap.minicolors-position-right .minicolors-input {
padding-right: 44px;
padding-left: 12px;
}

BIN
img/jquery.minicolors.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

View File

@ -39,6 +39,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="<?php print $qvitterpath; ?>css/1.css" />
<link rel="stylesheet" type="text/css" href="<?php print $qvitterpath; ?>css/jquery.minicolors.css" />
<link rel="shortcut icon" type="image/x-icon" href="<?php print $qvitterpath; ?>favicon.ico">
<script>
window.timeBetweenPolling = <?php print $timebetweenpolling; ?>;
@ -46,11 +47,35 @@
window.siteRootDomain = '<?php print $siterootdomain; ?>';
window.useHistoryPushState = <?php if($usehistorypushstate) print 'true'; else print 'false'; ?>;
</script>
<style>
a, a:visited, a:active,
ul.stats li:hover a,
ul.stats li:hover a strong,
#user-body a:hover div strong,
#user-body a:hover div div,
.permalink-link:hover,
.stream-item.expanded > .queet .stream-item-expand,
.stream-item-footer .with-icn .requeet-text a b:hover,
ul.queet-actions li .with-icn,
.queet-text span.attachment.more,
.stream-item-header .created-at a:hover,
.stream-item-header a.account-group:hover .name,
.queet:hover .stream-item-expand,
.show-full-conversation:hover,
#new-queets-bar,
.menu-container div,
#user-header:hover #user-name {
color:#0084B4;/*COLOREND*/
}
ul.queet-actions li .icon {
background-color:#0084B4;/*BACKGROUNDCOLOREND*/
}
</style>
</head>
<body>
<div class="topbar">
<a id="logolink">
<div id="logo"></div>
<a href="<?php print strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,strpos( $_SERVER["SERVER_PROTOCOL"],'/'))).'://'.$siterootdomain; ?>"><div id="logo"></div></a>
<a id="settingslink">
<div class="dropdown-toggle">
<i class="nav-session"></i>
<b class="caret"></b>
@ -61,6 +86,8 @@
<span class="caret-outer"></span>
<span class="caret-inner"></span>
</li>
<li><a id="settings"></a></li>
<li class="dropdown-divider"></li>
<li><a id="logout"></a></li>
</ul>
<img id="birds-top" src="<?php print $qvitterpath; ?>img/birds.png" />
@ -167,6 +194,7 @@
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/jquery-2.0.2.min.js"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/jquery-ui-1.10.3.min.js"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/jquery.minicolors.min.js"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/dom-functions-1.js"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/misc-functions-1.js"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/ajax-functions-1.js"></script>

View File

@ -53,14 +53,27 @@ function checkLogin(username,password,actionOnSuccess) {
password: password
},
dataType: 'json',
error: function() {
logoutWithoutReload(true);
},
success: function(data) {
if(typeof data.error == 'undefined') {
actionOnSuccess(data);
}
else {
alert(data.error);
remove_spinner();
$('#submit-login').removeAttr('disabled');
// if no stream is set, get the one from the url
if(typeof window.currentStream == 'undefined' || window.currentStream == '') {
setNewCurrentStream(getStreamFromUrl(),function(){
logoutWithoutReload(true);
remove_spinner();
},true);
}
// if we have a strem, just just do logout and shake...
else {
logoutWithoutReload(true);
remove_spinner();
}
}
}
});
@ -147,6 +160,31 @@ function postQueetToAPI(queetText_txt, actionOnSuccess) {
}
/* ·
·
· Post new link color
·
· @param newLinkColor: the new link color in hex without #
·
· · · · · · · · · · · · · */
function postNewLinkColor(newLinkColor) {
$.ajax({ url: 'API.php',
type: "POST",
data: {
postRequest: 'account/update_link_color.json',
linkcolor: newLinkColor,
username: window.loginUsername,
password: window.loginPassword
},
dataType:"json",
error: function(data){ console.log(data); },
success: function(data) { console.log(data);}
});
}
/* ·
·
· Post follow or unfollow user request

View File

@ -177,6 +177,14 @@ function profileCardFromFirstObject(data,screen_name) {
if(typeof window.loginUsername != 'undefined' && window.myUserID != first.user.id) {
var followButton = '<div class="user-actions"><button data-follow-user-id="' + first.user.id + '" data-follow-user="' + first.user.statusnet_profile_url + '" type="button" class="follow-button ' + followingClass + '"><span class="button-text follow-text"><i class="follow"></i>' + window.sL.userFollow + '</span><span class="button-text following-text">' + window.sL.userFollowing + '</span><span class="button-text unfollow-text">' + window.sL.userUnfollow + '</span></button></div>';
}
// change link color if set
if(first.user.linkcolor.length == 6) {
changeLinkColor('#' + first.user.linkcolor);
}
else {
changeLinkColor('#0084B4');
}
$('#feed').before('<div class="profile-card"><div class="profile-header-inner" style="background-image:url(' + first.user.profile_image_url_original + ')"><div class="profile-header-inner-overlay"></div><a class="profile-picture" href="' + first.user.profile_image_url_original + '"><img src="' + first.user.profile_image_url_profile_size + '" /></a><div class="profile-card-inner"><h1 class="fullname">' + first.user.name + '<span></span></h1><h2 class="username"><span class="screen-name">@' + first.user.screen_name + '</span><span class="follow-status"></span></h2><div class="bio-container"><p>' + first.user.description + '</p></div><p class="location-and-url"><span class="location">' + first.user.location + '</span><span class="divider"> · </span><span class="url"><a href="' + first.user.url + '">' + first.user.url.replace('http://','').replace('https://','') + '</a></span></p></div></div><div class="profile-banner-footer"><ul class="stats"><li><a class="tweet-stats"><strong>' + first.user.statuses_count + '</strong>' + window.sL.notices + '</a></li><li><a class="following-stats"><strong>' + first.user.friends_count + '</strong>' + window.sL.following + '</a></li><li><a class="follower-stats"><strong>' + first.user.followers_count + '</strong>' + window.sL.followers + '</a></li><li><a class="groups-stats"><strong>' + first.user.groups_count + '</strong>' + window.sL.groups + '</a></li></ul>' + followButton + '<div class="clearfix"></div></div></div>');
}
@ -207,6 +215,14 @@ function profileCardFromFirstObject(data,screen_name) {
if(typeof window.loginUsername != 'undefined' && window.myUserID != data.id) {
var followButton = '<div class="user-actions"><button data-follow-user-id="' + data.id + '" data-follow-user="' + data.statusnet_profile_url + '" type="button" class="follow-button ' + followingClass + '"><span class="button-text follow-text"><i class="follow"></i>' + window.sL.userFollow + '</span><span class="button-text following-text">' + window.sL.userFollowing + '</span><span class="button-text unfollow-text">' + window.sL.userUnfollow + '</span></button></div>';
}
// change link color
if(data.linkcolor.length == 6) {
changeLinkColor('#' + data.linkcolor);
}
else {
changeLinkColor('#0084B4');
}
$('#feed').before('<div class="profile-card"><div class="profile-header-inner" style="background-image:url(' + data.profile_image_url_original + ')"><div class="profile-header-inner-overlay"></div><a class="profile-picture" href="' + data.profile_image_url_original + '"><img src="' + data.profile_image_url_profile_size + '" /></a><div class="profile-card-inner"><h1 class="fullname">' + data.name + '<span></span></h1><h2 class="username"><span class="screen-name">@' + data.screen_name + '</span><span class="follow-status"></span></h2><div class="bio-container"><p>' + data.description + '</p></div><p class="location-and-url"><span class="location">' + data.location + '</span><span class="divider"> · </span><span class="url"><a href="' + data.url + '">' + data.url.replace('http://','').replace('https://','') + '</a></span></p></div></div><div class="profile-banner-footer"><ul class="stats"><li><a class="tweet-stats"><strong>' + data.statuses_count + '</strong>' + window.sL.notices + '</a></li><li><a class="following-stats"><strong>' + data.friends_count + '</strong>' + window.sL.following + '</a></li><li><a class="follower-stats"><strong>' + data.followers_count + '</strong>' + window.sL.followers + '</a></li><li><a class="groups-stats"><strong>' + data.groups_count + '</strong>' + window.sL.groups + '</a></li></ul>' + followButton + '<div class="clearfix"></div></div></div>');
}});
@ -396,6 +412,14 @@ function setNewCurrentStream(stream,actionOnSuccess,setLocation) {
// while waiting for this data user might have changed stream, so only proceed if current stream still is this one
if(window.currentStream == stream) {
// change link color
if(window.userLinkColor.length == 6) {
changeLinkColor('#' + window.userLinkColor);
}
else {
changeLinkColor('#0084B4');
}
// get screen name from stream, if not found, this is me
if(stream.indexOf('screen_name=')>-1) {
var thisUsersScreenName = stream.substring(stream.indexOf('screen_name=')+12);
@ -426,6 +450,14 @@ function setNewCurrentStream(stream,actionOnSuccess,setLocation) {
if(queet_data) {
// while waiting for this data user might have changed stream, so only proceed if current stream still is this one
if(window.currentStream == stream) {
// change link color
if(window.userLinkColor.length == 6) {
changeLinkColor('#' + window.userLinkColor);
}
else {
changeLinkColor('#0084B4');
}
// show profile card if this is a user's queet stream
if(stream.substring(0,27) == 'statuses/user_timeline.json') {

8
js/jquery.minicolors.min.js vendored Executable file

File diff suppressed because one or more lines are too long

View File

@ -122,6 +122,9 @@ window.l.es.isMemberOfGroup = 'Abandonar grupo';
window.l.es.leaveGroup = 'Abandonar grupo';
window.l.es.memberCount = 'Miembros';
window.l.es.adminCount = 'Administradores';
window.l.es.settings = 'Configuración';
window.l.es.saveChanges = 'Guardar cambios';
window.l.es.linkColor = 'Color del enlace';
// french
@ -209,6 +212,9 @@ window.l.fr.isMemberOfGroup = 'Quitter le groupe';
window.l.fr.leaveGroup = 'Quitter le groupe';
window.l.fr.memberCount = 'Membres';
window.l.fr.adminCount = 'Administrateurs';
window.l.fr.settings = 'Paramètres';
window.l.fr.saveChanges = 'Sauvegarder les modifications';
window.l.fr.linkColor = ' Couleur des liens';
// deutsch
@ -296,6 +302,9 @@ window.l.de.isMemberOfGroup = 'Gruppe verlassen';
window.l.de.leaveGroup = 'Gruppe verlassen';
window.l.de.memberCount = 'Mitglieder';
window.l.de.adminCount = 'Administratoren';
window.l.de.settings = 'Einstellungen';
window.l.de.saveChanges = 'Änderungen speichern';
window.l.de.linkColor = 'Linkfarbe';
@ -384,7 +393,9 @@ window.l.en.isMemberOfGroup = 'Member';
window.l.en.leaveGroup = 'Leave';
window.l.en.memberCount = 'Members';
window.l.en.adminCount = 'Admins';
window.l.en.settings = 'Settings';
window.l.en.saveChanges = 'Save changes';
window.l.en.linkColor = 'Link color';
// svenska
@ -472,6 +483,9 @@ window.l.sv.isMemberOfGroup = 'Medlem';
window.l.sv.leaveGroup = 'Gå ur';
window.l.sv.memberCount = 'Medlemmar';
window.l.sv.adminCount = 'Administratörer';
window.l.sv.settings = 'Inställningar';
window.l.sv.saveChanges = 'Spara ändringarna';
window.l.sv.linkColor = 'Länkfärg';
@ -560,6 +574,9 @@ window.l.fa.isMemberOfGroup = 'عضو گروه';
window.l.fa.leaveGroup = 'ترک گروه';
window.l.fa.memberCount = 'اعضا';
window.l.fa.adminCount = 'مدیران';
window.l.fa.settings = 'تنظیمات';
window.l.fa.saveChanges = 'ذخیره تغییرات';
window.l.fa.linkColor = 'رنگ پیوند';
@ -648,6 +665,9 @@ window.l.ar.isMemberOfGroup = 'مغادرة المجموعة';
window.l.ar.leaveGroup = 'مغادرة المجموعة';
window.l.ar.memberCount = 'الأعضاء';
window.l.ar.adminCount = 'الإداريين';
window.l.ar.settings = 'الإعدادات';
window.l.ar.saveChanges = 'حفظ التغييرات';
window.l.ar.linkColor = 'لون الرابط';
@ -692,6 +712,7 @@ $('#queet-box').html(window.sL.compose);
$('#queet').html(window.sL.queetVerb);
$('#feed-header-inner h2').html(window.sL.queetsNounPlural);
$('#logout').html(window.sL.logout);
$('#settings').html(window.sL.settings);
$('.language-dropdown .dropdown-toggle small').html(window.sL.languageSelected);
$('.language-dropdown .current-language').html(window.sL.languageName);
$('.stream-selection[data-stream-name="statuses/friends_timeline.json"]').prepend(window.sL.queetsNounPlural);

View File

@ -56,6 +56,21 @@ function localStorageIsEnabled() {
}
/* ·
·
· Change link color
·
· @param newLinkColor: hex value with #
·
· · · · · · · · · */
function changeLinkColor(newLinkColor) {
var linkstyle = $('style').html();
$('style').html(linkstyle.substring(0,linkstyle.indexOf('color:')+6) + newLinkColor + linkstyle.substring(linkstyle.indexOf(';/*COLOREND*/')));
var linkstyle = $('style').html();
$('style').html(linkstyle.substring(0,linkstyle.indexOf('background-color:')+17) + newLinkColor + linkstyle.substring(linkstyle.indexOf(';/*BACKGROUNDCOLOREND*/')));
}
/* ·
·

View File

@ -32,6 +32,8 @@
· Contact h@nnesmannerhe.im if you have any questions. ·
· ·
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
/* ·
·
@ -85,18 +87,18 @@ $('<img/>').attr('src', window.fullUrlToThisQvitterApp + 'img/ekan4.jpg').load(f
$('#submit-login').trigger('click');
}
else {
// set stream
display_spinner();
window.currentStream = ''; // force reload stream
setNewCurrentStream(getStreamFromUrl(),function(){
$('input#username').focus();
$('#login-content').animate({opacity:'1'},800);
$('#page-container').animate({opacity:'1'},200);
logoutWithoutReload(false);
remove_spinner();
},true);
}
});
/* ·
·
· Login action
@ -111,11 +113,12 @@ $('#submit-login').click(function () {
// login with ajax
checkLogin($('input#username').val(),$('input#password').val(),function(user){
console.log(user);
// store credentials in global var
window.loginUsername = user.screen_name;
window.loginPassword = $('input#password').val();
console.log(user);
window.userLinkColor = user.linkcolor;
// add user data to DOM, show search form, remeber user id, show the feed
$('#user-avatar').attr('src', user.profile_image_url);
@ -125,10 +128,9 @@ $('#submit-login').click(function () {
$('#user-queets strong').html(user.statuses_count);
$('#user-following strong').html(user.friends_count);
$('#user-followers strong').html(user.followers_count);
$('#user-groups strong').html(user.groups_count);
$('#search').fadeIn('slow');
$('#user-groups strong').html(user.groups_count);
window.myUserID = user.id;
// if remeber me is checked, save credentials in local storage
if($('#rememberme').is(':checked')) {
if(localStorageIsEnabled()) {
@ -155,7 +157,9 @@ $('#submit-login').click(function () {
$('#user-body').animate({opacity:'1'},800);
$('#user-footer').animate({opacity:'1'},800);
$('.menu-container').animate({opacity:'1'},800);
$('#page-container').animate({opacity:'1'},200);
$('#page-container').animate({opacity:'1'},200);
$('#settingslink').fadeIn('slow');
$('#search').fadeIn('slow');
$('#login-content').css('display','none');
remove_spinner();
},true);
@ -179,7 +183,7 @@ $('#rememberme_label').click(function(){
$('#rememberme').prop('checked', true);
}
});
$('#rememberme_label').disableSelection();
/* ·
@ -210,6 +214,68 @@ $('#logout').click(function(){
location.reload();
});
/* ·
·
· Settings
·
· · · · · · · · · · · · · */
$('#settings').click(function(){
popUpAction('popup-settings', window.sL.settings,'<div id="settings-container"><label for="link-color-selection">' + window.sL.linkColor + '</label><input id="link-color-selection" type="text" value="#' + window.userLinkColor + '" /></div>','<div class="right"><button class="close">' + window.sL.cancelVerb + '</button><button class="primary">' + window.sL.saveChanges + '</button></div>');
$('#link-color-selection').minicolors({
change: function(hex) {
changeLinkColor(hex);
postNewLinkColor(hex.substring(1));
}
});
});
/* ·
·
· Do a logout without reloading, i.e. on login errors
·
· · · · · · · · · · · · · */
function logoutWithoutReload(doShake) {
$('#submit-login').removeAttr('disabled');
// delete any locally stored credentials
if(localStorageIsEnabled()) {
delete localStorage.autologinUsername;
delete localStorage.autologinPassword;
}
$('#user-header').animate({opacity:'0'},800);
$('#user-body').animate({opacity:'0'},800);
$('#user-footer').animate({opacity:'0'},800);
$('.menu-container').animate({opacity:'0'},800);
$('#settingslink').fadeOut('slow');
$('#search').fadeOut('slow');
$('input#username').focus();
if(doShake) {
$('input#username').css('background-color','pink');
$('input#password').css('background-color','pink');
}
$('#login-content').animate({opacity:'1'},800, function(){
if(doShake) {
$('#login-content').effect('shake',{distance:5,times:2},function(){
$('input#username').animate({backgroundColor:'#fff'},1000);
$('input#password').animate({backgroundColor:'#fff'},1000);
});
}
});
$('#page-container').animate({opacity:'1'},200);
}
/* ·
·
· Handling the language dropdown selection
@ -219,7 +285,7 @@ $('#logout').click(function(){
$('.dropdown').click(function(){$(this).toggleClass('dropped')});
$('.dropdown').disableSelection();
$(document).bind('click', function (e) {
if(!$(e.target).is('#logo') && !$(e.target).is('#logolink') && !$(e.target).is('.nav-session') && !$(e.target).is('.dropdown-toggle') && !$(e.target).is('.dropdown-toggle small') && !$(e.target).is('.dropdown-toggle span') && !$(e.target).is('.dropdown-toggle b')) {
if(!$(e.target).is('#logo') && !$(e.target).is('#settingslink') && !$(e.target).is('.nav-session') && !$(e.target).is('.dropdown-toggle') && !$(e.target).is('.dropdown-toggle small') && !$(e.target).is('.dropdown-toggle span') && !$(e.target).is('.dropdown-toggle b')) {
$('.dropdown').removeClass('dropped');
$('.quitter-settings.dropdown-menu').removeClass('dropped');
}
@ -238,7 +304,7 @@ $('.language-link').click(function(){
·
· · · · · · · · · · · · · */
$('#logolink').click(function(){
$('#settingslink').click(function(){
if(!$('.quitter-settings').hasClass('dropped')) { $('.quitter-settings').addClass('dropped'); }
else { $('.quitter-settings').removeClass('dropped'); }
});