summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-08-31 12:47:10 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-08-31 12:47:10 -0400
commitb7aee071c30818bbd4d297e7bb92d3cbb3f38a5e (patch)
tree7545bfbc7a930d8f88cb657af970113e19a80888
parentff6a34c180ba314c9f7e7c0e720599125aa42ad4 (diff)
parent06db492c1fa8cc36dd30cfed22da6521fa4535d4 (diff)
downloadaskbot-b7aee071c30818bbd4d297e7bb92d3cbb3f38a5e.tar.gz
askbot-b7aee071c30818bbd4d297e7bb92d3cbb3f38a5e.tar.bz2
askbot-b7aee071c30818bbd4d297e7bb92d3cbb3f38a5e.zip
Merge branch 'adolfo' into user-groups
-rw-r--r--askbot/forms.py29
-rw-r--r--askbot/models/widgets.py7
-rw-r--r--askbot/skins/common/media/js/live_search_new_thread.js22
-rw-r--r--askbot/skins/default/media/style/style.css24
-rw-r--r--askbot/skins/default/media/style/style.less26
-rw-r--r--askbot/skins/default/templates/embed/ask_by_widget.html90
-rwxr-xr-xaskbot/skins/default/templates/embed/askbot_widget.css21
-rwxr-xr-xaskbot/skins/default/templates/embed/askbot_widget.js16
-rw-r--r--askbot/views/commands.py3
-rw-r--r--askbot/views/widgets.py21
10 files changed, 181 insertions, 78 deletions
diff --git a/askbot/forms.py b/askbot/forms.py
index b75bf6f0..0ed888a5 100644
--- a/askbot/forms.py
+++ b/askbot/forms.py
@@ -925,6 +925,7 @@ class AskWidgetForm(forms.Form, FormWithHideableFields):
class CreateAskWidgetForm(forms.Form, FormWithHideableFields):
title = forms.CharField(max_length=100)
+ include_text_field = forms.BooleanField(required=False)
inner_style = forms.CharField(
widget=forms.Textarea,
@@ -938,14 +939,14 @@ class CreateAskWidgetForm(forms.Form, FormWithHideableFields):
def __init__(self, *args, **kwargs):
from askbot.models import Tag
super(CreateAskWidgetForm, self).__init__(*args, **kwargs)
- self.fields['group'] = forms.ModelChoiceField(
- queryset=get_groups().exclude(name__startswith='_internal_'),
- required=False
- )
- self.fields['tag'] = forms.ModelChoiceField(queryset=Tag.objects.get_content_tags(),
+ #self.fields['group'] = forms.ModelChoiceField(
+ # queryset=get_groups().exclude(name__startswith='_internal_'),
+ # required=False
+ #)
+ self.fields['tag'] = forms.ModelChoiceField(queryset=Tag.objects.get_content_tags(),
required=False)
- if not askbot_settings.GROUPS_ENABLED:
- self.hide_field('group')
+ #if not askbot_settings.GROUPS_ENABLED:
+ # self.hide_field('group')
class CreateQuestionWidgetForm(forms.Form, FormWithHideableFields):
title = forms.CharField(max_length=100)
@@ -953,22 +954,22 @@ class CreateQuestionWidgetForm(forms.Form, FormWithHideableFields):
tagnames = forms.CharField(label=_('tags'), max_length=50)
search_query = forms.CharField(max_length=50, required=False)
order_by = forms.ChoiceField(
- choices=const.SEARCH_ORDER_BY,
+ choices=const.SEARCH_ORDER_BY,
initial='-added_at'
)
style = forms.CharField(
- widget=forms.Textarea,
- initial=const.DEFAULT_QUESTION_WIDGET_STYLE,
+ widget=forms.Textarea,
+ initial=const.DEFAULT_QUESTION_WIDGET_STYLE,
required=False
)
def __init__(self, *args, **kwargs):
super(CreateQuestionWidgetForm, self).__init__(*args, **kwargs)
self.fields['tagnames'] = TagNamesField()
- self.fields['group'] = forms.ModelChoiceField(
- queryset=get_groups().exclude(name__startswith='_internal'),
- required=False
- )
+ #self.fields['group'] = forms.ModelChoiceField(
+ # queryset=get_groups().exclude(name__startswith='_internal'),
+ # required=False
+ #)
class AskByEmailForm(forms.Form):
""":class:`~askbot.forms.AskByEmailForm`
diff --git a/askbot/models/widgets.py b/askbot/models/widgets.py
index 4ea80468..86f3b471 100644
--- a/askbot/models/widgets.py
+++ b/askbot/models/widgets.py
@@ -6,8 +6,8 @@ from askbot.const import DEFAULT_QUESTION_WIDGET_STYLE, SEARCH_ORDER_BY
class AskWidget(models.Model):
'''stores widgets styles and options'''
title = models.CharField(max_length=100)
- group = models.ForeignKey(Group, null=True, blank=True,
- related_name='groups')
+ #group = models.ForeignKey(Group, null=True, blank=True,
+ # related_name='groups')
tag = models.ForeignKey(Tag, null=True, blank=True)
include_text_field = models.BooleanField(default=False, blank=True)
@@ -32,7 +32,8 @@ class QuestionWidget(models.Model):
title = models.CharField(max_length=100)
question_number = models.PositiveIntegerField(default=7)
tagnames = models.CharField(_('tags'), max_length=50)
- group = models.ForeignKey(Tag, null=True, blank=True)
+ #group = models.ForeignKey(Tag, null=True, blank=True)
+ #group = models.ForeignKey(Group, null=True, blank=True)
search_query = models.CharField(
max_length=50, null=True, blank=True, default=''
)
diff --git a/askbot/skins/common/media/js/live_search_new_thread.js b/askbot/skins/common/media/js/live_search_new_thread.js
index 38170692..eedd5fe8 100644
--- a/askbot/skins/common/media/js/live_search_new_thread.js
+++ b/askbot/skins/common/media/js/live_search_new_thread.js
@@ -1,5 +1,5 @@
-var liveSearchNewThreadInit = function() {
+var liveSearchNewThreadInit = function(auto_focus_out) {
var query = $('input#id_title.questionTitleInput');
var prev_text = $.trim(query.val());
var search_url = askbot['urls']['api_get_questions'];
@@ -15,16 +15,27 @@ var liveSearchNewThreadInit = function() {
}
});
+ query.focusout(function(){
+ if (auto_focus_out){
+ var restart_query_handle = setTimeout(restart_query, 500);
+ restart_query_handle();
+ }
+ });
+
+ var restart_query = function(){
+ /* restart query */
+ $('#' + q_list_sel).css('height',0).children().remove();
+ running = false;
+ prev_text = '';
+ }
+
var eval_query = function(){
cur_text = $.trim(query.val());
if (cur_text !== prev_text && running === false){
if (cur_text.length >= minSearchWordLength){
send_query(cur_text);
} else if (cur_text.length === 0){
- /* restart query */
- $('#' + q_list_sel).css('height',0).children().remove();
- running = false;
- prev_text = '';
+ restart_query();
}
}
};
@@ -79,5 +90,4 @@ var liveSearchNewThreadInit = function() {
cache: false
});
}
-
};
diff --git a/askbot/skins/default/media/style/style.css b/askbot/skins/default/media/style/style.css
index ca9ed050..bdba3c28 100644
--- a/askbot/skins/default/media/style/style.css
+++ b/askbot/skins/default/media/style/style.css
@@ -285,7 +285,7 @@ body.user-messages {
#metaNav a {
color: #e2e2ae;
padding: 0px 0px 0px 35px;
- height: 25px;
+ height: 35px;
line-height: 25px;
margin: 5px 0px 0px 10px;
font-size: 18px;
@@ -327,17 +327,16 @@ body.user-messages {
margin: 5px 0px 5px 10px;
}
#metaNav input.group-name {
- border-top: none;
- border-left: none;
- border-right: none;
- border-bottom: #e2e2ae 1px solid;
- color: #e2e2ae;
+ border: none;
height: 25px;
font-size: 18px;
font-weight: 100;
text-decoration: none;
display: block;
- float: left;
+ margin: 0px 10px 0px 10px;
+ width: 140px;
+ font-family: 'Open Sans Condensed', Arial, sans-serif;
+ font-weight: 100;
}
#metaNav input.group-name:focus {
border: none;
@@ -348,12 +347,20 @@ body.user-messages {
#metaNav span.dropdown:hover ul.dropdown-menu {
display: block;
}
+#metaNav div.dropdown-container:hover ul.dropdown-menu {
+ display: block;
+}
#metaNav .dropdown {
float: left;
}
#metaNav .dropdown-menu {
+ border-top: none;
left: 7%;
}
+#metaNav .dropdown-menu a {
+ color: #666;
+ height: 25px;
+}
#header.with-logo #userToolsNav {
position: absolute;
bottom: 0;
@@ -363,9 +370,6 @@ body.user-messages {
float: left;
margin-top: 7px;
}
-#header.without-logo #metaNav {
- margin-bottom: 7px;
-}
#secondaryHeader {
/* Div containing Home button, scope navigation, search form and ask button, check blocks/secondary_header.html */
diff --git a/askbot/skins/default/media/style/style.less b/askbot/skins/default/media/style/style.less
index a381c29a..de7b3657 100644
--- a/askbot/skins/default/media/style/style.less
+++ b/askbot/skins/default/media/style/style.less
@@ -281,7 +281,7 @@ body.user-messages {
a {
color: #e2e2ae;
padding: 0px 0px 0px 35px;
- height: 25px;
+ height: 35px;
line-height: 25px;
margin:5px 0px 0px 10px;
font-size: 18px;
@@ -332,18 +332,16 @@ body.user-messages {
}
input.group-name{
- border-top:none;
- border-left:none;
- border-right:none;
- border-bottom: #e2e2ae 1px solid;
- color: #e2e2ae;
+ border:none;
height: 25px;
font-size: 18px;
font-weight: 100;
text-decoration: none;
display: block;
- float: left;
-
+ margin: 0px 10px 0px 10px;
+ width: 140px;
+ font-family: 'Open Sans Condensed', Arial, sans-serif;
+ font-weight: 100;
}
input.group-name:focus{
@@ -358,12 +356,21 @@ body.user-messages {
display: block;
}
+ div.dropdown-container:hover ul.dropdown-menu {
+ display: block;
+ }
+
.dropdown {
float:left;
}
.dropdown-menu{
+ border-top: none;
left: 7%;
+ a{
+ color: #666;
+ height: 25px;
+ }
}
}
@@ -379,9 +386,6 @@ body.user-messages {
margin-top: 7px;
}
-#header.without-logo #metaNav {
- margin-bottom: 7px;
-}
#secondaryHeader{ /* Div containing Home button, scope navigation, search form and ask button, check blocks/secondary_header.html */
height:55px;
diff --git a/askbot/skins/default/templates/embed/ask_by_widget.html b/askbot/skins/default/templates/embed/ask_by_widget.html
index 3a5e7bb0..5eb3d664 100644
--- a/askbot/skins/default/templates/embed/ask_by_widget.html
+++ b/askbot/skins/default/templates/embed/ask_by_widget.html
@@ -4,28 +4,43 @@
{% if editor_type == 'markdown' %}
<link rel="stylesheet" type="text/css" href="{{"/js/wmd/wmd.css"|media}}" />
{%endif%}
+ {% if settings.USE_LOCAL_FONTS %}
+ {% include "meta/fonts.html" %}
+ {% else %}
+ <link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:400,700&amp;subset=latin,cyrillic-ext,latin-ext' rel='stylesheet' type='text/css' />
+ {% endif %}
<style type="text/css" media="screen">
+ body{
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ }
#editor {
display: block;
min-height: 200px;
- width: 99.5%;
+ width: 98%;
margin: 0;
border:none;
+ outline:none;
+ padding: 6px;
}
.wmd-container{
border: #CCE6EC 3px solid;
width: 100%;
+ margin-top: 20px;
}
#id_title{
+ {% if editor_type == 'markdown' %}
width: 100%;
+ {%else%}
+ padding: 0px 0 0 5px;
+ width: 99.2%;
+ {%endif%}
font-size: 130%;
border: #CCE6EC 3px solid;
+ max-width: 600px;
}
-
- #submit{
- float: right;
- font-size: 130%;
+ #id_title:focus {
+ outline: none;
}
.title{
@@ -36,23 +51,38 @@
#question-list {
height: auto;
+ z-index: 10000;
+ position: absolute;
+ border: 3px solid #CCE6EC;
+ border-top:none;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px;
+ background: #fff;
+ width:97.4%;
+ margin-top: -4.9px;
}
#question-list h2{
text-decoration: none;
margin: 0px;
font-size: 13px;
- color: #005580;
padding: 3px 0 3px 5px;
- margin-left: 15px;
padding-bottom: 0;
border-top: #F0F0EC 1px solid;
- border-left: #F0F0EC 1px solid;
min-height: 30px;
line-height: 30px;
font-weight: normal
}
+ #question-list h2:first-child{
+ border-top: none;
+ }
+
+ #question-list a{
+ color: #005580;
+ }
+
#question-list a:hover{
color: #005580;
text-decoration: underline;
@@ -88,6 +118,38 @@
}
{% endif %}
+ #submit{
+ font-size: 130%;
+ margin-right: -6px;
+ float: right;
+ text-align: center;
+ text-decoration: none;
+ cursor: pointer;
+ color: #4A757F;
+ font-family: 'Open Sans Condensed', Arial, sans-serif;
+ text-shadow: 0px 1px 0px #C6D9DD;
+ -moz-text-shadow: 0px 1px 0px #c6d9dd;
+ -webkit-text-shadow: 0px 1px 0px #c6d9dd;
+ border-top: #EAF2F3 1px solid;
+ background-color: #D1E2E5;
+ background-repeat: no-repeat;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#D1E2E5), color-stop(25%, #D1E2E5), to(#A9C2C7));
+ background-image: -webkit-linear-gradient(#D1E2E5, #D1E2E5 25%, #A9C2C7);
+ background-image: -moz-linear-gradient(top, #D1E2E5, #D1E2E5 25%, #A9C2C7);
+ background-image: -ms-linear-gradient(#D1E2E5, #D1E2E5 25%, #A9C2C7);
+ background-image: -o-linear-gradient(#D1E2E5, #D1E2E5 25%, #A9C2C7);
+ background-image: linear-gradient(#D1E2E5, #D1E2E5 25%, #A9C2C7);
+ border-radius: 4px;
+ -ms-border-radius: 4px;
+ -moz-border-radius: 4px;
+ -webkit-border-radius: 4px;
+ -khtml-border-radius: 4px;
+ -webkit-box-shadow: 1px 1px 2px #636363;
+ -moz-box-shadow: 1px 1px 2px #636363;
+ box-shadow: 1px 1px 2px #636363;
+ width: 200px;
+ }
+
{{widget.inner_style}}
</style>
{%endblock%}
@@ -97,11 +159,11 @@
<form action="." method="POST" accept-charset="utf-8">
{% csrf_token %}
<label>{%trans%}Please enter a descriptive title for your question{%endtrans%}</label>
- <input autocomplete="off" id="id_title" type="text" name="title" size="70" class='questionTitleInput'>
- {% if related_questions %}
+ <div class="input-title">
+ <input autocomplete="off" id="id_title" type="text" name="title" size="70" class='questionTitleInput'>
+ </div>
<div id='question-list'>
</div>
- {%endif%}
{% if widget.include_text_field %}
{% if editor_type == 'markdown' %}
<div class="wmd-container">
@@ -127,7 +189,10 @@
<script type="text/javascript" charset="utf-8">
var minSearchWordLength = {{settings.MIN_SEARCH_WORD_LENGTH}};
askbot['urls']['api_get_questions'] = '{% url api_get_questions %}';
- liveSearchNewThreadInit();
+ liveSearchNewThreadInit(true);
+ $(document).ready(function(){
+ $("#id_title").focus();
+ });
</script>
<script type='text/javascript' src='{{"/js/editor.js"|media}}'></script>
@@ -138,3 +203,4 @@
{% include "meta/tinymce.html" %}
{% endif %}
{% endblock %}
+ \ No newline at end of file
diff --git a/askbot/skins/default/templates/embed/askbot_widget.css b/askbot/skins/default/templates/embed/askbot_widget.css
index d2a75a1f..b51a87f8 100755
--- a/askbot/skins/default/templates/embed/askbot_widget.css
+++ b/askbot/skins/default/templates/embed/askbot_widget.css
@@ -12,7 +12,11 @@
#{{variable_name}} div{
width:600px;
{%if widget.include_text_field%}
- height:450px;
+ {% if editor_type == 'markdown' %}
+ height:480px;
+ {%else%}
+ height:500px;
+ {%endif%}
{%else%}
height:210px;
{%endif%}
@@ -20,10 +24,19 @@
background-color: #fff;
border:1px solid #000;
padding:15px;
- text-align:right;
+ padding-left: 10px;
+ text-align: right;
+}
+
+#{{variable_name}} a{
+ padding:5px;
}
#{{variable_name}} iframe{
width:600px;
- height:450px;
-}
+ {% if editor_type == 'markdown' %}
+ height:480px;
+ {%else%}
+ height:520px;
+ {%endif%}
+} \ No newline at end of file
diff --git a/askbot/skins/default/templates/embed/askbot_widget.js b/askbot/skins/default/templates/embed/askbot_widget.js
index 57cead90..fa5fe731 100755
--- a/askbot/skins/default/templates/embed/askbot_widget.js
+++ b/askbot/skins/default/templates/embed/askbot_widget.js
@@ -3,6 +3,9 @@ var {{variable_name}} = {
widgetToggle: function() {
element = document.getElementById({{variable_name}}.element_id);
element.style.visibility = (element.style.visibility == "visible") ? "hidden" : "visible";
+ if (element.style.visibility == "visible"){
+ $("#" + {{variable_name}}.element_id + " iframe").focus();
+ }
},
toHtml: function() {
var html = {{variable_name}}.createButton();
@@ -14,7 +17,7 @@ var {{variable_name}} = {
//creating the div
var motherDiv = document.createElement('div');
motherDiv.setAttribute("id", {{variable_name}}.element_id);
- console.log(motherDiv);
+ motherDiv.style.visibility = "hidden";
var containerDiv = document.createElement('div');
motherDiv.appendChild(containerDiv);
@@ -29,7 +32,7 @@ var {{variable_name}} = {
closeButton.setAttribute('href', '#');
closeButton.setAttribute('id', 'AskbotModalClose');
closeButton.setAttribute('onClick', '{{variable_name}}.widgetToggle();');
- closeButton.innerText = 'Close';
+ closeButton.innerHTML= 'Close';
containerDiv.appendChild(closeButton);
@@ -40,7 +43,6 @@ var {{variable_name}} = {
var body = document.getElementsByTagName('body')[0];
if (body){
- console.log(body.firstChild);
body.insertBefore(motherDiv, body.firstChild);
body.insertBefore(link, body.firstChild);
}
@@ -50,9 +52,10 @@ var {{variable_name}} = {
var buttonDiv = document.createElement('div');
buttonDiv.setAttribute('id', "AskbotAskButton");
- var closeButton = document.createElement('button');
+ var closeButton = document.createElement('input');
closeButton.setAttribute('onClick', '{{variable_name}}.widgetToggle();');
- closeButton.innerText = label;
+ closeButton.setAttribute('type', 'button');
+ closeButton.value = label;
buttonDiv.appendChild(closeButton);
@@ -68,6 +71,5 @@ var onload_functions = function(){
{{variable_name}}.toHtml();
}
-console.log(onload_functions);
window.onload = onload_functions();
-document.write({{variable_name}}.createButton().outerHTML);
+document.write({{variable_name}}.createButton().outerHTML); \ No newline at end of file
diff --git a/askbot/views/commands.py b/askbot/views/commands.py
index 80d75445..da0beeca 100644
--- a/askbot/views/commands.py
+++ b/askbot/views/commands.py
@@ -941,8 +941,9 @@ def save_group_logo_url(request):
def add_group(request):
group_name = request.POST.get('group')
if group_name:
- group = models.Tag.group_tags.get_or_create(
+ group = models.Group.objects.get_or_create(
group_name=group_name,
+ is_open=True,
user=request.user,
)
diff --git a/askbot/views/widgets.py b/askbot/views/widgets.py
index 281c4cf9..41913d39 100644
--- a/askbot/views/widgets.py
+++ b/askbot/views/widgets.py
@@ -72,10 +72,10 @@ def ask_widget(request, widget_id):
text = ' '
- if widget.group:
- group_id = widget.group.id
- else:
- group_id = None
+ #if widget.group:
+ # group_id = widget.group.id
+ #else:
+ # group_id = None
if widget.tag:
tagnames = widget.tag.name
@@ -88,7 +88,7 @@ def ask_widget(request, widget_id):
'wiki': False,
'text': text,
'tagnames': tagnames,
- 'group_id': group_id,
+ #'group_id': group_id,
'is_anonymous': ask_anonymously
}
if request.user.is_authenticated():
@@ -117,7 +117,7 @@ def ask_widget(request, widget_id):
return redirect(next_url)
form = forms.AskWidgetForm(include_text=widget.include_text_field)
-
+
data = {
'form': form,
'widget': widget,
@@ -158,7 +158,7 @@ def create_widget(request, model):
if request.method == 'POST':
form = form_class(request.POST)
if form.is_valid():
- instance = model_class(**form.cleaned_data)
+ instance = model_class(**form.cleaned_data)
instance.save()
return redirect('list_widgets', model=model)
else:
@@ -178,7 +178,7 @@ def edit_widget(request, model, widget_id):
if request.method == 'POST':
form = form_class(request.POST)
if form.is_valid():
- instance = model_class(**form.cleaned_data)
+ instance = model_class(**form.cleaned_data)
instance.save()
return redirect('list_widgets', model=model)
else:
@@ -220,6 +220,7 @@ def render_ask_widget_css(request, widget_id):
content_tpl = get_template('embed/askbot_widget.css', request)
context_dict = {'widget': widget,
'host': request.get_host(),
+ 'editor_type': askbot_settings.EDITOR_TYPE,
'variable_name': variable_name}
content = content_tpl.render(Context(context_dict))
return HttpResponse(content, mimetype='text/css')
@@ -239,8 +240,8 @@ def question_widget(request, widget_id):
if widget.tagnames:
filter_params['tags__name__in'] = widget.tagnames.split(' ')
- if widget.group:
- filter_params['groups'] = widget.group
+ #if widget.group:
+ # filter_params['groups'] = widget.group
#simple title search for now
if widget.search_query: