Skip to content

Commit

Permalink
account/settings complete, domain logo added
Browse files Browse the repository at this point in the history
  • Loading branch information
philtobias committed Oct 4, 2010
1 parent ee17261 commit e5430c9
Show file tree
Hide file tree
Showing 23 changed files with 215 additions and 110 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.sass-cache*
/tests
/resources/attachments
/application/system/config.ini
20 changes: 15 additions & 5 deletions application/services/accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,9 @@ public function updateUserInDomain($domain, $username)
$context = array(AMForm::kDataKey=>$data);
$input = AMForm::formWithContext($context);

$input->addValidator(new AMPatternValidator('firstname', AMValidator::kRequired, '/^[a-zA-Z]{2,}[a-zA-Z ]{0,}$/', "Invalid first name. Expecting minimum 2 characters. Must start with at least 2 letters, followed by letters or spaces"));
$input->addValidator(new AMPatternValidator('lastname', AMValidator::kRequired, '/^[a-zA-Z]{2,}[a-zA-Z ]{0,}$/', "Invalid last name. Expecting minimum 2 characters. Must start with at least 2 letters, followed by letters or spaces"));
$input->addValidator(new AMPatternValidator('username', AMValidator::kRequired, '/^[\w\d]{4,}$/', "Invalid username. Expecting minimum 4 characters. Must be composed of letters, numbers or _"));
$input->addValidator(new AMEmailValidator('email', AMValidator::kRequired, 'Invalid email address'));

// if password is passed in then the user is trying to change their password
// otherwise the user is editing their information
if($input->password)
{
// only the owner can change the password
Expand All @@ -270,6 +268,13 @@ public function updateUserInDomain($domain, $username)
$this->message = "unable to change password";
}
}
else
{
$input->addValidator(new AMPatternValidator('firstname', AMValidator::kRequired, '/^[a-zA-Z]{2,}[a-zA-Z ]{0,}$/', "Invalid first name. Expecting minimum 2 characters. Must start with at least 2 letters, followed by letters or spaces"));
$input->addValidator(new AMPatternValidator('lastname', AMValidator::kRequired, '/^[a-zA-Z]{2,}[a-zA-Z ]{0,}$/', "Invalid last name. Expecting minimum 2 characters. Must start with at least 2 letters, followed by letters or spaces"));
$input->addValidator(new AMPatternValidator('username', AMValidator::kRequired, '/^[\w\d]{4,}$/', "Invalid username. Expecting minimum 4 characters. Must be composed of letters, numbers or _"));
$input->addValidator(new AMEmailValidator('email', AMValidator::kRequired, 'Invalid email address'));
}


if($dirty == false)
Expand Down Expand Up @@ -456,7 +461,11 @@ public function getUsersInDomain($domain)
$users = $company->getUsers();

foreach($users as $user)
{
// identify current logged in user by username
$user['is_current_user'] = ($user['username'] == $session->currentUser->username);
$response->users[] = $user;
}
}
else
{
Expand Down Expand Up @@ -498,7 +507,8 @@ public function getDomainInfo($domain)
"timestamp" => $company->timestamp,
"users" => $company->users,
"logo" => $company->logo,
"current_username" => $session->currentUser->username);
"current_username" => $session->currentUser->username,
"user_level" => $session->currentUser->level);
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions application/system/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ domain = "yss.com"

[autologin]
domain = "blitz"
userid = 1
userid = 16
firstname = "Phil"
lastname = "Tobias"
username = "ptobias"
username = "philtobias"
email = "philtobias@gmail.com"
level = 7

