From 3431a38f59499008143baca5490f0c1871027b95 Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Mon, 3 Oct 2011 11:35:45 -0300 Subject: Fixed issue 96: Add possibility to pre-populate tags when asking question via url parameters. --- askbot/views/writers.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/askbot/views/writers.py b/askbot/views/writers.py index fcc98761..2e783da1 100644 --- a/askbot/views/writers.py +++ b/askbot/views/writers.py @@ -267,6 +267,17 @@ def ask(request):#view used to ask a new question query = search_state.query form.initial['title'] = query + if 'tags' in request.GET: + #pre-populate tags. + clean_tags = request.GET['tags'].replace(',', ' ') + form.initial['tags'] = clean_tags + else: + #attemp to get tags from search state + search_state = request.session.get('search_state', None) + if search_state.tags: + tags = ' '.join(search_state.tags) + form.initial['tags'] = tags + data = { 'active_tab': 'ask', 'page_class': 'ask-page', -- cgit v1.2.3-1-g7c22 From 91befc92662173d24c64680328e34379268ee7b7 Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Mon, 3 Oct 2011 12:52:06 -0300 Subject: Fixes issue 80: make answering own questions harder. --- askbot/skins/default/templates/question.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/askbot/skins/default/templates/question.html b/askbot/skins/default/templates/question.html index 06cd1332..c9d0f61b 100644 --- a/askbot/skins/default/templates/question.html +++ b/askbot/skins/default/templates/question.html @@ -380,6 +380,9 @@ {% endif %} {% endif %} + {% if request.user == question.author %} + + {%endif%} {% endblock %} {% block sidebar %} @@ -529,6 +532,14 @@ $('#fmanswer textarea').focus(); } {% if settings.ENABLE_SHARING_GOOGLE %}$.getScript("http://apis.google.com/js/plusone.js"){% endif %} + + {% if request.user == question.author%} + $("#fmanswer").hide(); + $("#fmanswer_button").click(function() { + $("#fmanswer").show(); + $("#fmanswer_button").hide(); + }); + {%endif%} }); function initEditor(){ -- cgit v1.2.3-1-g7c22 From 322538fe62637fdf1d84b776fbc0f72636e69b6f Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Mon, 3 Oct 2011 13:24:22 -0300 Subject: Fixes: Tool tip to sort people in "people" page doesn't add much value http://askbot.org/en/question/662 --- askbot/skins/default/templates/users.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/askbot/skins/default/templates/users.html b/askbot/skins/default/templates/users.html index 750b3abb..3c9a7686 100644 --- a/askbot/skins/default/templates/users.html +++ b/askbot/skins/default/templates/users.html @@ -10,25 +10,25 @@ id="sort_reputation" href="{% url users %}?sort=reputation" {% if tab_id == 'reputation' %}class="on"{% endif %} - title="{% trans %}reputation{% endtrans %}" + title="{% trans %}People sorted by reputation{% endtrans %}" >{% trans %}reputation{% endtrans %} {% trans %}recent{% endtrans %} {% trans %}oldest{% endtrans %} {% trans %}by username{% endtrans %} -- cgit v1.2.3-1-g7c22 From 57f1cdf96b0499059ea9d98e129c379f273de83d Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Mon, 3 Oct 2011 16:41:32 -0300 Subject: Fixes(kind of): auto highlight #hash anchor on any url http://bugs.askbot.org/issues/83 --- askbot/skins/default/templates/question.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/askbot/skins/default/templates/question.html b/askbot/skins/default/templates/question.html index 06cd1332..637f8afb 100644 --- a/askbot/skins/default/templates/question.html +++ b/askbot/skins/default/templates/question.html @@ -529,6 +529,18 @@ $('#fmanswer textarea').focus(); } {% if settings.ENABLE_SHARING_GOOGLE %}$.getScript("http://apis.google.com/js/plusone.js"){% endif %} + var answer_id = window.location.hash.substring(1); + if (answer_id!=""){ + $("#answer-container-" + answer_id).addClass('highlight'); + $("#answer-container-" + answer_id).hide(); + $("#answer-container-" + answer_id).fadeIn(2000); + //using window.setTimeout + /*function foo(){ + $("#answer-container-" + answer_id).removeClass('highlight') + } + var timeout = window.setTimeout(foo, 2000); + */ + } }); function initEditor(){ -- cgit v1.2.3-1-g7c22 From b3c632906e64828edc9e8b544428411ebf80f57e Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Mon, 3 Oct 2011 19:02:59 -0300 Subject: Changed the effect to be used with jquery.color.js Fixed bug in jquery.color.js to make it work with askbot. --- askbot/skins/default/media/js/jquery.color.js | 124 ++++++++++++++++++++++++++ askbot/skins/default/media/js/utils.js | 1 + askbot/skins/default/templates/question.html | 12 +-- 3 files changed, 128 insertions(+), 9 deletions(-) create mode 100644 askbot/skins/default/media/js/jquery.color.js diff --git a/askbot/skins/default/media/js/jquery.color.js b/askbot/skins/default/media/js/jquery.color.js new file mode 100644 index 00000000..ad5decd0 --- /dev/null +++ b/askbot/skins/default/media/js/jquery.color.js @@ -0,0 +1,124 @@ +/* + * jQuery Color Animations + * Copyright 2007 John Resig + * Released under the MIT and GPL licenses. + */ + +(function(jQuery){ + + // We override the animation for all of these color styles + jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){ + jQuery.fx.step[attr] = function(fx){ + if ( fx.state == 0 ) { + fx.start = getColor( fx.elem, attr ); + fx.end = getRGB( fx.end ); + } + + fx.elem.style[attr] = "rgb(" + [ + Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0), + Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0), + Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0) + ].join(",") + ")"; + } + }); + + // Color Conversion functions from highlightFade + // By Blair Mitchelmore + // http://jquery.offput.ca/highlightFade/ + + // Parse strings looking for color tuples [255,255,255] + function getRGB(color) { + var result; + + // Check if we're already dealing with an array of colors + if ( color && color.constructor == Array && color.length == 3 ) + return color; + + // Look for rgb(num,num,num) + if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) + return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])]; + + // Look for rgb(num%,num%,num%) + if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) + return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55]; + + // Look for #a0b1c2 + if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) + return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)]; + + // Look for #fff + if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) + return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)]; + + // Otherwise, we're most likely dealing with a named color + return colors[jQuery.trim(color).toLowerCase()]; + } + + function getColor(elem, attr) { + var color; + + do { + color = jQuery.curCSS(elem, attr); + + // Keep going until we find an element that has color, or we hit the body + if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") ) + break; + + attr = "backgroundColor"; + } while ( elem = elem.parentNode ); + + return getRGB(color); + }; + + // Some named colors to work with + // From Interface by Stefan Petre + // http://interface.eyecon.ro/ + + var colors = { + aqua:[0,255,255], + azure:[240,255,255], + beige:[245,245,220], + black:[0,0,0], + blue:[0,0,255], + brown:[165,42,42], + cyan:[0,255,255], + darkblue:[0,0,139], + darkcyan:[0,139,139], + darkgrey:[169,169,169], + darkgreen:[0,100,0], + darkkhaki:[189,183,107], + darkmagenta:[139,0,139], + darkolivegreen:[85,107,47], + darkorange:[255,140,0], + darkorchid:[153,50,204], + darkred:[139,0,0], + darksalmon:[233,150,122], + darkviolet:[148,0,211], + fuchsia:[255,0,255], + gold:[255,215,0], + green:[0,128,0], + indigo:[75,0,130], + khaki:[240,230,140], + lightblue:[173,216,230], + lightcyan:[224,255,255], + lightgreen:[144,238,144], + lightgrey:[211,211,211], + lightpink:[255,182,193], + lightyellow:[255,255,224], + lime:[0,255,0], + magenta:[255,0,255], + maroon:[128,0,0], + navy:[0,0,128], + olive:[128,128,0], + orange:[255,165,0], + pink:[255,192,203], + purple:[128,0,128], + violet:[128,0,128], + red:[255,0,0], + silver:[192,192,192], + white:[255,255,255], + yellow:[255,255,0], + transparent:[255,255,255] + }; + +})(jQuery); diff --git a/askbot/skins/default/media/js/utils.js b/askbot/skins/default/media/js/utils.js index ec55e535..8634a3fe 100644 --- a/askbot/skins/default/media/js/utils.js +++ b/askbot/skins/default/media/js/utils.js @@ -389,3 +389,4 @@ if(!this.JSON){this.JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typ (function(){var a={getSelection:function(){var b=this.jquery?this[0]:this;return(("selectionStart" in b&&function(){var c=b.selectionEnd-b.selectionStart;return{start:b.selectionStart,end:b.selectionEnd,length:c,text:b.value.substr(b.selectionStart,c)}})||(document.selection&&function(){b.focus();var d=document.selection.createRange();if(d==null){return{start:0,end:b.value.length,length:0}}var c=b.createTextRange();var e=c.duplicate();c.moveToBookmark(d.getBookmark());e.setEndPoint("EndToStart",c);return{start:e.text.length,end:e.text.length+d.text.length,length:d.text.length,text:d.text}})||function(){return{start:0,end:b.value.length,length:0}})()},replaceSelection:function(){var b=this.jquery?this[0]:this;var c=arguments[0]||"";return(("selectionStart" in b&&function(){b.value=b.value.substr(0,b.selectionStart)+c+b.value.substr(b.selectionEnd,b.value.length);return this})||(document.selection&&function(){b.focus();document.selection.createRange().text=c;return this})||function(){b.value+=c;return this})()}};jQuery.each(a,function(b){jQuery.fn[b]=this})})(); //our custom autocompleter var AutoCompleter=function(a){var b={autocompleteMultiple:true,multipleSeparator:" ",inputClass:"acInput",loadingClass:"acLoading",resultsClass:"acResults",selectClass:"acSelect",queryParamName:"q",limitParamName:"limit",extraParams:{},lineSeparator:"\n",cellSeparator:"|",minChars:2,maxItemsToShow:10,delay:400,useCache:true,maxCacheLength:10,matchSubset:true,matchCase:false,matchInside:true,mustMatch:false,preloadData:false,selectFirst:false,stopCharRegex:/\s+/,selectOnly:false,formatItem:null,onItemSelect:false,autoFill:false,filterResults:true,sortResults:true,sortFunction:false,onNoMatch:false};this.options=$.extend({},b,a);this.cacheData_={};this.cacheLength_=0;this.selectClass_="jquery-autocomplete-selected-item";this.keyTimeout_=null;this.lastKeyPressed_=null;this.lastProcessedValue_=null;this.lastSelectedValue_=null;this.active_=false;this.finishOnBlur_=true;this.options.minChars=parseInt(this.options.minChars,10);if(isNaN(this.options.minChars)||this.options.minChars<1){this.options.minChars=2}this.options.maxItemsToShow=parseInt(this.options.maxItemsToShow,10);if(isNaN(this.options.maxItemsToShow)||this.options.maxItemsToShow<1){this.options.maxItemsToShow=10}this.options.maxCacheLength=parseInt(this.options.maxCacheLength,10);if(isNaN(this.options.maxCacheLength)||this.options.maxCacheLength<1){this.options.maxCacheLength=10}if(this.options.preloadData===true){this.fetchRemoteData("",function(){})}};inherits(AutoCompleter,WrappedElement);AutoCompleter.prototype.decorate=function(a){this._element=a;this._element.attr("autocomplete","off");this._results=$("
").hide();if(this.options.resultsClass){this._results.addClass(this.options.resultsClass)}this._results.css({position:"absolute"});$("body").append(this._results);this.setEventHandlers()};AutoCompleter.prototype.setEventHandlers=function(){var a=this;a._element.keydown(function(b){a.lastKeyPressed_=b.keyCode;switch(a.lastKeyPressed_){case 38:b.preventDefault();if(a.active_){a.focusPrev()}else{a.activate()}return false;break;case 40:b.preventDefault();if(a.active_){a.focusNext()}else{a.activate()}return false;break;case 9:case 13:if(a.active_){b.preventDefault();a.selectCurrent();return false}break;case 27:if(a.active_){b.preventDefault();a.finish();return false}break;default:a.activate()}});a._element.blur(function(){if(a.finishOnBlur_){setTimeout(function(){a.finish()},200)}})};AutoCompleter.prototype.position=function(){var a=this._element.offset();this._results.css({top:a.top+this._element.outerHeight(),left:a.left})};AutoCompleter.prototype.cacheRead=function(d){var f,c,b,a,e;if(this.options.useCache){d=String(d);f=d.length;if(this.options.matchSubset){c=1}else{c=f}while(c<=f){if(this.options.matchInside){a=f-c}else{a=0}e=0;while(e<=a){b=d.substr(0,c);if(this.cacheData_[b]!==undefined){return this.cacheData_[b]}e++}c++}}return false};AutoCompleter.prototype.cacheWrite=function(a,b){if(this.options.useCache){if(this.cacheLength_>=this.options.maxCacheLength){this.cacheFlush()}a=String(a);if(this.cacheData_[a]!==undefined){this.cacheLength_++}return this.cacheData_[a]=b}return false};AutoCompleter.prototype.cacheFlush=function(){this.cacheData_={};this.cacheLength_=0};AutoCompleter.prototype.callHook=function(c,b){var a=this.options[c];if(a&&$.isFunction(a)){return a(b,this)}return false};AutoCompleter.prototype.activate=function(){var b=this;var a=function(){b.activateNow()};var c=parseInt(this.options.delay,10);if(isNaN(c)||c<=0){c=250}if(this.keyTimeout_){clearTimeout(this.keyTimeout_)}this.keyTimeout_=setTimeout(a,c)};AutoCompleter.prototype.activateNow=function(){var a=this.getValue();if(a!==this.lastProcessedValue_&&a!==this.lastSelectedValue_){if(a.length>=this.options.minChars){this.active_=true;this.lastProcessedValue_=a;this.fetchData(a)}}};AutoCompleter.prototype.fetchData=function(b){if(this.options.data){this.filterAndShowResults(this.options.data,b)}else{var a=this;this.fetchRemoteData(b,function(c){a.filterAndShowResults(c,b)})}};AutoCompleter.prototype.fetchRemoteData=function(c,e){var d=this.cacheRead(c);if(d){e(d)}else{var a=this;if(this._element){this._element.addClass(this.options.loadingClass)}var b=function(g){var f=false;if(g!==false){f=a.parseRemoteData(g);a.options.data=f;a.cacheWrite(c,f)}if(a._element){a._element.removeClass(a.options.loadingClass)}e(f)};$.ajax({url:this.makeUrl(c),success:b,error:function(){b(false)}})}};AutoCompleter.prototype.setOption=function(a,b){this.options[a]=b};AutoCompleter.prototype.setExtraParam=function(b,c){var a=$.trim(String(b));if(a){if(!this.options.extraParams){this.options.extraParams={}}if(this.options.extraParams[a]!==c){this.options.extraParams[a]=c;this.cacheFlush()}}};AutoCompleter.prototype.makeUrl=function(e){var a=this;var b=this.options.url;var d=$.extend({},this.options.extraParams);if(this.options.queryParamName===false){b+=encodeURIComponent(e)}else{d[this.options.queryParamName]=e}if(this.options.limitParamName&&this.options.maxItemsToShow){d[this.options.limitParamName]=this.options.maxItemsToShow}var c=[];$.each(d,function(f,g){c.push(a.makeUrlParam(f,g))});if(c.length){b+=b.indexOf("?")==-1?"?":"&";b+=c.join("&")}return b};AutoCompleter.prototype.makeUrlParam=function(a,b){return String(a)+"="+encodeURIComponent(b)};AutoCompleter.prototype.splitText=function(a){return String(a).replace(/(\r\n|\r|\n)/g,"\n").split(this.options.lineSeparator)};AutoCompleter.prototype.parseRemoteData=function(c){var h,b,f,d,g;var e=[];var b=this.splitText(c);for(f=0;f""){if(typeof c!=="object"){c={}}if(this.options.filterResults){h=String(b);g=String(l);if(!this.options.matchCase){h=h.toLowerCase();g=g.toLowerCase()}a=g.indexOf(h);if(this.options.matchInside){a=a>-1}else{a=a===0}}else{a=true}if(a){f.push({value:l,data:c})}}}if(this.options.sortResults){f=this.sortResults(f,b)}if(this.options.maxItemsToShow>0&&this.options.maxItemsToShowc){return 1}if(d");var f,l,j,a,h=false,d=false;var c=e.length;for(f=0;f"+this.showResult(l.value,l.data)+"");j.data("value",l.value);j.data("data",l.data);j.click(function(){var i=$(this);k.selectItem(i)}).mousedown(function(){k.finishOnBlur_=false}).mouseup(function(){k.finishOnBlur_=true});g.append(j);if(h===false){h=String(l.value);d=j;j.addClass(this.options.firstItemClass)}if(f==c-1){j.addClass(this.options.lastItemClass)}}this.position();this._results.html(g).show();a=this._results.outerWidth()-this._results.width();this._results.width(this._element.outerWidth()-a);$("li",this._results).hover(function(){k.focusItem(this)},function(){});if(this.autoFill(h,b)){this.focusItem(d)}};AutoCompleter.prototype.showResult=function(b,a){if($.isFunction(this.options.showResult)){return this.options.showResult(b,a)}else{return b}};AutoCompleter.prototype.autoFill=function(e,c){var b,a,d,f;if(this.options.autoFill&&this.lastKeyPressed_!=8){b=String(e).toLowerCase();a=String(c).toLowerCase();d=e.length;f=c.length;if(b.substr(0,f)===a){this._element.val(e);this.selectRange(f,d);return true}}return false};AutoCompleter.prototype.focusNext=function(){this.focusMove(+1)};AutoCompleter.prototype.focusPrev=function(){this.focusMove(-1)};AutoCompleter.prototype.focusMove=function(a){var b,c=$("li",this._results);a=parseInt(a,10);for(var b=0;b=c.length){b=c.length-1}}a=$(c[b])}else{a=$(b)}if(a){a.addClass(this.selectClass_).addClass(this.options.selectClass)}}};AutoCompleter.prototype.selectCurrent=function(){var a=$("li."+this.selectClass_,this._results);if(a.length==1){this.selectItem(a)}else{this.finish()}};AutoCompleter.prototype.selectItem=function(d){var c=d.data("value");var b=d.data("data");var a=this.displayValue(c,b);this.lastProcessedValue_=a;this.lastSelectedValue_=a;this.setValue(a);this.setCaret(a.length);this.callHook("onItemSelect",{value:c,data:b});this.finish()};AutoCompleter.prototype.isContentChar=function(a){if(a.match(this.options.stopCharRegex)){return false}else{if(a===this.options.multipleSeparator){return false}else{return true}}};AutoCompleter.prototype.getValue=function(){var c=this._element.getSelection();var d=this._element.val();var f=c.start;var e=f;for(cpos=f;cpos>=0;cpos=cpos-1){if(cpos===d.length){continue}var b=d.charAt(cpos);if(!this.isContentChar(b)){break}e=cpos}var a=f;for(cpos=f;cpos Date: Tue, 4 Oct 2011 10:33:40 -0300 Subject: Fixes: feature 99. Added bootstrap mode --- askbot/conf/__init__.py | 1 + askbot/conf/site_modes.py | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 askbot/conf/site_modes.py diff --git a/askbot/conf/__init__.py b/askbot/conf/__init__.py index 1d2d7240..64fe41fb 100644 --- a/askbot/conf/__init__.py +++ b/askbot/conf/__init__.py @@ -19,6 +19,7 @@ import askbot.conf.markup import askbot.conf.social_sharing import askbot.conf.badges import askbot.conf.login_providers +import askbot.conf.site_modes #import main settings object from askbot.conf.settings_wrapper import settings diff --git a/askbot/conf/site_modes.py b/askbot/conf/site_modes.py new file mode 100644 index 00000000..73487cd8 --- /dev/null +++ b/askbot/conf/site_modes.py @@ -0,0 +1,67 @@ +""" +Site modes settings: + Support for site modes currently supports + Bootstrap - for sites that are starting and + Default - for sites that already have a momentum. +""" +from askbot.conf.settings_wrapper import settings +from askbot.deps.livesettings import ConfigurationGroup, BooleanValue +from django.utils.translation import ugettext as _ +from askbot.conf import badges, minimum_reputation + +def bootstrap_callback(current_value, new_value): + '''Callback to update settings''' + + if new_value == True: + #minimum reputation settgins. + settings.update('MIN_REP_TO_VOTE_UP', 5) + settings.update('MIN_REP_TO_VOTE_DOWN', 50) + settings.update('MIN_REP_TO_ANSWER_OWN_QUESTION', 5) + settings.update('MIN_REP_TO_ACCEPT_OWN_ANSWER', 20) + settings.update('MIN_REP_TO_FLAG_OFFENSIVE', 5) + settings.update('MIN_REP_TO_LEAVE_COMMENTS', 10) + settings.update('MIN_REP_TO_DELETE_OTHERS_COMMENTS', 200) + settings.update('MIN_REP_TO_DELETE_OTHERS_POSTS', 500) + settings.update('MIN_REP_TO_UPLOAD_FILES', 10) + settings.update('MIN_REP_TO_CLOSE_OWN_QUESTIONS', 25) + settings.update('MIN_REP_TO_RETAG_OTHERS_QUESTIONS', 50) + settings.update('MIN_REP_TO_REOPEN_OWN_QUESTIONS', 50) + settings.update('MIN_REP_TO_EDIT_WIKI', 75) + settings.update('MIN_REP_TO_EDIT_OTHERS_POSTS', 200) + settings.update('MIN_REP_TO_VIEW_OFFENSIVE_FLAGS', 200) + settings.update('MIN_REP_TO_CLOSE_OTHERS_QUESTIONS', 200) + settings.update('MIN_REP_TO_LOCK_POSTS', 400) + settings.update('MIN_REP_TO_HAVE_STRONG_URL', 25) + #badge settings + settings.update('NOTABLE_QUESTION_BADGE_MIN_VIEWS', 25) + settings.update('POPULAR_QUESTION_BADGE_MIN_VIEWS', 15) + settings.update('FAMOUS_QUESTION_BADGE_MIN_VIEWS', 50) + settings.update('ENTHUSIAST_BADGE_MIN_DAYS', 5) + settings.update('TAXONOMIST_BADGE_MIN_USE_COUNT', 5) + else: + for key in badges.BADGES.keys(): + default_value = badges.BADGES[key].default + settings.update(key, default_value) + + for key in minimum_reputation.MIN_REP.keys(): + default_value = minimum_reputation.MIN_REP[key].default + settings.update(key, default_value) + + return new_value + + +SITE_MODES = ConfigurationGroup( + 'SITE_MODES', + _('Reputation & limits mode'), + ) + +settings.register( + BooleanValue( + SITE_MODES, + 'ACTIVATE_BOOTSTRAP_MODE', + default=False, + description=_('Check this value to activate a special "Bootstrap" mode'), + help_text=_("WARNING: your current value for Minimum reputation and Bagde Settings will be changed after you save.."), + update_callback = bootstrap_callback + ) +) -- cgit v1.2.3-1-g7c22 From e8604ae446e1fc2b2add854916b6885574c70836 Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Tue, 4 Oct 2011 15:16:02 -0300 Subject: do not overwrite settings in case that the value havent changed --- askbot/conf/site_modes.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/askbot/conf/site_modes.py b/askbot/conf/site_modes.py index 73487cd8..45aaec90 100644 --- a/askbot/conf/site_modes.py +++ b/askbot/conf/site_modes.py @@ -12,6 +12,11 @@ from askbot.conf import badges, minimum_reputation def bootstrap_callback(current_value, new_value): '''Callback to update settings''' + if current_value == new_value: + #do not overwrite settings in case that tha value + #is the same + return new_value + if new_value == True: #minimum reputation settgins. settings.update('MIN_REP_TO_VOTE_UP', 5) -- cgit v1.2.3-1-g7c22 From f588f303470aa0a899b6df18d459aa7c3d7479dd Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Wed, 5 Oct 2011 10:11:16 -0300 Subject: fixed: moderation tab is misaligned --- askbot/skins/default/media/style/style.css | 1 + 1 file changed, 1 insertion(+) diff --git a/askbot/skins/default/media/style/style.css b/askbot/skins/default/media/style/style.css index 478f5116..6297721b 100644 --- a/askbot/skins/default/media/style/style.css +++ b/askbot/skins/default/media/style/style.css @@ -887,6 +887,7 @@ a:hover.medal { margin: 5px 0 0 4px; padding: 0 2px; text-decoration: none; + font-size: 12.5px; } .tabsA .label, .tabsC .label { -- cgit v1.2.3-1-g7c22 From b857aae15a810e4b1c87e3d7272a03ed8120ebfa Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Wed, 5 Oct 2011 11:40:01 -0300 Subject: small changes to the bugfix branch --- askbot/skins/default/templates/question.html | 18 +++++++++++------- askbot/skins/default/templates/users.html | 8 ++++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/askbot/skins/default/templates/question.html b/askbot/skins/default/templates/question.html index dce91566..ae003ef4 100644 --- a/askbot/skins/default/templates/question.html +++ b/askbot/skins/default/templates/question.html @@ -305,7 +305,12 @@ {% trans %}email{% endtrans %}. {% endif %} -
{% csrf_token %} +{% csrf_token %} {% if request.user.is_authenticated() %}

{{ answer.email_notify }} @@ -539,12 +544,11 @@ } {% if settings.ENABLE_SHARING_GOOGLE %}$.getScript("http://apis.google.com/js/plusone.js"){% endif %} - {% if request.user == question.author%} - $("#fmanswer").hide(); - $("#fmanswer_button").click(function() { - $("#fmanswer").show(); - $("#fmanswer_button").hide(); - }); + {% if request.user == question.author %} + $("#fmanswer_button").click(function() { + $("#fmanswer").show(); + $("#fmanswer_button").hide(); + }); {%endif%} }); diff --git a/askbot/skins/default/templates/users.html b/askbot/skins/default/templates/users.html index 3c9a7686..1d7d02dd 100644 --- a/askbot/skins/default/templates/users.html +++ b/askbot/skins/default/templates/users.html @@ -10,25 +10,25 @@ id="sort_reputation" href="{% url users %}?sort=reputation" {% if tab_id == 'reputation' %}class="on"{% endif %} - title="{% trans %}People sorted by reputation{% endtrans %}" + title="{% trans %}see people with the highest reputation{% endtrans %}" >{% trans %}reputation{% endtrans %} {% trans %}recent{% endtrans %} {% trans %}oldest{% endtrans %} {% trans %}by username{% endtrans %} -- cgit v1.2.3-1-g7c22 From b8d9d95c7b244a2584be3abdf542d744e84a6926 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Wed, 5 Oct 2011 11:48:18 -0300 Subject: updated changelog --- askbot/doc/source/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst index 77ff4a45..dd1488a0 100644 --- a/askbot/doc/source/changelog.rst +++ b/askbot/doc/source/changelog.rst @@ -4,6 +4,8 @@ Changes in Askbot Development version (Not yet released) -------------------------------------- * RSS feed for individual question (Sayan Chowdhury) +* Allow pre-population of tags via ask a questios link (Adolfo) +* Make answering own question one click harder (Adolfo) 0.7.24 (Current Version) ------------------------ -- cgit v1.2.3-1-g7c22 From 9e006ba11567b8860929436cdbf1394e4274f902 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Wed, 5 Oct 2011 13:02:42 -0300 Subject: some changes to the bootstrap mode feature --- askbot/conf/settings_wrapper.py | 8 ++++ askbot/conf/site_modes.py | 85 ++++++++++++++++++++++++----------------- askbot/doc/source/changelog.rst | 3 +- 3 files changed, 59 insertions(+), 37 deletions(-) diff --git a/askbot/conf/settings_wrapper.py b/askbot/conf/settings_wrapper.py index aac8f071..2e0d8db2 100644 --- a/askbot/conf/settings_wrapper.py +++ b/askbot/conf/settings_wrapper.py @@ -49,6 +49,14 @@ class ConfigSettings(object): """ return getattr(self.__instance, key).value + def get_default(self, key): + """return the defalut value for the setting""" + return getattr(self.__instance, key).default + + def reset(self, key): + """returns setting to the default value""" + self.update(key, self.get_default(key)) + def update(self, key, value): setting = config_get(self.__group_map[key], key) setting.update(value) diff --git a/askbot/conf/site_modes.py b/askbot/conf/site_modes.py index 45aaec90..e79169e7 100644 --- a/askbot/conf/site_modes.py +++ b/askbot/conf/site_modes.py @@ -7,7 +7,37 @@ Site modes settings: from askbot.conf.settings_wrapper import settings from askbot.deps.livesettings import ConfigurationGroup, BooleanValue from django.utils.translation import ugettext as _ -from askbot.conf import badges, minimum_reputation + +BOOTSTRAP_MODE_SETTINGS = { + #minimum reputation settins. + 'MIN_REP_TO_VOTE_UP': 5, + 'MIN_REP_TO_VOTE_DOWN': 50, + 'MIN_REP_TO_ANSWER_OWN_QUESTION': 5, + 'MIN_REP_TO_ACCEPT_OWN_ANSWER': 20, + 'MIN_REP_TO_FLAG_OFFENSIVE': 5, + 'MIN_REP_TO_LEAVE_COMMENTS': 10, + 'MIN_REP_TO_DELETE_OTHERS_COMMENTS': 200, + 'MIN_REP_TO_DELETE_OTHERS_POSTS': 500, + 'MIN_REP_TO_UPLOAD_FILES': 10, + 'MIN_REP_TO_CLOSE_OWN_QUESTIONS': 25, + 'MIN_REP_TO_RETAG_OTHERS_QUESTIONS': 50, + 'MIN_REP_TO_REOPEN_OWN_QUESTIONS': 50, + 'MIN_REP_TO_EDIT_WIKI': 75, + 'MIN_REP_TO_EDIT_OTHERS_POSTS': 200, + 'MIN_REP_TO_VIEW_OFFENSIVE_FLAGS': 200, + 'MIN_REP_TO_CLOSE_OTHERS_QUESTIONS': 200, + 'MIN_REP_TO_LOCK_POSTS': 400, + 'MIN_REP_TO_HAVE_STRONG_URL': 25, + #badge settings + 'NOTABLE_QUESTION_BADGE_MIN_VIEWS': 25, + 'POPULAR_QUESTION_BADGE_MIN_VIEWS': 15, + 'FAMOUS_QUESTION_BADGE_MIN_VIEWS': 50, + 'ENTHUSIAST_BADGE_MIN_DAYS': 5, + 'TAXONOMIST_BADGE_MIN_USE_COUNT': 5, + #moderation rule settings + 'MIN_FLAGS_TO_HIDE_POST': 2, + 'MIN_FLAGS_TO_DELETE_POST': 3, +} def bootstrap_callback(current_value, new_value): '''Callback to update settings''' @@ -18,46 +48,19 @@ def bootstrap_callback(current_value, new_value): return new_value if new_value == True: - #minimum reputation settgins. - settings.update('MIN_REP_TO_VOTE_UP', 5) - settings.update('MIN_REP_TO_VOTE_DOWN', 50) - settings.update('MIN_REP_TO_ANSWER_OWN_QUESTION', 5) - settings.update('MIN_REP_TO_ACCEPT_OWN_ANSWER', 20) - settings.update('MIN_REP_TO_FLAG_OFFENSIVE', 5) - settings.update('MIN_REP_TO_LEAVE_COMMENTS', 10) - settings.update('MIN_REP_TO_DELETE_OTHERS_COMMENTS', 200) - settings.update('MIN_REP_TO_DELETE_OTHERS_POSTS', 500) - settings.update('MIN_REP_TO_UPLOAD_FILES', 10) - settings.update('MIN_REP_TO_CLOSE_OWN_QUESTIONS', 25) - settings.update('MIN_REP_TO_RETAG_OTHERS_QUESTIONS', 50) - settings.update('MIN_REP_TO_REOPEN_OWN_QUESTIONS', 50) - settings.update('MIN_REP_TO_EDIT_WIKI', 75) - settings.update('MIN_REP_TO_EDIT_OTHERS_POSTS', 200) - settings.update('MIN_REP_TO_VIEW_OFFENSIVE_FLAGS', 200) - settings.update('MIN_REP_TO_CLOSE_OTHERS_QUESTIONS', 200) - settings.update('MIN_REP_TO_LOCK_POSTS', 400) - settings.update('MIN_REP_TO_HAVE_STRONG_URL', 25) - #badge settings - settings.update('NOTABLE_QUESTION_BADGE_MIN_VIEWS', 25) - settings.update('POPULAR_QUESTION_BADGE_MIN_VIEWS', 15) - settings.update('FAMOUS_QUESTION_BADGE_MIN_VIEWS', 50) - settings.update('ENTHUSIAST_BADGE_MIN_DAYS', 5) - settings.update('TAXONOMIST_BADGE_MIN_USE_COUNT', 5) - else: - for key in badges.BADGES.keys(): - default_value = badges.BADGES[key].default - settings.update(key, default_value) + for key, value in BOOTSTRAP_MODE_SETTINGS.items(): + settings.update(key, value) - for key in minimum_reputation.MIN_REP.keys(): - default_value = minimum_reputation.MIN_REP[key].default - settings.update(key, default_value) + else: + for key in BOOTSTRAP_MODE_SETTINGS: + settings.reset(key) return new_value SITE_MODES = ConfigurationGroup( 'SITE_MODES', - _('Reputation & limits mode'), + _('Site modes'), ) settings.register( @@ -65,8 +68,18 @@ settings.register( SITE_MODES, 'ACTIVATE_BOOTSTRAP_MODE', default=False, - description=_('Check this value to activate a special "Bootstrap" mode'), - help_text=_("WARNING: your current value for Minimum reputation and Bagde Settings will be changed after you save.."), + description=_( + 'Activate a "Bootstrap" mode'), + help_text=_( + "Bootstrap mode lowers reputation and certain badge " + "thresholds, to values, more suitable " + "for the smaller communities, " + "WARNING: your current value for " + "Minimum reputation, " + "Bagde Settings and " + "Vote Rules will " + "be changed after you modify this setting." + ), update_callback = bootstrap_callback ) ) diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst index dd1488a0..0592cc54 100644 --- a/askbot/doc/source/changelog.rst +++ b/askbot/doc/source/changelog.rst @@ -4,8 +4,9 @@ Changes in Askbot Development version (Not yet released) -------------------------------------- * RSS feed for individual question (Sayan Chowdhury) -* Allow pre-population of tags via ask a questios link (Adolfo) +* Allow pre-population of tags via ask a questions link (Adolfo) * Make answering own question one click harder (Adolfo) +* Bootstrap mode (Adolfo, Evgeny) 0.7.24 (Current Version) ------------------------ -- cgit v1.2.3-1-g7c22 From 6f9e8eca777065cb737eb0027d1e609f0d0e46ef Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Wed, 5 Oct 2011 17:25:45 -0300 Subject: bumped version to 0.7.25 due to a bug not entirely fixed by 0.7.24 --- askbot/__init__.py | 2 +- askbot/doc/source/changelog.rst | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/askbot/__init__.py b/askbot/__init__.py index b4889f92..ef784c3b 100644 --- a/askbot/__init__.py +++ b/askbot/__init__.py @@ -9,7 +9,7 @@ import smtplib import sys import logging -VERSION = (0, 7, 24) +VERSION = (0, 7, 25) #necessary for interoperability of django and coffin try: diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst index 0592cc54..d58b415f 100644 --- a/askbot/doc/source/changelog.rst +++ b/askbot/doc/source/changelog.rst @@ -1,15 +1,15 @@ Changes in Askbot ================= -Development version (Not yet released) --------------------------------------- +0.7.25 (Current Version) +------------------------ * RSS feed for individual question (Sayan Chowdhury) * Allow pre-population of tags via ask a questions link (Adolfo) * Make answering own question one click harder (Adolfo) * Bootstrap mode (Adolfo, Evgeny) -0.7.24 (Current Version) ------------------------- +0.7.24 +------ * Made it possible to disable the anonymous user greeting alltogether (Raghu Udiyar) * Added annotations for the meanings of user levels on the "moderation" page. (Jishnu) * Auto-link patterns - e.g. to bug databases - are configurable from settings. (Arun SAG) -- cgit v1.2.3-1-g7c22 From 115e4b6316c7821f03abf14211551ea0269ea2aa Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Wed, 5 Oct 2011 17:32:13 -0300 Subject: added db to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 15b8d802..0375e009 100755 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.pyc *.swp *.log +db cache/?? run *.wsgi -- cgit v1.2.3-1-g7c22 From d8c0847e78a9f58c7fd8ea58bc1f34af65646f72 Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Wed, 5 Oct 2011 18:17:43 -0300 Subject: temporal: todo add alpha support for jquery.color.js tested jquery.animate-colors. but it does not works on FF --- .../default/media/js/jquery.animate-colors.js | 103 +++++++++++++++++++++ askbot/skins/default/media/js/jquery.color.js | 6 +- askbot/skins/default/media/js/utils.js | 1 - askbot/skins/default/templates/question.html | 19 +++- 4 files changed, 122 insertions(+), 7 deletions(-) create mode 100644 askbot/skins/default/media/js/jquery.animate-colors.js diff --git a/askbot/skins/default/media/js/jquery.animate-colors.js b/askbot/skins/default/media/js/jquery.animate-colors.js new file mode 100644 index 00000000..edffb427 --- /dev/null +++ b/askbot/skins/default/media/js/jquery.animate-colors.js @@ -0,0 +1,103 @@ +/**! + * @preserve Color animation jQuery-plugin + * http://www.bitstorm.org/jquery/color-animation/ + * Copyright 2011 Edwin Martin + * Released under the MIT and GPL licenses. + */ + +(function($) { + /** + * Check whether the browser supports RGBA color mode. + * + * Author Mehdi Kabab + * @return {boolean} True if the browser support RGBA. False otherwise. + */ + function isRGBACapable() { + var $script = $('script:first'), + color = $script.css('color'), + result = false; + if (/^rgba/.test(color)) { + result = true; + } else { + try { + result = ( color != $script.css('color', 'rgba(0, 0, 0, 0.5)').css('color') ); + $script.css('color', color); + } catch (e) { + } + } + + return result; + } + + $.extend(true, $, { + support: { + 'rgba': isRGBACapable() + } + }); + + var properties = ['color', 'backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'outlineColor']; + $.each(properties, function(i, property) { + $.fx.step[property] = function(fx) { + if (!fx.init) { + fx.begin = parseColor($(fx.elem).css(property)); + fx.end = parseColor(fx.end); + fx.init = true; + } + + fx.elem.style[property] = calculateColor(fx.begin, fx.end, fx.pos); + } + }); + + // borderColor doesn't fit in standard fx.step above. + $.fx.step.borderColor = function(fx) { + if (!fx.init) { + fx.end = parseColor(fx.end); + } + var borders = properties.slice(2, 6); // All four border properties + $.each(borders, function(i, property) { + if (!fx.init) { + fx[property] = {begin: parseColor($(fx.elem).css(property))}; + } + + fx.elem.style[property] = calculateColor(fx[property].begin, fx.end, fx.pos); + }); + fx.init = true; + } + + // Calculate an in-between color. Returns "#aabbcc"-like string. + function calculateColor(begin, end, pos) { + var color = 'rgb' + ($.support['rgba'] ? 'a' : '') + '(' + + parseInt((begin[0] + pos * (end[0] - begin[0])), 10) + ',' + + parseInt((begin[1] + pos * (end[1] - begin[1])), 10) + ',' + + parseInt((begin[2] + pos * (end[2] - begin[2])), 10); + if ($.support['rgba']) { + color += ',' + (begin && end ? parseFloat(begin[3] + pos * (end[3] - begin[3])) : 1); + } + color += ')'; + return color; + } + + // Parse an CSS-syntax color. Outputs an array [r, g, b] + function parseColor(color) { + var match, triplet; + + // Match #aabbcc + if (match = /#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(color)) { + triplet = [parseInt(match[1], 16), parseInt(match[2], 16), parseInt(match[3], 16), 1]; + + // Match #abc + } else if (match = /#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(color)) { + triplet = [parseInt(match[1], 16) * 17, parseInt(match[2], 16) * 17, parseInt(match[3], 16) * 17, 1]; + + // Match rgb(n, n, n) + } else if (match = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) { + triplet = [parseInt(match[1]), parseInt(match[2]), parseInt(match[3]), 1]; + + } else if (match = /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]*)\s*\)/.exec(color)) { + triplet = [parseInt(match[1], 10), parseInt(match[2], 10), parseInt(match[3], 10),parseFloat(match[4])]; + + // No browser returns rgb(n%, n%, n%), so little reason to support this format. + } + return triplet; + } +})(jQuery); \ No newline at end of file diff --git a/askbot/skins/default/media/js/jquery.color.js b/askbot/skins/default/media/js/jquery.color.js index ad5decd0..2199bb48 100644 --- a/askbot/skins/default/media/js/jquery.color.js +++ b/askbot/skins/default/media/js/jquery.color.js @@ -13,7 +13,8 @@ fx.start = getColor( fx.elem, attr ); fx.end = getRGB( fx.end ); } - + + //add alpha support fx.elem.style[attr] = "rgb(" + [ Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0), Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0), @@ -42,6 +43,9 @@ if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55]; + if (result = /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) + return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])]; + // Look for #a0b1c2 if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)]; diff --git a/askbot/skins/default/media/js/utils.js b/askbot/skins/default/media/js/utils.js index 8634a3fe..ec55e535 100644 --- a/askbot/skins/default/media/js/utils.js +++ b/askbot/skins/default/media/js/utils.js @@ -389,4 +389,3 @@ if(!this.JSON){this.JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typ (function(){var a={getSelection:function(){var b=this.jquery?this[0]:this;return(("selectionStart" in b&&function(){var c=b.selectionEnd-b.selectionStart;return{start:b.selectionStart,end:b.selectionEnd,length:c,text:b.value.substr(b.selectionStart,c)}})||(document.selection&&function(){b.focus();var d=document.selection.createRange();if(d==null){return{start:0,end:b.value.length,length:0}}var c=b.createTextRange();var e=c.duplicate();c.moveToBookmark(d.getBookmark());e.setEndPoint("EndToStart",c);return{start:e.text.length,end:e.text.length+d.text.length,length:d.text.length,text:d.text}})||function(){return{start:0,end:b.value.length,length:0}})()},replaceSelection:function(){var b=this.jquery?this[0]:this;var c=arguments[0]||"";return(("selectionStart" in b&&function(){b.value=b.value.substr(0,b.selectionStart)+c+b.value.substr(b.selectionEnd,b.value.length);return this})||(document.selection&&function(){b.focus();document.selection.createRange().text=c;return this})||function(){b.value+=c;return this})()}};jQuery.each(a,function(b){jQuery.fn[b]=this})})(); //our custom autocompleter var AutoCompleter=function(a){var b={autocompleteMultiple:true,multipleSeparator:" ",inputClass:"acInput",loadingClass:"acLoading",resultsClass:"acResults",selectClass:"acSelect",queryParamName:"q",limitParamName:"limit",extraParams:{},lineSeparator:"\n",cellSeparator:"|",minChars:2,maxItemsToShow:10,delay:400,useCache:true,maxCacheLength:10,matchSubset:true,matchCase:false,matchInside:true,mustMatch:false,preloadData:false,selectFirst:false,stopCharRegex:/\s+/,selectOnly:false,formatItem:null,onItemSelect:false,autoFill:false,filterResults:true,sortResults:true,sortFunction:false,onNoMatch:false};this.options=$.extend({},b,a);this.cacheData_={};this.cacheLength_=0;this.selectClass_="jquery-autocomplete-selected-item";this.keyTimeout_=null;this.lastKeyPressed_=null;this.lastProcessedValue_=null;this.lastSelectedValue_=null;this.active_=false;this.finishOnBlur_=true;this.options.minChars=parseInt(this.options.minChars,10);if(isNaN(this.options.minChars)||this.options.minChars<1){this.options.minChars=2}this.options.maxItemsToShow=parseInt(this.options.maxItemsToShow,10);if(isNaN(this.options.maxItemsToShow)||this.options.maxItemsToShow<1){this.options.maxItemsToShow=10}this.options.maxCacheLength=parseInt(this.options.maxCacheLength,10);if(isNaN(this.options.maxCacheLength)||this.options.maxCacheLength<1){this.options.maxCacheLength=10}if(this.options.preloadData===true){this.fetchRemoteData("",function(){})}};inherits(AutoCompleter,WrappedElement);AutoCompleter.prototype.decorate=function(a){this._element=a;this._element.attr("autocomplete","off");this._results=$("

").hide();if(this.options.resultsClass){this._results.addClass(this.options.resultsClass)}this._results.css({position:"absolute"});$("body").append(this._results);this.setEventHandlers()};AutoCompleter.prototype.setEventHandlers=function(){var a=this;a._element.keydown(function(b){a.lastKeyPressed_=b.keyCode;switch(a.lastKeyPressed_){case 38:b.preventDefault();if(a.active_){a.focusPrev()}else{a.activate()}return false;break;case 40:b.preventDefault();if(a.active_){a.focusNext()}else{a.activate()}return false;break;case 9:case 13:if(a.active_){b.preventDefault();a.selectCurrent();return false}break;case 27:if(a.active_){b.preventDefault();a.finish();return false}break;default:a.activate()}});a._element.blur(function(){if(a.finishOnBlur_){setTimeout(function(){a.finish()},200)}})};AutoCompleter.prototype.position=function(){var a=this._element.offset();this._results.css({top:a.top+this._element.outerHeight(),left:a.left})};AutoCompleter.prototype.cacheRead=function(d){var f,c,b,a,e;if(this.options.useCache){d=String(d);f=d.length;if(this.options.matchSubset){c=1}else{c=f}while(c<=f){if(this.options.matchInside){a=f-c}else{a=0}e=0;while(e<=a){b=d.substr(0,c);if(this.cacheData_[b]!==undefined){return this.cacheData_[b]}e++}c++}}return false};AutoCompleter.prototype.cacheWrite=function(a,b){if(this.options.useCache){if(this.cacheLength_>=this.options.maxCacheLength){this.cacheFlush()}a=String(a);if(this.cacheData_[a]!==undefined){this.cacheLength_++}return this.cacheData_[a]=b}return false};AutoCompleter.prototype.cacheFlush=function(){this.cacheData_={};this.cacheLength_=0};AutoCompleter.prototype.callHook=function(c,b){var a=this.options[c];if(a&&$.isFunction(a)){return a(b,this)}return false};AutoCompleter.prototype.activate=function(){var b=this;var a=function(){b.activateNow()};var c=parseInt(this.options.delay,10);if(isNaN(c)||c<=0){c=250}if(this.keyTimeout_){clearTimeout(this.keyTimeout_)}this.keyTimeout_=setTimeout(a,c)};AutoCompleter.prototype.activateNow=function(){var a=this.getValue();if(a!==this.lastProcessedValue_&&a!==this.lastSelectedValue_){if(a.length>=this.options.minChars){this.active_=true;this.lastProcessedValue_=a;this.fetchData(a)}}};AutoCompleter.prototype.fetchData=function(b){if(this.options.data){this.filterAndShowResults(this.options.data,b)}else{var a=this;this.fetchRemoteData(b,function(c){a.filterAndShowResults(c,b)})}};AutoCompleter.prototype.fetchRemoteData=function(c,e){var d=this.cacheRead(c);if(d){e(d)}else{var a=this;if(this._element){this._element.addClass(this.options.loadingClass)}var b=function(g){var f=false;if(g!==false){f=a.parseRemoteData(g);a.options.data=f;a.cacheWrite(c,f)}if(a._element){a._element.removeClass(a.options.loadingClass)}e(f)};$.ajax({url:this.makeUrl(c),success:b,error:function(){b(false)}})}};AutoCompleter.prototype.setOption=function(a,b){this.options[a]=b};AutoCompleter.prototype.setExtraParam=function(b,c){var a=$.trim(String(b));if(a){if(!this.options.extraParams){this.options.extraParams={}}if(this.options.extraParams[a]!==c){this.options.extraParams[a]=c;this.cacheFlush()}}};AutoCompleter.prototype.makeUrl=function(e){var a=this;var b=this.options.url;var d=$.extend({},this.options.extraParams);if(this.options.queryParamName===false){b+=encodeURIComponent(e)}else{d[this.options.queryParamName]=e}if(this.options.limitParamName&&this.options.maxItemsToShow){d[this.options.limitParamName]=this.options.maxItemsToShow}var c=[];$.each(d,function(f,g){c.push(a.makeUrlParam(f,g))});if(c.length){b+=b.indexOf("?")==-1?"?":"&";b+=c.join("&")}return b};AutoCompleter.prototype.makeUrlParam=function(a,b){return String(a)+"="+encodeURIComponent(b)};AutoCompleter.prototype.splitText=function(a){return String(a).replace(/(\r\n|\r|\n)/g,"\n").split(this.options.lineSeparator)};AutoCompleter.prototype.parseRemoteData=function(c){var h,b,f,d,g;var e=[];var b=this.splitText(c);for(f=0;f""){if(typeof c!=="object"){c={}}if(this.options.filterResults){h=String(b);g=String(l);if(!this.options.matchCase){h=h.toLowerCase();g=g.toLowerCase()}a=g.indexOf(h);if(this.options.matchInside){a=a>-1}else{a=a===0}}else{a=true}if(a){f.push({value:l,data:c})}}}if(this.options.sortResults){f=this.sortResults(f,b)}if(this.options.maxItemsToShow>0&&this.options.maxItemsToShowc){return 1}if(d");var f,l,j,a,h=false,d=false;var c=e.length;for(f=0;f"+this.showResult(l.value,l.data)+"");j.data("value",l.value);j.data("data",l.data);j.click(function(){var i=$(this);k.selectItem(i)}).mousedown(function(){k.finishOnBlur_=false}).mouseup(function(){k.finishOnBlur_=true});g.append(j);if(h===false){h=String(l.value);d=j;j.addClass(this.options.firstItemClass)}if(f==c-1){j.addClass(this.options.lastItemClass)}}this.position();this._results.html(g).show();a=this._results.outerWidth()-this._results.width();this._results.width(this._element.outerWidth()-a);$("li",this._results).hover(function(){k.focusItem(this)},function(){});if(this.autoFill(h,b)){this.focusItem(d)}};AutoCompleter.prototype.showResult=function(b,a){if($.isFunction(this.options.showResult)){return this.options.showResult(b,a)}else{return b}};AutoCompleter.prototype.autoFill=function(e,c){var b,a,d,f;if(this.options.autoFill&&this.lastKeyPressed_!=8){b=String(e).toLowerCase();a=String(c).toLowerCase();d=e.length;f=c.length;if(b.substr(0,f)===a){this._element.val(e);this.selectRange(f,d);return true}}return false};AutoCompleter.prototype.focusNext=function(){this.focusMove(+1)};AutoCompleter.prototype.focusPrev=function(){this.focusMove(-1)};AutoCompleter.prototype.focusMove=function(a){var b,c=$("li",this._results);a=parseInt(a,10);for(var b=0;b=c.length){b=c.length-1}}a=$(c[b])}else{a=$(b)}if(a){a.addClass(this.selectClass_).addClass(this.options.selectClass)}}};AutoCompleter.prototype.selectCurrent=function(){var a=$("li."+this.selectClass_,this._results);if(a.length==1){this.selectItem(a)}else{this.finish()}};AutoCompleter.prototype.selectItem=function(d){var c=d.data("value");var b=d.data("data");var a=this.displayValue(c,b);this.lastProcessedValue_=a;this.lastSelectedValue_=a;this.setValue(a);this.setCaret(a.length);this.callHook("onItemSelect",{value:c,data:b});this.finish()};AutoCompleter.prototype.isContentChar=function(a){if(a.match(this.options.stopCharRegex)){return false}else{if(a===this.options.multipleSeparator){return false}else{return true}}};AutoCompleter.prototype.getValue=function(){var c=this._element.getSelection();var d=this._element.val();var f=c.start;var e=f;for(cpos=f;cpos>=0;cpos=cpos-1){if(cpos===d.length){continue}var b=d.charAt(cpos);if(!this.isContentChar(b)){break}e=cpos}var a=f;for(cpos=f;cpos +