Skip to content

Commit

Permalink
Switch streams page over to use consistent buttons.
Browse files Browse the repository at this point in the history
(imported from commit c4d7f658f361a759a38951349e027ac3e279fe9b)
  • Loading branch information
wdaher committed Mar 5, 2014
1 parent 66ecc7a commit a9f01e3
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 68 deletions.
8 changes: 4 additions & 4 deletions static/js/custom_markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ var exports = {};

function display_subscribe($button, stream_name) {
$button.text('Subscribe to ' + stream_data.canonicalized_name(stream_name))
.removeClass('green-button')
.addClass('gray-button');
.removeClass('btn-success')
.addClass('btn-default');
}

function display_unsubscribe($button, stream_name) {
$button.text('Unsubscribe from ' + stream_data.canonicalized_name(stream_name))
.removeClass('gray-button')
.addClass('green-button');
.removeClass('btn-default')
.addClass('btn-success');
}

function update_button_display($button, stream_name) {
Expand Down
8 changes: 4 additions & 4 deletions static/js/subs.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ exports.mark_subscribed = function (stream_name, attrs) {
var settings = settings_for_sub(sub);
var button = button_for_sub(sub);
if (button.length !== 0) {
button.text("Subscribed").addClass("subscribed-button").addClass("green-button");
button.text("Subscribed").addClass("subscribed-button").addClass("btn-success");
// Add the user to the member list if they're currently
// viewing the members of this stream
if (sub.render_subscribers && settings.hasClass('in')) {
Expand Down Expand Up @@ -359,7 +359,7 @@ exports.mark_sub_unsubscribed = function (sub) {
} else if (sub.subscribed) {
stream_list.remove_narrow_filter(sub.name, 'stream');
sub.subscribed = false;
button_for_sub(sub).removeClass("subscribed-button").removeClass("green-button").removeClass("red-button").text("Subscribe");
button_for_sub(sub).removeClass("subscribed-button").removeClass("btn-success").removeClass("btn-danger").text("Subscribe");
var settings = settings_for_sub(sub);
if (settings.hasClass('in')) {
settings.collapse('hide');
Expand Down Expand Up @@ -756,9 +756,9 @@ $(function () {
});

$("body").on("mouseover", ".subscribed-button", function (e) {
$(e.target).addClass("red-button").text("Unsubscribe");
$(e.target).addClass("btn-danger").text("Unsubscribe");
}).on("mouseout", ".subscribed-button", function (e) {
$(e.target).removeClass("red-button").text("Subscribed");
$(e.target).removeClass("btn-danger").text("Subscribed");
});

$("#subscriptions_table").on("click", ".email-address", function (e) {
Expand Down
44 changes: 0 additions & 44 deletions static/styles/zulip.css
Original file line number Diff line number Diff line change
Expand Up @@ -2571,47 +2571,13 @@ div.floating_recipient {
margin-right: 10px;
}

.zulip-button {
background-image: -moz-linear-gradient(top, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0) 100%); /* FF3.6+ */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.05)), color-stop(100%,rgba(0,0,0,0))); /* Chrome,Safari4+ */
background-image: -webkit-linear-gradient(top, rgba(0,0,0,0.05) 0%,rgba(0,0,0,0) 100%); /* Chrome10+,Safari5.1+ */
background-image: -o-linear-gradient(top, rgba(0,0,0,0.05) 0%,rgba(0,0,0,0) 100%); /* Opera 11.10+ */
background-image: -ms-linear-gradient(top, rgba(0,0,0,0.05) 0%,rgba(0,0,0,0) 100%); /* IE10+ */
background-image: linear-gradient(to bottom, rgba(0,0,0,0.05) 0%,rgba(0,0,0,0) 100%); /* W3C */
background-color: #ddd;
color: #000;
border: 1px solid #fff;
border-radius: 3px;
line-height: 20px;
padding: 5px 8px 5px 8px;
outline: none;
}

.zulip-button:focus {
box-shadow: inset 0px 100px 0px 0px rgba(255,255,255,0.2), 0px 0px 0px 1px rgba(0,0,0,0.2);
}

.zulip-button:hover {
background-image: -moz-linear-gradient(top, rgba(0,0,0,0.09) 0%, rgba(0,0,0,0) 100%); /* FF3.6+ */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.09)), color-stop(100%,rgba(0,0,0,0))); /* Chrome,Safari4+ */
background-image: -webkit-linear-gradient(top, rgba(0,0,0,0.09) 0%,rgba(0,0,0,0) 100%); /* Chrome10+,Safari5.1+ */
background-image: -o-linear-gradient(top, rgba(0,0,0,0.09) 0%,rgba(0,0,0,0) 100%); /* Opera 11.10+ */
background-image: -ms-linear-gradient(top, rgba(0,0,0,0.09) 0%,rgba(0,0,0,0) 100%); /* IE10+ */
background-image: linear-gradient(to bottom, rgba(0,0,0,0.09) 0%,rgba(0,0,0,0) 100%); /* W3C */
}

.sub_unsub_button {
min-width: 140px;
float: right;
margin-top: 9px;
margin-right: 10px;
}

.green-button {
background-color: #006e2e; /* Old browsers */
color: #fff;
}

button.primary {
background-color: #89a0b3;
padding: 2px;
Expand All @@ -2636,16 +2602,6 @@ button.topic_edit_cancel {
margin-top: -1px;
}

.red-button {
background-color: #cc0000;
color: #ffffff;
}

.blue-button {
background-color: #0000cc;
color: #ffffff;
}

.sub_arrow {
float: right;
line-height: 47px;
Expand Down
4 changes: 2 additions & 2 deletions static/templates/change_stream_privacy.handlebars
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{#if can_make_public}}
<button class="zulip-button blue-button make-stream-public-button" data-stream-name="{{name}}" tabindex="-1">
<button class="btn btn-primary make-stream-public-button" data-stream-name="{{name}}" tabindex="-1">
Make stream public
</button>
{{/if}}
{{#if can_make_private}}
<button class="zulip-button red-button make-stream-private-button" data-stream-name="{{name}}" tabindex="-1">
<button class="btn btn-danger make-stream-private-button" data-stream-name="{{name}}" tabindex="-1">
Make stream private
</button>
{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion static/templates/stream_member_list_entry.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="subscriber_list_remove">
<form class="form-inline remove-subscriber-form">
<input type="submit" name="unsubscribe" value="Unsubscribe"
class="zulip-button red-button remove-subscriber-button" />
class="btn btn-danger remove-subscriber-button" />
</form>
</div>
</td>
Expand Down
8 changes: 4 additions & 4 deletions static/templates/subscription.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<span class="subscription_description subscription-description-row">{{description}}</span>
</span>
<span class="sub_arrow"><i class="icon-vector-chevron-down"></i></span>
<button class="zulip-button sub_unsub_button {{^subscribed}}gray-button{{/subscribed}}{{#subscribed}} green-button subscribed-button{{/subscribed}}"
<button class="btn sub_unsub_button btn-default{{#subscribed}} btn-success subscribed-button{{/subscribed}}"
type="button" name="subscription">
{{#subscribed}}
Subscribed
Expand Down Expand Up @@ -74,14 +74,14 @@
<div class="rename-stream">
<form class="form-inline">
<input type="text" name="new-name" value="" class="input-block new-stream-name" tabindex="-1" />
<input type="submit" name="rename" value="Rename stream" class="zulip-button red-button stream-rename-button" tabindex="-1" />
<input type="submit" name="rename" value="Rename stream" class="btn btn-danger stream-rename-button" tabindex="-1" />
</form>
</div>
<div class="change-stream-description">
<form class="form-inline">
<input type="hidden" name="stream_name" value="{{name}}" />
<input type="text" name="description" value="{{description}}" class="input-block description" tabindex="-1" />
<input type="submit" name="change-stream-description" value="Change stream description" class="zulip-button red-button change-stream-description-button" tabindex="-1" />
<input type="submit" name="change-stream-description" value="Change stream description" class="btn btn-danger change-stream-description-button" tabindex="-1" />
</form>
</div>
<div class="change-stream-privacy">
Expand All @@ -96,7 +96,7 @@
<div class="subscriber_list_add">
<form class="form-inline">
<input type="text" name="principal" placeholder="Email address" value="" class="input-block" tabindex="-1" />
<input type="submit" name="add_subscriber" value="Add" class="zulip-button blue-button add-subscriber-button" tabindex="-1 "/>
<input type="submit" name="add_subscriber" value="Add" class="btn btn-primary add-subscriber-button" tabindex="-1 "/>
</form>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion static/templates/subscription_table_body.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<form id="add_new_subscription" class="form-inline" action="">
<input type="text" name="stream_name" id="create_stream_name"
placeholder="Stream name" value="" />
<input type="submit" class="zulip-button blue-button"
<input type="submit" class="btn btn-primary"
id="create_stream_button" value="Create new stream" />
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion zerver/lib/bugdown/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def handleMatch(self, match):

button = markdown.util.etree.SubElement(span, 'button')
button.text = 'Subscribe to ' + stream_name
button.set('class', 'inline-subscribe-button zulip-button')
button.set('class', 'inline-subscribe-button btn')

error = markdown.util.etree.SubElement(span, 'span')
error.set('class', 'inline-subscribe-error')
Expand Down
8 changes: 4 additions & 4 deletions zerver/test_bugdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def test_stream_subscribe_button_simple(self):
converted,
'<p>'
'<span class="inline-subscribe" data-stream-name="simple">'
'<button class="inline-subscribe-button zulip-button">Subscribe to simple</button>'
'<button class="inline-subscribe-button btn">Subscribe to simple</button>'
'<span class="inline-subscribe-error"></span>'
'</span>'
'</p>'
Expand All @@ -336,7 +336,7 @@ def test_stream_subscribe_button_in_name(self):
converted,
'<p>'
'<span class="inline-subscribe" data-stream-name="simple (not)">'
'<button class="inline-subscribe-button zulip-button">Subscribe to simple (not)</button>'
'<button class="inline-subscribe-button btn">Subscribe to simple (not)</button>'
'<span class="inline-subscribe-error"></span>'
'</span>'
'</p>'
Expand All @@ -349,7 +349,7 @@ def test_stream_subscribe_button_after_name(self):
converted,
'<p>'
'<span class="inline-subscribe" data-stream-name="simple">'
'<button class="inline-subscribe-button zulip-button">Subscribe to simple</button>'
'<button class="inline-subscribe-button btn">Subscribe to simple</button>'
'<span class="inline-subscribe-error"></span>'
'</span>'
' (not)</p>'
Expand All @@ -362,7 +362,7 @@ def test_stream_subscribe_button_slash(self):
converted,
'<p>'
'<span class="inline-subscribe" data-stream-name="simple\\">'
'<button class="inline-subscribe-button zulip-button">Subscribe to simple\\</button>'
'<button class="inline-subscribe-button btn">Subscribe to simple\\</button>'
'<span class="inline-subscribe-error"></span>'
'</span>'
'</p>'
Expand Down
6 changes: 3 additions & 3 deletions zerver/tests/frontend/tests/04-subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ casper.then(function () {
casper.then(function () {
casper.test.assertTextExists('Subscribed', 'Initial subscriptions loaded');
casper.fill('form#add_new_subscription', {stream_name: 'Waseemio'});
casper.click('form#add_new_subscription input.zulip-button');
casper.click('form#add_new_subscription input.btn');
casper.waitForText('Waseemio');
});
casper.then(function () {
Expand All @@ -29,13 +29,13 @@ casper.then(function () {
casper.then(function () {
casper.test.assertSelectorHasText('.subscription_name', 'Waseemio', 'Subscribing to a stream');
casper.fill('form#add_new_subscription', {stream_name: 'WASeemio'});
casper.click('form#add_new_subscription input.zulip-button');
casper.click('form#add_new_subscription input.btn');
casper.waitForText('Already subscribed');
});
casper.then(function () {
casper.test.assertTextExists('Already subscribed', "Can't subscribe twice to a stream");
casper.fill('form#add_new_subscription', {stream_name: ' '});
casper.click('form#add_new_subscription input.zulip-button');
casper.click('form#add_new_subscription input.btn');
casper.waitForText('Error adding subscription');
});
casper.then(function () {
Expand Down

0 comments on commit a9f01e3

Please sign in to comment.