Expand Down
4 changes: 2 additions & 2 deletions application/system/vhost.conf
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ RewriteCond ${lowercase:%{SERVER_NAME}} ^([^\.]+)\.yss\.com$
RewriteCond ${lowercase:%{SERVER_NAME}} !^www\. [NC]
RewriteCond ${lowercase:%{SERVER_NAME}} !^api\. [NC]
RewriteRule ^(.+) ${lowercase:%{SERVER_NAME}}$1 [C]
RewriteRule ^([^\.]+)\.yss\.com/? /index.php?domain=$1 [L]
# RewriteRule ^([^\.]+)\.yss\.com/dashboard /dashboard.php?domain=$1 [L]
# RewriteRule ^([^\.]+)\.yss\.com/project/add /project-add.php?domain=$1 [L]
# RewriteRule ^([^\.]+)\.yss\.com/manage/users /manage-users.php?domain=$1 [L]
# RewriteRule ^([^\.]+)\.yss\.com/manage/account /manage-account.php?domain=$1 [L]
RewriteRule ^([^\.]+)\.yss\.com/account/verify/([a-zA-Z0-9]{32})$ /account-verify.php?domain=$1&token=$2 [L]
RewriteRule ^([^\.]+)\.yss\.com/account/verify/([a-zA-Z0-9]{32})$ /account-verify.php?domain=$1&token=$2 [L]
RewriteRule ^([^\.]+)\.yss\.com/? /index.php?domain=$1 [L]
# RewriteRule ^([^\.]+)\.yss\.com/logout /logout.php?domain=$1 [L]
# RewriteRule ^([^\.]+)\.yss\.com /login.php?domain=$1 [L]
10 changes: 5 additions & 5 deletions application/templates/sign-up.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
</div>
</li>
</ul>
<a href="#" class="btn btn-signup left clearboth">Sign Up</a>
<a href="#" class="btn btn-signup btn-submit left clearboth">Sign Up</a>
</form>
</div>
</section>
Expand All @@ -100,15 +100,15 @@
<li class="field">
<input type="password" name="password" />
<label for="password">Password</label>
<a href="#" class="btn-forgot-password forgot-password incomplete">forgot password?</a>
<a href="#" class="btn-forgot-password btn-submit forgot-password incomplete">forgot password?</a>
</li>
</ul>
<a href="#" class="btn btn-sign-in left">Login</a>
<a href="#" class="btn btn-submit btn-sign-in left">Login</a>
</form>
</div>
<div id="forgot-password-container">
<h3>Forgot Password</h3>
<a href="#" class="btn-sign-in-form incomplete">Nevermind, I remember.</a>
<a href="#" class="btn-sign-in-form incomplete">&laquo; Nevermind, I remember.</a>
<form id="frm-forgot-password" action="" method="post">
<ul>
<li class="field">
Expand All @@ -120,7 +120,7 @@
<label for="username">Email</label>
</li>
</ul>
<a href="#" class="btn btn-reset-password left">Reset Password</a>
<a href="#" class="btn btn-reset-password btn-submit left">Reset Password</a>
</form>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
<script src="resources/js/src/jquery/plugins/jqueryui.selectmenu.js"></script>
<script src="resources/js/src/jquery/plugins/jquery.numeric.js"></script>
<script src="resources/js/src/jquery/plugins/jquery.validation.js"></script>
<script src="resources/js/src/jquery/plugins/jquery.lastfieldentersubmit.js"></script>
<script src="resources/js/src/sammy/sammy.min.js"></script>
<script src="resources/js/src/sammy/plugins/sammy.cache.js"></script>
<script src="resources/js/src/sammy/plugins/sammy.json.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion resources/css/coming-soon.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/css/logged-in.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/css/sign-up.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/css/src/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ form {}
form li li {clear: none; width: 190px;}
form .field-domain div,
.field input,
.field textarea {position: relative; z-index: 2; background: transparent; @include boxshadow(rgba(0, 0, 1, 0.2), 0, 0, 3px, inset); @include corner(); font-size: 28px; color: $color_dark_gray; width: 351px; height: 38px; float: left; padding: 5px; letter-spacing: -1px; border: 1px solid rgba(0, 0, 0, 0.1); outline: none; @include transition(all, 0.15s, ease-out)}
.field textarea {position: relative; z-index: 2; background: transparent; @include boxshadow(rgba(0, 0, 1, 0.2), 0, 0, 3px, inset); @include corner(); font-size: 22px; color: $color_dark_gray; width: 351px; height: 38px; float: left; padding: 5px; letter-spacing: -1px; border: 1px solid rgba(0, 0, 0, 0.1); outline: none; @include transition(all, 0.15s, ease-out)}
.field textarea {height: 200px; font: 18px "Calibri","Lucida Sans",Helvetica,Arial,sans-serif;}
.field input.file {margin-right: 10px; width: 260px;}
.field input[type=file] {cursor: pointer;}
Expand Down
15 changes: 13 additions & 2 deletions resources/css/src/logged-in.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,27 @@
.settings .table-users .table-column-email {width: 165px;}
.settings .table-users .table-column-admin {width: 95px;}
.settings .table-users .table-column-edit {width: 35px;}
.settings .table-users .user-me {color: $color_light_pink;}
.settings .table-users .btn-edit {cursor: pointer;}

