Allow user to pre-select target for new snipt.

master
Nick Sergeant 2015-10-19 00:41:24 -04:00
parent fc2b5c424d
commit 39cab89c49
9 changed files with 80 additions and 45 deletions

File diff suppressed because one or more lines are too long

View File

@ -209,10 +209,10 @@ header.main {
float: right; float: right;
margin-right: 13px; margin-right: 13px;
} }
&.teams-nav { &.teams-nav, &.add-snipt {
position: relative; position: relative;
ul { > ul {
background: transparent url('../img/aside-nav-open-bottom-bg.gif') top left repeat; background: transparent url('../img/aside-nav-open-bottom-bg.gif') top left repeat;
display: none; display: none;
left: -5px; left: -5px;
@ -259,6 +259,10 @@ header.main {
display: block; display: block;
} }
} }
span.as {
color: #7C8D8E;
margin-right: 2px;
}
} }
} }
} }

View File

@ -43,6 +43,7 @@
this.$aside_main = $('aside.main', this.$body); this.$aside_main = $('aside.main', this.$body);
this.$aside_nav = $('aside.nav', this.$body); this.$aside_nav = $('aside.nav', this.$body);
this.$teams_nav = $('li.teams-nav', this.$body); this.$teams_nav = $('li.teams-nav', this.$body);
this.$add_snipt = $('li.add-snipt', this.$body);
this.$aside_nav_ul = $('ul', this.$aside_nav); this.$aside_nav_ul = $('ul', this.$aside_nav);
this.$search_form = $('form.search', this.$body); this.$search_form = $('form.search', this.$body);
this.$search_query = $('input#search-query', this.$body); this.$search_query = $('input#search-query', this.$body);
@ -71,6 +72,7 @@
} }
that.$aside_nav.removeClass('open'); that.$aside_nav.removeClass('open');
that.$teams_nav.removeClass('open'); that.$teams_nav.removeClass('open');
that.$add_snipt.removeClass('open');
}); });
this.$aside_nav_ul.click(function(e) { this.$aside_nav_ul.click(function(e) {

View File

@ -110,10 +110,6 @@
var $selectLexer = $('select#id_lexer', window.site.$main_edit); var $selectLexer = $('select#id_lexer', window.site.$main_edit);
$selectLexer.chosen(); $selectLexer.chosen();
// Init user
var $selectUser = $('select#id_user', window.site.$main_edit);
$selectUser.chosen();
// Blog post // Blog post
$('label.blog-post input', window.site.$main_edit).change(function() { $('label.blog-post input', window.site.$main_edit).change(function() {
var $checkbox = $(this); var $checkbox = $(this);
@ -225,15 +221,21 @@
if (window.editor_theme != 'default') { if (window.editor_theme != 'default') {
$selectTheme.val(window.editor_theme); $selectTheme.val(window.editor_theme);
$selectTheme.trigger('liszt:updated'); $selectTheme.trigger('chosen:updated');
$selectTheme.trigger('change'); $selectTheme.trigger('change');
} }
if (window.default_editor != 'codemirror') { if (window.default_editor != 'codemirror') {
$selectEditor.val(window.default_editor); $selectEditor.val(window.default_editor);
$selectEditor.trigger('liszt:updated'); $selectEditor.trigger('chosen:updated');
$selectEditor.trigger('change'); $selectEditor.trigger('change');
} }
// Init user
var $selectUser = $('select#id_user', window.site.$main_edit);
$selectUser.chosen();
$selectUser.val(window.intended_user);
$selectUser.trigger('chosen:updated');
// Full-screen mode. // Full-screen mode.
this.setupCodeMirrorFullScreen(); this.setupCodeMirrorFullScreen();
@ -600,8 +602,22 @@
} }
$('span.cmd-ctrl').text(cmd); $('span.cmd-ctrl').text(cmd);
$('button#add-snipt').click(function() { var $buttonAddSnipt = $('button#add-snipt');
that.addNewSnipt(); $buttonAddSnipt.click(function(e) {
if (window.teams.length) {
e.stopPropagation();
$buttonAddSnipt.parent().toggleClass('open');
} else {
that.addNewSnipt();
}
});
var $addSniptTeams = $('ul.add-snipt-teams a');
$addSniptTeams.click(function(e) {
e.stopPropagation();
window.intended_user = $(e.target).attr('data-intended-user') ||
$(e.target).parent().attr('data-intended-user');
that.addNewSnipt();
}); });
}, },

View File

@ -1,12 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block add-snipt %} {% block add-snipt %}
<li class="add-snipt"> {% include 'add-snipt.html' %}
<button class="btn btn-info btn-large" id="add-snipt">
Add {% if request.user.username == 'blog' %}Post{% else %}Snipt{% endif %}
<i class="icon-search icon-plus icon-white"></i>
</button>
</li>
{% endblock %} {% endblock %}
{% block page-title %}/ {% if snipt.title %}{{ snipt.title }}{% else %}Untitled{% endif %} / {{ user.username }} - {{ block.super }}{% endblock %} {% block page-title %}/ {% if snipt.title %}{{ snipt.title }}{% else %}Untitled{% endif %} / {{ user.username }} - {{ block.super }}{% endblock %}

View File

@ -1,12 +1,7 @@
{% extends "snipts/list.html" %} {% extends "snipts/list.html" %}
{% block add-snipt %} {% block add-snipt %}
<li class="add-snipt"> {% include 'add-snipt.html' %}
<button class="btn btn-info btn-large" id="add-snipt">
Add {% if request.user.username == 'blog' %}Post{% else %}Snipt{% endif %}
<i class="icon-search icon-plus icon-white"></i>
</button>
</li>
{% endblock %} {% endblock %}
{% block breadcrumb %} {% block breadcrumb %}

View File

@ -1,12 +1,7 @@
{% extends "snipts/list.html" %} {% extends "snipts/list.html" %}
{% block add-snipt %} {% block add-snipt %}
<li class="add-snipt"> {% include 'add-snipt.html' %}
<button class="btn btn-info btn-large" id="add-snipt">
Add {% if request.user.username == 'blog' %}Post{% else %}Snipt{% endif %}
<i class="icon-search icon-plus icon-white"></i>
</button>
</li>
{% endblock %} {% endblock %}
{% block breadcrumb %} {% block breadcrumb %}

26
templates/add-snipt.html Normal file
View File

@ -0,0 +1,26 @@
<li class="add-snipt">
<button class="btn btn-info btn-large" id="add-snipt">
Add {% if request.user.username == 'blog' %}Post{% else %}Snipt{% endif %}
<i class="icon-search icon-plus icon-white"></i>
</button>
{% if request.user.profile.has_teams %}
<ul class="add-snipt-teams">
<li>
<a href data-intended-user="{{ request.user.username }}">
<i class="icon-user icon-white"></i>
<span class="as">as</span>
<span>{{ request.user.username }}</span>
</a>
</li>
{% for team in request.user.profile.teams|dictsort:'name' %}
<li>
<a href data-intended-user="{{ team.user.username }}">
<i class="icon-user icon-white"></i>
<span class="as">under</span>
<span>{{ team.name }}</span>
</a>
</li>
{% endfor %}
</ul>
{% endif %}
</li>

View File

@ -113,22 +113,24 @@
{% else %} {% else %}
<li class="teams-nav"> <li class="teams-nav">
<a href="#" class="teams-nav {% if '/for-teams/' in request.path %}active{% endif %}">Teams</a> <a href="#" class="teams-nav {% if '/for-teams/' in request.path %}active{% endif %}">Teams</a>
<ul> {% if request.user.profile.has_teams %}
{% for team in request.user.profile.teams|dictsort:'name' %} <ul>
<li> {% for team in request.user.profile.teams|dictsort:'name' %}
<a href="/{{ team.user.username }}/"> <li>
<i class="icon-user icon-white"></i> <a href="/{{ team.user.username }}/">
{{ team.name }} <i class="icon-user icon-white"></i>
</a> {{ team.name }}
</li> </a>
{% endfor %} </li>
<li> {% endfor %}
<a href="/for-teams/"> <li>
<i class="icon-plus icon-white"></i> <a href="/for-teams/">
Create new team <i class="icon-plus icon-white"></i>
</a> Create new team
</li> </a>
</ul> </li>
</ul>
{% endif %}
</li> </li>
{% endif %} {% endif %}
</ul> </ul>