// remove hover states
.settings .table-sortable tbody tr {height: 21px; padding: 2px 3px; font-size: 16px; line-height: 21px; cursor: default; @include transition(all, 0.15s, ease-out); @include corner(); display: block; width: 100%; background: $color_light_white;
&:hover {background: $color_light_white; border-color: $color_light_white; color: $color_dark_gray;}
&:nth-child(even):hover {background: #fff; color: $color_dark_gray;}
}

.settings .account-actions {
h3 {font-size: 18px;}
.btn-delete-account {color: $color_dark_red; margin: 10px 0 0 0; float: left;
&:hover {color: $color_light_red;}
}

.msg {font-weight: bold; background: $color_light_pink; color: #fff; padding: 5px 10px; @include corner(); display: none;}
}

.modal .chk-admin,
.modal .msg-admin {display: none;}

// END SETTINGS SPECIFIC


Expand Down Expand Up @@ -142,7 +152,8 @@
.wide + .sidebar {display: none;}
.sidebar .company-logo {height: 138px; width: 290px; background: $color_light_white; display: table-cell; text-align: center; vertical-align: middle;}
.sidebar .company-logo * {vertical-align: middle;}
.sidebar .company-logo span {display: inline-block; height: 100%; width: 1px;}
// .sidebar .company-logo span {display: inline-block; height: 100%; width: 1px;}
.sidebar .company-logo img {max-width: 290px; max-height: 138px;}

.sidebar .company-meta {}
.sidebar .company-meta .company {font-size: 26px; font-weight: bold; line-height: 26px;}
Expand Down
2 changes: 1 addition & 1 deletion resources/css/style.css

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions resources/js/src/jquery/plugins/jquery.lastfieldentersubmit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
(function($) {
$.fn.lastfieldentersubmit = function(settings) {
var config = {
submit: null
};

if (settings) $.extend(config, settings);

this.each(function(i) {
$frm = $(this);
// submit form when user presses enter on last field
$frm.find("input:last").keypress(function(evt) {
if(evt.keyCode == 13)
{
if(config.submit && $.isFunction(config.submit))
{
config.submit($(this).parents("form"));
}
else
{
$frm.submit();
}
}
});
});

return this;
};
})(jQuery);
13 changes: 8 additions & 5 deletions resources/js/src/peeq/peeq.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,24 @@ peeq.prototype.api =
// remove iframe if it currently exists
$("#" + iframe).remove();

var $iframe = $('<iframe name="' + iframe + '" id="' + iframe + '" style="display:none;width:0;height:0" src="" target="_self" />');
var $iframe = $('<iframe name="' + iframe + '" id="' + iframe + '" style="display:none;width:0;height:0" src="http://blitz.yss.com/#/settings" target="_self" />');

$iframe.insertAfter("#" + $original_form.attr("id"));

$original_form.attr("action", action).submit();

$iframe.load(function() {
var response = $.parseJSON($("#" + iframe)[0].contentDocument.body.innerHTML);
/* var response = $.parseJSON($("#" + iframe)[0].contentDocument.body.innerHTML);
if(response.ok)
{
// CHANGE TO AJAX refresh
document.location.reload(true);
//document.location.reload(true);
}
*/
document.location.reload(true);
$("#" + iframe).remove();
});

return false;
},
request: function(resource, data, method, successCallback, isUpload)
Expand Down
104 changes: 61 additions & 43 deletions resources/js/src/peeq/peeq.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ function peeq()

$("#table-annotations-container").find(".table-sortable").tablesorter({
"cssAsc": "icon-sort-asc",
"cssDesc": "icon-sort-desc"
"cssDesc": "icon-sort-desc",
"sortList": [[0,1]] /* sort on priority */
});

// clicking on tr fire annotation in preview's click event (deeplinking into annotation)
Expand Down Expand Up @@ -434,52 +435,64 @@ function peeq()

$(".settings").find(".table-sortable").tablesorter({
"cssAsc": "icon-sort-asc",
"cssDesc": "icon-sort-desc"
"cssDesc": "icon-sort-desc",
"sortList": [[0,0]] /* sort on last name */
});

$(".table-users").find(".btn-edit").click(function() {
// get fields
var $row = $(this).parents("tr"),
ary_name = $row.find(".table-column-name").text().split(","),
first_name = $.trim(ary_name[1]),
last_name = $.trim(ary_name[0]),
username = $row.find(".table-column-username").text(),
email = $row.find(".table-column-email").text(),
is_admin = $row.find(".table-column-admin").text().length,
$modal = $(".modal-view-edit-user");
// bind events for admin users
if(peeq.utils.template.user.is_admin(data.result.account.user_level))
{
/* // clicking on user allows you to edit user
$(".table-users").find("tbody tr").click(function() {
$(this).find(".btn-edit").click();
return false;
});
*/

// populate modal with fields
$modal.find("input[name=firstname]").val(first_name);
$modal.find("input[name=lastname]").val(last_name);
$modal.find("input[name=username]").val(username).data("original", username);
$modal.find("input[name=email]").val(email);
$modal.find("input[name=admin]").attr("checked", is_admin ? "checked" : "");
// setup admin change button
$modal.find(".btn-admin-change").click().click();
});
$(".table-users").find(".btn-edit").click(function() {
// get fields
var $row = $(this).parents("tr"),
ary_name = $row.find(".table-column-name").text().split(","),
first_name = $.trim(ary_name[1]),
last_name = $.trim(ary_name[0]),
username = $row.find(".table-column-username").text(),
email = $row.find(".table-column-email").text(),
is_admin = $row.find(".table-column-admin").text().length,
$modal = $(".modal-view-edit-user");

// populate modal with fields
$modal.find("input[name=firstname]").val(first_name);
$modal.find("input[name=lastname]").val(last_name);
$modal.find("input[name=username]").val(username).data("original", username);
$modal.find("input[name=email]").val(email);
$modal.find("input[name=admin]").attr("checked", is_admin ? "checked" : "");
// setup admin change button
$modal.find(".btn-admin-change").click().click();
});

// toggle admin privileges
$(".btn-admin-change").click(function() {
var $li = $(this).parents("li"),
$msg_admin = $li.find(".msg-admin"),
$msg_user = $li.find(".msg-user"),
$chkbox = $li.find("input[name=admin]");
// toggle admin privileges
$(".btn-admin-change").click(function() {
var $li = $(this).parents("li"),
$msg_admin = $li.find(".msg-admin"),
$msg_user = $li.find(".msg-user"),
$chkbox = $li.find("input[name=admin]");

if($chkbox.is(":checked")) // is admin
{
$msg_admin.hide();
$msg_user.show();
$chkbox.attr("checked", "");
}
else
{
$msg_admin.show();
$msg_user.hide();
$chkbox.attr("checked", "checked");
}
if($chkbox.is(":checked")) // is admin
{
$msg_admin.hide();
$msg_user.show();
$chkbox.attr("checked", "");
}
else
{
$msg_admin.show();
$msg_user.hide();
$chkbox.attr("checked", "checked");
}

return false;
});
return false;
});
}
});
});
});
Expand Down Expand Up @@ -623,7 +636,8 @@ function peeq()
// redirect
document.location.href = "http://yss.com";
});
})
});

};

// setup modals
Expand Down Expand Up @@ -656,7 +670,11 @@ function peeq()
$(this).remove();
});
}
});
}).find("form").lastfieldentersubmit({ // whenever a user presses enter in the last input field of the form it will fire .btn-submit (submitting the form)
submit: function($frm) {
$frm.find(".btn-submit").click();
}
});

$(".btn-modal").click(function() {
$(".modal"+ get_modal_view(this)).jqmShow();
Expand Down
Loading

0 comments on commit e5430c9

Please sign in to comment.