* @category Applications
* @package StatusNet
* @author Zach Copley <zach@status.net>
- * @copyright 2008-2009 StatusNet, Inc.
+ * @copyright 2008-2011 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
$app->query('ROLLBACK');
}
- $app->uploadLogo();
+ try {
+ $app->uploadLogo();
+ } catch (Exception $e) {
+ $app->query('ROLLBACK');
+ $this->showForm(_('Invalid image.'));
+ return;
+ }
$app->query('COMMIT');
.fadeIn(2500);
SN.U.NoticeWithAttachment($('#'+notice.id));
SN.U.NoticeReplyTo($('#'+notice.id));
+ SN.U.switchInputFormTab("placeholder");
}
} else {
// Not on a timeline that this belongs on?
nextStep();
} else {
// Remove placeholder if any
- $('li.notice-reply-placeholder').remove();
+ list.find('li.notice-reply-placeholder').remove();
// Create the reply form entry at the end
var replyItem = $('li.notice-reply', list);
var placeholder = $('<li class="notice-reply-placeholder">' +
'<input class="placeholder">' +
'</li>');
- placeholder.click(function() {
- SN.U.NoticeInlineReplyTrigger(notice);
- });
- placeholder.find('input').val(SN.msg('reply_placeholder'));
+ placeholder.find('input')
+ .val(SN.msg('reply_placeholder'))
+ .focus(function() {
+ SN.U.NoticeInlineReplyTrigger(notice);
+ return false;
+ });
list.append(placeholder);
},
}
var NGW = form.find('.notice_data-geo_wrap');
- var geocodeURL = NGW.attr('title');
- NGW.removeAttr('title');
+ var geocodeURL = NGW.attr('data-api');
label
.attr('title', label.text());
wrapper = $('<div class="'+SN.C.S.Success+' geo_status_wrapper"><button class="close" style="float:right">×</button><div class="geo_status"></div></div>');
wrapper.find('button.close').click(function() {
form.find('[name=notice_data-geo]').removeAttr('checked').change();
+ return false;
});
form.append(wrapper);
}
switchInputFormTab: function(tag) {
// The one that's current isn't current anymore
$('.input_form_nav_tab.current').removeClass('current');
- $('#input_form_nav_'+tag).addClass('current');
+ if (tag == 'placeholder') {
+ // Hack: when showing the placeholder, mark the tab
+ // as current for 'Status'.
+ $('#input_form_nav_status').addClass('current');
+ } else {
+ $('#input_form_nav_'+tag).addClass('current');
+ }
$('.input_form.current').removeClass('current');
- $('#input_form_'+tag).addClass('current');
+ $('#input_form_'+tag)
+ .addClass('current')
+ .find('.ajax-notice').each(function() {
+ var form = $(this);
+ SN.Init.NoticeFormSetup(form);
+ })
+ .find('textarea:first').focus();
}
},
*/
NoticeForm: function() {
if ($('body.user_in').length > 0) {
- $('.ajax-notice').each(function() {
- var form = $(this);
- SN.Init.NoticeFormSetup(form);
+ // SN.Init.NoticeFormSetup() will get run
+ // when forms get displayed for the first time...
+
+ // Hack to initialize the placeholder at top
+ $('#input_form_placeholder input.placeholder').focus(function() {
+ SN.U.switchInputFormTab("status");
+ });
+
+ // Make inline reply forms self-close when clicking out.
+ $('body').bind('click', function(e) {
+ var currentForm = $('#content .input_forms div.current');
+ if (currentForm.length > 0) {
+ if ($('#content .input_forms').has(e.target).length == 0) {
+ // If all fields are empty, switch back to the placeholder.
+ var fields = currentForm.find('textarea, input[type=text], input[type=""]');
+ var anything = false;
+ fields.each(function() {
+ anything = anything || $(this).val();
+ });
+ if (!anything) {
+ SN.U.switchInputFormTab("placeholder");
+ }
+ }
+ }
+
+ var openReplies = $('li.notice-reply');
+ if (openReplies.length > 0) {
+ var target = $(e.target);
+ openReplies.each(function() {
+ // Did we click outside this one?
+ var replyItem = $(this);
+ if (replyItem.has(e.target).length == 0) {
+ var textarea = replyItem.find('.notice_data-text:first');
+ var cur = $.trim(textarea.val());
+ // Only close if there's been no edit.
+ if (cur == '' || cur == textarea.data('initialText')) {
+ var parentNotice = replyItem.closest('li.notice');
+ replyItem.remove();
+ SN.U.NoticeInlineReplyPlaceholder(parentNotice);
+ }
+ }
+ });
+ }
});
}
},
* @param {jQuery} form
*/
NoticeFormSetup: function(form) {
- SN.U.NoticeLocationAttach(form);
- SN.U.FormNoticeXHR(form);
- SN.U.FormNoticeEnhancements(form);
- SN.U.NoticeDataAttach(form);
+ if (!form.data('NoticeFormSetup')) {
+ SN.U.NoticeLocationAttach(form);
+ SN.U.FormNoticeXHR(form);
+ SN.U.FormNoticeEnhancements(form);
+ SN.U.NoticeDataAttach(form);
+ form.data('NoticeFormSetup', true);
+ }
},
/**
-var SN={C:{I:{CounterBlackout:false,MaxLength:140,PatternUsername:/^[0-9a-zA-Z\-_.]*$/,HTTP20x30x:[200,201,202,203,204,205,206,300,301,302,303,304,305,306,307],NoticeFormMaster:null},S:{Disabled:"disabled",Warning:"warning",Error:"error",Success:"success",Processing:"processing",CommandResult:"command_result",FormNotice:"form_notice",NoticeDataGeo:"notice_data-geo",NoticeDataGeoCookie:"NoticeDataGeo",NoticeDataGeoSelected:"notice_data-geo_selected",StatusNetInstance:"StatusNetInstance"}},messages:{},msg:function(a){if(typeof SN.messages[a]=="undefined"){return"["+a+"]"}else{return SN.messages[a]}},U:{FormNoticeEnhancements:function(b){if(jQuery.data(b[0],"ElementData")===undefined){MaxLength=b.find(".count").text();if(typeof(MaxLength)=="undefined"){MaxLength=SN.C.I.MaxLength}jQuery.data(b[0],"ElementData",{MaxLength:MaxLength});SN.U.Counter(b);NDT=b.find(".notice_data-text:first");NDT.bind("keyup",function(c){SN.U.Counter(b)});var a=function(c){window.setTimeout(function(){SN.U.Counter(b)},50)};NDT.bind("cut",a).bind("paste",a)}else{b.find(".count").text(jQuery.data(b[0],"ElementData").MaxLength)}},Counter:function(d){SN.C.I.FormNoticeCurrent=d;var b=jQuery.data(d[0],"ElementData").MaxLength;if(b<=0){return}var c=b-SN.U.CharacterCount(d);var a=d.find(".count");if(c.toString()!=a.text()){if(!SN.C.I.CounterBlackout||c===0){if(a.text()!=String(c)){a.text(c)}if(c<0){d.addClass(SN.C.S.Warning)}else{d.removeClass(SN.C.S.Warning)}if(!SN.C.I.CounterBlackout){SN.C.I.CounterBlackout=true;SN.C.I.FormNoticeCurrent=d;window.setTimeout("SN.U.ClearCounterBlackout(SN.C.I.FormNoticeCurrent);",500)}}}},CharacterCount:function(a){return a.find(".notice_data-text:first").val().length},ClearCounterBlackout:function(a){SN.C.I.CounterBlackout=false;SN.U.Counter(a)},RewriteAjaxAction:function(a){if(document.location.protocol=="https:"&&a.substr(0,5)=="http:"){return a.replace(/^http:\/\/[^:\/]+/,"https://"+document.location.host)}else{return a}},FormXHR:function(a){$.ajax({type:"POST",dataType:"xml",url:SN.U.RewriteAjaxAction(a.attr("action")),data:a.serialize()+"&ajax=1",beforeSend:function(b){a.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled)},error:function(c,d,b){alert(b||d)},success:function(b,c){if(typeof($("form",b)[0])!="undefined"){form_new=document._importNode($("form",b)[0],true);a.replaceWith(form_new)}else{a.replaceWith(document._importNode($("p",b)[0],true))}}})},FormNoticeXHR:function(b){SN.C.I.NoticeDataGeo={};b.append('<input type="hidden" name="ajax" value="1"/>');b.attr("action",SN.U.RewriteAjaxAction(b.attr("action")));var c=function(d,e){b.append($('<p class="form_response"></p>').addClass(d).text(e))};var a=function(){b.find(".form_response").remove()};b.ajaxForm({dataType:"xml",timeout:"60000",beforeSend:function(d){if(b.find(".notice_data-text:first").val()==""){b.addClass(SN.C.S.Warning);return false}b.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled);SN.U.normalizeGeoData(b);return true},error:function(f,g,e){b.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).removeAttr(SN.C.S.Disabled,SN.C.S.Disabled);a();if(g=="timeout"){c("error","Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.")}else{var d=SN.U.GetResponseXML(f);if($("."+SN.C.S.Error,d).length>0){b.append(document._importNode($("."+SN.C.S.Error,d)[0],true))}else{if(parseInt(f.status)===0||jQuery.inArray(parseInt(f.status),SN.C.I.HTTP20x30x)>=0){b.resetForm().find(".attach-status").remove();SN.U.FormNoticeEnhancements(b)}else{c("error","(Sorry! We had trouble sending your notice ("+f.status+" "+f.statusText+"). Please report the problem to the site administrator if this happens again.")}}}},success:function(i,f){a();var n=$("#"+SN.C.S.Error,i);if(n.length>0){c("error",n.text())}else{if($("body")[0].id=="bookmarklet"){self.close()}var d=$("#"+SN.C.S.CommandResult,i);if(d.length>0){c("success",d.text())}else{var m=document._importNode($("li",i)[0],true);var k=$("#notices_primary .notices:first");var l=b.closest("li.notice-reply");if(l.length>0){var e=$(m).attr("id");if($("#"+e).length==0){var j=l.closest("li.notice");l.replaceWith(m);SN.U.NoticeInlineReplyPlaceholder(j)}else{l.remove()}}else{if(k.length>0&&SN.U.belongsOnTimeline(m)){if($("#"+m.id).length===0){var h=b.find("[name=inreplyto]").val();var g="#notices_primary #notice-"+h;if($("body")[0].id=="conversation"){if(h.length>0&&$(g+" .notices").length<1){$(g).append('<ul class="notices"></ul>')}$($(g+" .notices")[0]).append(m)}else{k.prepend(m)}$("#"+m.id).css({display:"none"}).fadeIn(2500);SN.U.NoticeWithAttachment($("#"+m.id));SN.U.NoticeReplyTo($("#"+m.id))}}else{c("success",$("title",i).text())}}}b.resetForm();b.find("[name=inreplyto]").val("");b.find(".attach-status").remove();SN.U.FormNoticeEnhancements(b)}},complete:function(d,e){b.removeClass(SN.C.S.Processing).find(".submit").removeAttr(SN.C.S.Disabled).removeClass(SN.C.S.Disabled);b.find("[name=lat]").val(SN.C.I.NoticeDataGeo.NLat);b.find("[name=lon]").val(SN.C.I.NoticeDataGeo.NLon);b.find("[name=location_ns]").val(SN.C.I.NoticeDataGeo.NLNS);b.find("[name=location_id]").val(SN.C.I.NoticeDataGeo.NLID);b.find("[name=notice_data-geo]").attr("checked",SN.C.I.NoticeDataGeo.NDG)}})},normalizeGeoData:function(a){SN.C.I.NoticeDataGeo.NLat=a.find("[name=lat]").val();SN.C.I.NoticeDataGeo.NLon=a.find("[name=lon]").val();SN.C.I.NoticeDataGeo.NLNS=a.find("[name=location_ns]").val();SN.C.I.NoticeDataGeo.NLID=a.find("[name=location_id]").val();SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked");var b=$.cookie(SN.C.S.NoticeDataGeoCookie);if(b!==null&&b!="disabled"){b=JSON.parse(b);SN.C.I.NoticeDataGeo.NLat=a.find("[name=lat]").val(b.NLat).val();SN.C.I.NoticeDataGeo.NLon=a.find("[name=lon]").val(b.NLon).val();if(b.NLNS){SN.C.I.NoticeDataGeo.NLNS=a.find("[name=location_ns]").val(b.NLNS).val();SN.C.I.NoticeDataGeo.NLID=a.find("[name=location_id]").val(b.NLID).val()}else{a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("")}}if(b=="disabled"){SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked",false).attr("checked")}else{SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked",true).attr("checked")}},GetResponseXML:function(b){try{return b.responseXML}catch(a){return(new DOMParser()).parseFromString(b.responseText,"text/xml")}},NoticeReply:function(){if($("#content .notice_reply").length>0){$("#content .notice").each(function(){SN.U.NoticeReplyTo($(this))})}},NoticeReplyTo:function(a){a.find(".notice_reply").live("click",function(c){c.preventDefault();var b=($(".author .nickname",a).length>0)?$($(".author .nickname",a)[0]):$(".author .nickname.uid");SN.U.NoticeInlineReplyTrigger(a,"@"+b.text());return false})},NoticeInlineReplyTrigger:function(h,i){var b=$($(".notice_id",h)[0]).text();var e=h;var f=h.closest(".notices");if(f.hasClass("threaded-replies")){e=f.closest(".notice")}else{f=$("ul.threaded-replies",h);if(f.length==0){f=$('<ul class="notices threaded-replies xoxo"></ul>');h.append(f)}}var j=$(".notice-reply-form",f);var d=function(){j.find("input[name=inreplyto]").val(b);var m=j.find("textarea");if(m.length==0){throw"No textarea"}var l="";if(i){l=i+" "}m.val(l+m.val().replace(RegExp(l,"i"),""));m.data("initialText",$.trim(i+""));m.focus();if(m[0].setSelectionRange){var k=m.val().length;m[0].setSelectionRange(k,k)}};if(j.length>0){d()}else{$("li.notice-reply-placeholder").remove();var g=$("li.notice-reply",f);if(g.length==0){g=$('<li class="notice-reply"></li>');var c=function(k){var l=document._importNode(k,true);g.append(l);f.append(g);var m=j=$(l);SN.Init.NoticeFormSetup(m);d()};if(SN.C.I.NoticeFormMaster){c(SN.C.I.NoticeFormMaster)}else{var a=$("#form_notice").attr("action");$.get(a,{ajax:1},function(k,m,l){c($("form",k)[0])})}}}},NoticeInlineReplyPlaceholder:function(b){var a=b.find("ul.threaded-replies");var c=$('<li class="notice-reply-placeholder"><input class="placeholder"></li>');c.click(function(){SN.U.NoticeInlineReplyTrigger(b)});c.find("input").val(SN.msg("reply_placeholder"));a.append(c)},NoticeInlineReplySetup:function(){$(".threaded-replies").each(function(){var b=$(this);var a=b.closest(".notice");SN.U.NoticeInlineReplyPlaceholder(a)})},NoticeRepeat:function(){$(".form_repeat").live("click",function(a){a.preventDefault();SN.U.NoticeRepeatConfirmation($(this));return false})},NoticeRepeatConfirmation:function(a){var c=a.find(".submit");var b=c.clone();b.addClass("submit_dialogbox").removeClass("submit");a.append(b);b.bind("click",function(){SN.U.FormXHR(a);return false});c.hide();a.addClass("dialogbox").append('<button class="close">×</button>').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('<div class="attach-status '+SN.C.S.Success+'"><code></code> <button class="close">×</button></div>');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;e<this.files.length;e++){SN.U.PreviewAttach(b,this.files[e])}}})},maxFileSize:function(b){var a=$(b).find("input[name=MAX_FILE_SIZE]").attr("value");if(a){return parseInt(a)}else{return 0}},PreviewAttach:function(d,c){var e=c.type+" "+Math.round(c.size/1024)+"KB";var f=true;var h;if(typeof window.createObjectURL!="undefined"){h=function(i,j){j(window.createObjectURL(i))}}else{if(typeof window.FileReader!="undefined"){h=function(j,k){var i=new FileReader();i.onload=function(l){k(i.result)};i.readAsDataURL(j)}}else{f=false}}var a=["image/png","image/jpeg","image/gif","image/svg+xml"];if($.inArray(c.type,a)==-1){f=false}var g=8*1024*1024;if(c.size>g){f=false}if(f){h(c,function(j){var i=$("<img>").attr("title",e).attr("alt",e).attr("src",j).attr("style","height: 120px");d.find(".attach-status").append(i)})}else{var b=$("<div></div>").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var k=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var l=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var j=a.find("label.notice_data-geo");function f(n){j.attr("title",jQuery.trim(j.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(n){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(n)}else{a.find(".geo_status_wrapper").remove()}}function m(n,o){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(n,o,function(p){var q,r;if(typeof(p.location_ns)!="undefined"){a.find("[name=location_ns]").val(p.location_ns);q=p.location_ns}if(typeof(p.location_id)!="undefined"){a.find("[name=location_id]").val(p.location_id);r=p.location_id}if(typeof(p.name)=="undefined"){NLN_text=o.lat+";"+o.lon}else{NLN_text=p.name}SN.U.NoticeGeoStatus(a,NLN_text,o.lat,o.lon,p.url);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(o.lat);a.find("[name=lon]").val(o.lon);a.find("[name=location_ns]").val(q);a.find("[name=location_id]").val(r);a.find("[name=notice_data-geo]").attr("checked",true);var s={NLat:o.lat,NLon:o.lon,NLNS:q,NLID:r,NLN:NLN_text,NLNU:p.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(s),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var i=h.attr("title");h.removeAttr("title");j.attr("title",j.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){j.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(p){a.find("[name=lat]").val(p.coords.latitude);a.find("[name=lon]").val(p.coords.longitude);var q={lat:p.coords.latitude,lon:p.coords.longitude,token:$("#token").val()};m(i,q)},function(p){switch(p.code){case p.PERMISSION_DENIED:f("Location permission denied.");break;case p.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&k.length>0){var n={lat:e,lon:k,token:$("#token").val()};m(i,n)}else{f();c.remove();j.remove()}}}else{var o=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(o.NLat);a.find("[name=lon]").val(o.NLon);a.find("[name=location_ns]").val(o.NLNS);a.find("[name=location_id]").val(o.NLID);a.find("[name=notice_data-geo]").attr("checked",o.NDG);SN.U.NoticeGeoStatus(a,o.NLN,o.NLat,o.NLon,o.NLNU);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+o.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('<div class="'+SN.C.S.Success+' geo_status_wrapper"><button class="close" style="float:right">×</button><div class="geo_status"></div></div>');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change()});e.append(h)}var b;if(c){b=$("<a></a>").attr("href",c)}else{b=$("<span></span>")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('<button class="close">×</button>');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");$("#input_form_nav_"+a).addClass("current");$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current")}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$(".ajax-notice").each(function(){var a=$(this);SN.Init.NoticeFormSetup(a)})}},NoticeFormSetup:function(a){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a)},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){SN.U.NewDirectMessage()}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},AjaxForms:function(){$("form.ajax").live("submit",function(){SN.U.FormXHR($(this));return false})},UploadForms:function(){$("input[type=file]").change(function(d){if(typeof this.files=="object"&&this.files.length>0){var c=0;for(var b=0;b<this.files.length;b++){c+=this.files[b].size}var a=SN.U.maxFileSize($(this.form));if(a>0&&c>a){var e="File too large: maximum upload size is %d bytes.";alert(e.replace("%d",a));$(this).val("");d.preventDefault();return false}}})}}};$(document).ready(function(){SN.Init.AjaxForms();SN.Init.UploadForms();if($("."+SN.C.S.FormNotice).length>0){SN.Init.NoticeForm()}if($("#content .notices").length>0){SN.Init.Notices()}if($("#content .entity_actions").length>0){SN.Init.EntityActions()}if($("#form_login").length>0){SN.Init.Login()}});if(!document.ELEMENT_NODE){document.ELEMENT_NODE=1;document.ATTRIBUTE_NODE=2;document.TEXT_NODE=3;document.CDATA_SECTION_NODE=4;document.ENTITY_REFERENCE_NODE=5;document.ENTITY_NODE=6;document.PROCESSING_INSTRUCTION_NODE=7;document.COMMENT_NODE=8;document.DOCUMENT_NODE=9;document.DOCUMENT_TYPE_NODE=10;document.DOCUMENT_FRAGMENT_NODE=11;document.NOTATION_NODE=12}document._importNode=function(e,a){switch(e.nodeType){case document.ELEMENT_NODE:var d=document.createElement(e.nodeName);if(e.attributes&&e.attributes.length>0){for(var c=0,b=e.attributes.length;c<b;){if(e.attributes[c].nodeName=="class"){d.className=e.getAttribute(e.attributes[c++].nodeName)}else{d.setAttribute(e.attributes[c].nodeName,e.getAttribute(e.attributes[c++].nodeName))}}}if(a&&e.childNodes&&e.childNodes.length>0){for(var c=0,b=e.childNodes.length;c<b;){d.appendChild(document._importNode(e.childNodes[c++],a))}}return d;break;case document.TEXT_NODE:case document.CDATA_SECTION_NODE:case document.COMMENT_NODE:return document.createTextNode(e.nodeValue);break}};if(typeof navigator.geolocation=="undefined"||navigator.geolocation.shim){(function(){(function(){if(window.google&&google.gears){return}var c=null;if(typeof GearsFactory!="undefined"){c=new GearsFactory()}else{try{c=new ActiveXObject("Gears.Factory");if(c.getBuildInfo().indexOf("ie_mobile")!=-1){c.privateSetGlobalObject(this)}}catch(d){if((typeof navigator.mimeTypes!="undefined")&&navigator.mimeTypes["application/x-googlegears"]){c=document.createElement("object");c.style.display="none";c.width=0;c.height=0;c.type="application/x-googlegears";document.documentElement.appendChild(c)}}}if(!c){return}if(!window.google){google={}}if(!google.gears){google.gears={factory:c}}})();var a=(function(){var d=google.gears.factory.create("beta.geolocation");var c=function(f,e){return function(g){f(g);e.lastPosition=g}};return{shim:true,type:"Gears",lastPosition:null,getCurrentPosition:function(e,g,h){var f=this;var i=c(e,f);d.getCurrentPosition(i,g,h)},watchPosition:function(e,f,g){d.watchPosition(e,f,g)},clearWatch:function(e){d.clearWatch(e)},getPermission:function(g,e,f){d.getPermission(g,e,f)}}});var b=(function(){var i=false;var e=function(){if(!d()&&!i){i=true;var j=document.createElement("script");j.src=(document.location.protocol=="https:"?"https://":"http://")+"www.google.com/jsapi?callback=_google_loader_apiLoaded";j.type="text/javascript";document.getElementsByTagName("body")[0].appendChild(j)}};var c=[];var h=function(j){c.push(j)};var f=function(){if(d()){while(c.length>0){var j=c.pop();j()}}};window._google_loader_apiLoaded=function(){f()};var d=function(){return(window.google&&google.loader)};var g=function(j){if(d()){return true}h(j);e();return false};e();return{shim:true,type:"ClientLocation",lastPosition:null,getCurrentPosition:function(k,n,o){var m=this;if(!g(function(){m.getCurrentPosition(k,n,o)})){return}if(google.loader.ClientLocation){var l=google.loader.ClientLocation;var j={coords:{latitude:l.latitude,longitude:l.longitude,altitude:null,accuracy:43000,altitudeAccuracy:null,heading:null,speed:null},address:{city:l.address.city,country:l.address.country,country_code:l.address.country_code,region:l.address.region},timestamp:new Date()};k(j);this.lastPosition=j}else{if(n==="function"){n({code:3,message:"Using the Google ClientLocation API and it is not able to calculate a location."})}}},watchPosition:function(j,l,m){this.getCurrentPosition(j,l,m);var k=this;var n=setInterval(function(){k.getCurrentPosition(j,l,m)},10000);return n},clearWatch:function(j){clearInterval(j)},getPermission:function(l,j,k){return true}}});navigator.geolocation=(window.google&&google.gears)?a():b()})()};
\ No newline at end of file
+var SN={C:{I:{CounterBlackout:false,MaxLength:140,PatternUsername:/^[0-9a-zA-Z\-_.]*$/,HTTP20x30x:[200,201,202,203,204,205,206,300,301,302,303,304,305,306,307],NoticeFormMaster:null},S:{Disabled:"disabled",Warning:"warning",Error:"error",Success:"success",Processing:"processing",CommandResult:"command_result",FormNotice:"form_notice",NoticeDataGeo:"notice_data-geo",NoticeDataGeoCookie:"NoticeDataGeo",NoticeDataGeoSelected:"notice_data-geo_selected",StatusNetInstance:"StatusNetInstance"}},messages:{},msg:function(a){if(typeof SN.messages[a]=="undefined"){return"["+a+"]"}else{return SN.messages[a]}},U:{FormNoticeEnhancements:function(b){if(jQuery.data(b[0],"ElementData")===undefined){MaxLength=b.find(".count").text();if(typeof(MaxLength)=="undefined"){MaxLength=SN.C.I.MaxLength}jQuery.data(b[0],"ElementData",{MaxLength:MaxLength});SN.U.Counter(b);NDT=b.find(".notice_data-text:first");NDT.bind("keyup",function(c){SN.U.Counter(b)});var a=function(c){window.setTimeout(function(){SN.U.Counter(b)},50)};NDT.bind("cut",a).bind("paste",a)}else{b.find(".count").text(jQuery.data(b[0],"ElementData").MaxLength)}},Counter:function(d){SN.C.I.FormNoticeCurrent=d;var b=jQuery.data(d[0],"ElementData").MaxLength;if(b<=0){return}var c=b-SN.U.CharacterCount(d);var a=d.find(".count");if(c.toString()!=a.text()){if(!SN.C.I.CounterBlackout||c===0){if(a.text()!=String(c)){a.text(c)}if(c<0){d.addClass(SN.C.S.Warning)}else{d.removeClass(SN.C.S.Warning)}if(!SN.C.I.CounterBlackout){SN.C.I.CounterBlackout=true;SN.C.I.FormNoticeCurrent=d;window.setTimeout("SN.U.ClearCounterBlackout(SN.C.I.FormNoticeCurrent);",500)}}}},CharacterCount:function(a){return a.find(".notice_data-text:first").val().length},ClearCounterBlackout:function(a){SN.C.I.CounterBlackout=false;SN.U.Counter(a)},RewriteAjaxAction:function(a){if(document.location.protocol=="https:"&&a.substr(0,5)=="http:"){return a.replace(/^http:\/\/[^:\/]+/,"https://"+document.location.host)}else{return a}},FormXHR:function(a){$.ajax({type:"POST",dataType:"xml",url:SN.U.RewriteAjaxAction(a.attr("action")),data:a.serialize()+"&ajax=1",beforeSend:function(b){a.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled)},error:function(c,d,b){alert(b||d)},success:function(b,c){if(typeof($("form",b)[0])!="undefined"){form_new=document._importNode($("form",b)[0],true);a.replaceWith(form_new)}else{a.replaceWith(document._importNode($("p",b)[0],true))}}})},FormNoticeXHR:function(b){SN.C.I.NoticeDataGeo={};b.append('<input type="hidden" name="ajax" value="1"/>');b.attr("action",SN.U.RewriteAjaxAction(b.attr("action")));var c=function(d,e){b.append($('<p class="form_response"></p>').addClass(d).text(e))};var a=function(){b.find(".form_response").remove()};b.ajaxForm({dataType:"xml",timeout:"60000",beforeSend:function(d){if(b.find(".notice_data-text:first").val()==""){b.addClass(SN.C.S.Warning);return false}b.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled);SN.U.normalizeGeoData(b);return true},error:function(f,g,e){b.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).removeAttr(SN.C.S.Disabled,SN.C.S.Disabled);a();if(g=="timeout"){c("error","Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.")}else{var d=SN.U.GetResponseXML(f);if($("."+SN.C.S.Error,d).length>0){b.append(document._importNode($("."+SN.C.S.Error,d)[0],true))}else{if(parseInt(f.status)===0||jQuery.inArray(parseInt(f.status),SN.C.I.HTTP20x30x)>=0){b.resetForm().find(".attach-status").remove();SN.U.FormNoticeEnhancements(b)}else{c("error","(Sorry! We had trouble sending your notice ("+f.status+" "+f.statusText+"). Please report the problem to the site administrator if this happens again.")}}}},success:function(i,f){a();var n=$("#"+SN.C.S.Error,i);if(n.length>0){c("error",n.text())}else{if($("body")[0].id=="bookmarklet"){self.close()}var d=$("#"+SN.C.S.CommandResult,i);if(d.length>0){c("success",d.text())}else{var m=document._importNode($("li",i)[0],true);var k=$("#notices_primary .notices:first");var l=b.closest("li.notice-reply");if(l.length>0){var e=$(m).attr("id");if($("#"+e).length==0){var j=l.closest("li.notice");l.replaceWith(m);SN.U.NoticeInlineReplyPlaceholder(j)}else{l.remove()}}else{if(k.length>0&&SN.U.belongsOnTimeline(m)){if($("#"+m.id).length===0){var h=b.find("[name=inreplyto]").val();var g="#notices_primary #notice-"+h;if($("body")[0].id=="conversation"){if(h.length>0&&$(g+" .notices").length<1){$(g).append('<ul class="notices"></ul>')}$($(g+" .notices")[0]).append(m)}else{k.prepend(m)}$("#"+m.id).css({display:"none"}).fadeIn(2500);SN.U.NoticeWithAttachment($("#"+m.id));SN.U.NoticeReplyTo($("#"+m.id));SN.U.switchInputFormTab("placeholder")}}else{c("success",$("title",i).text())}}}b.resetForm();b.find("[name=inreplyto]").val("");b.find(".attach-status").remove();SN.U.FormNoticeEnhancements(b)}},complete:function(d,e){b.removeClass(SN.C.S.Processing).find(".submit").removeAttr(SN.C.S.Disabled).removeClass(SN.C.S.Disabled);b.find("[name=lat]").val(SN.C.I.NoticeDataGeo.NLat);b.find("[name=lon]").val(SN.C.I.NoticeDataGeo.NLon);b.find("[name=location_ns]").val(SN.C.I.NoticeDataGeo.NLNS);b.find("[name=location_id]").val(SN.C.I.NoticeDataGeo.NLID);b.find("[name=notice_data-geo]").attr("checked",SN.C.I.NoticeDataGeo.NDG)}})},normalizeGeoData:function(a){SN.C.I.NoticeDataGeo.NLat=a.find("[name=lat]").val();SN.C.I.NoticeDataGeo.NLon=a.find("[name=lon]").val();SN.C.I.NoticeDataGeo.NLNS=a.find("[name=location_ns]").val();SN.C.I.NoticeDataGeo.NLID=a.find("[name=location_id]").val();SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked");var b=$.cookie(SN.C.S.NoticeDataGeoCookie);if(b!==null&&b!="disabled"){b=JSON.parse(b);SN.C.I.NoticeDataGeo.NLat=a.find("[name=lat]").val(b.NLat).val();SN.C.I.NoticeDataGeo.NLon=a.find("[name=lon]").val(b.NLon).val();if(b.NLNS){SN.C.I.NoticeDataGeo.NLNS=a.find("[name=location_ns]").val(b.NLNS).val();SN.C.I.NoticeDataGeo.NLID=a.find("[name=location_id]").val(b.NLID).val()}else{a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("")}}if(b=="disabled"){SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked",false).attr("checked")}else{SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked",true).attr("checked")}},GetResponseXML:function(b){try{return b.responseXML}catch(a){return(new DOMParser()).parseFromString(b.responseText,"text/xml")}},NoticeReply:function(){if($("#content .notice_reply").length>0){$("#content .notice").each(function(){SN.U.NoticeReplyTo($(this))})}},NoticeReplyTo:function(a){a.find(".notice_reply").live("click",function(c){c.preventDefault();var b=($(".author .nickname",a).length>0)?$($(".author .nickname",a)[0]):$(".author .nickname.uid");SN.U.NoticeInlineReplyTrigger(a,"@"+b.text());return false})},NoticeInlineReplyTrigger:function(h,i){var b=$($(".notice_id",h)[0]).text();var e=h;var f=h.closest(".notices");if(f.hasClass("threaded-replies")){e=f.closest(".notice")}else{f=$("ul.threaded-replies",h);if(f.length==0){f=$('<ul class="notices threaded-replies xoxo"></ul>');h.append(f)}}var j=$(".notice-reply-form",f);var d=function(){j.find("input[name=inreplyto]").val(b);var m=j.find("textarea");if(m.length==0){throw"No textarea"}var l="";if(i){l=i+" "}m.val(l+m.val().replace(RegExp(l,"i"),""));m.data("initialText",$.trim(i+""));m.focus();if(m[0].setSelectionRange){var k=m.val().length;m[0].setSelectionRange(k,k)}};if(j.length>0){d()}else{f.find("li.notice-reply-placeholder").remove();var g=$("li.notice-reply",f);if(g.length==0){g=$('<li class="notice-reply"></li>');var c=function(k){var l=document._importNode(k,true);g.append(l);f.append(g);var m=j=$(l);SN.Init.NoticeFormSetup(m);d()};if(SN.C.I.NoticeFormMaster){c(SN.C.I.NoticeFormMaster)}else{var a=$("#form_notice").attr("action");$.get(a,{ajax:1},function(k,m,l){c($("form",k)[0])})}}}},NoticeInlineReplyPlaceholder:function(b){var a=b.find("ul.threaded-replies");var c=$('<li class="notice-reply-placeholder"><input class="placeholder"></li>');c.find("input").val(SN.msg("reply_placeholder")).focus(function(){SN.U.NoticeInlineReplyTrigger(b);return false});a.append(c)},NoticeInlineReplySetup:function(){$(".threaded-replies").each(function(){var b=$(this);var a=b.closest(".notice");SN.U.NoticeInlineReplyPlaceholder(a)})},NoticeRepeat:function(){$(".form_repeat").live("click",function(a){a.preventDefault();SN.U.NoticeRepeatConfirmation($(this));return false})},NoticeRepeatConfirmation:function(a){var c=a.find(".submit");var b=c.clone();b.addClass("submit_dialogbox").removeClass("submit");a.append(b);b.bind("click",function(){SN.U.FormXHR(a);return false});c.hide();a.addClass("dialogbox").append('<button class="close">×</button>').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('<div class="attach-status '+SN.C.S.Success+'"><code></code> <button class="close">×</button></div>');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;e<this.files.length;e++){SN.U.PreviewAttach(b,this.files[e])}}})},maxFileSize:function(b){var a=$(b).find("input[name=MAX_FILE_SIZE]").attr("value");if(a){return parseInt(a)}else{return 0}},PreviewAttach:function(d,c){var e=c.type+" "+Math.round(c.size/1024)+"KB";var f=true;var h;if(typeof window.createObjectURL!="undefined"){h=function(i,j){j(window.createObjectURL(i))}}else{if(typeof window.FileReader!="undefined"){h=function(j,k){var i=new FileReader();i.onload=function(l){k(i.result)};i.readAsDataURL(j)}}else{f=false}}var a=["image/png","image/jpeg","image/gif","image/svg+xml"];if($.inArray(c.type,a)==-1){f=false}var g=8*1024*1024;if(c.size>g){f=false}if(f){h(c,function(j){var i=$("<img>").attr("title",e).attr("alt",e).attr("src",j).attr("style","height: 120px");d.find(".attach-status").append(i)})}else{var b=$("<div></div>").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var k=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var l=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var j=a.find("label.notice_data-geo");function f(n){j.attr("title",jQuery.trim(j.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(n){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(n)}else{a.find(".geo_status_wrapper").remove()}}function m(n,o){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(n,o,function(p){var q,r;if(typeof(p.location_ns)!="undefined"){a.find("[name=location_ns]").val(p.location_ns);q=p.location_ns}if(typeof(p.location_id)!="undefined"){a.find("[name=location_id]").val(p.location_id);r=p.location_id}if(typeof(p.name)=="undefined"){NLN_text=o.lat+";"+o.lon}else{NLN_text=p.name}SN.U.NoticeGeoStatus(a,NLN_text,o.lat,o.lon,p.url);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(o.lat);a.find("[name=lon]").val(o.lon);a.find("[name=location_ns]").val(q);a.find("[name=location_id]").val(r);a.find("[name=notice_data-geo]").attr("checked",true);var s={NLat:o.lat,NLon:o.lon,NLNS:q,NLID:r,NLN:NLN_text,NLNU:p.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(s),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var i=h.attr("data-api");j.attr("title",j.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){j.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(p){a.find("[name=lat]").val(p.coords.latitude);a.find("[name=lon]").val(p.coords.longitude);var q={lat:p.coords.latitude,lon:p.coords.longitude,token:$("#token").val()};m(i,q)},function(p){switch(p.code){case p.PERMISSION_DENIED:f("Location permission denied.");break;case p.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&k.length>0){var n={lat:e,lon:k,token:$("#token").val()};m(i,n)}else{f();c.remove();j.remove()}}}else{var o=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(o.NLat);a.find("[name=lon]").val(o.NLon);a.find("[name=location_ns]").val(o.NLNS);a.find("[name=location_id]").val(o.NLID);a.find("[name=notice_data-geo]").attr("checked",o.NDG);SN.U.NoticeGeoStatus(a,o.NLN,o.NLat,o.NLon,o.NLNU);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+o.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('<div class="'+SN.C.S.Success+' geo_status_wrapper"><button class="close" style="float:right">×</button><div class="geo_status"></div></div>');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("<a></a>").attr("href",c)}else{b=$("<span></span>")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('<button class="close">×</button>');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var b=$(this);SN.Init.NoticeFormSetup(b)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var j=$(this);if(j.has(g.target).length==0){var h=j.find(".notice_data-text:first");var i=$.trim(h.val());if(i==""||i==h.data("initialText")){var e=j.closest("li.notice");j.remove();SN.U.NoticeInlineReplyPlaceholder(e)}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){SN.U.NewDirectMessage()}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},AjaxForms:function(){$("form.ajax").live("submit",function(){SN.U.FormXHR($(this));return false})},UploadForms:function(){$("input[type=file]").change(function(d){if(typeof this.files=="object"&&this.files.length>0){var c=0;for(var b=0;b<this.files.length;b++){c+=this.files[b].size}var a=SN.U.maxFileSize($(this.form));if(a>0&&c>a){var e="File too large: maximum upload size is %d bytes.";alert(e.replace("%d",a));$(this).val("");d.preventDefault();return false}}})}}};$(document).ready(function(){SN.Init.AjaxForms();SN.Init.UploadForms();if($("."+SN.C.S.FormNotice).length>0){SN.Init.NoticeForm()}if($("#content .notices").length>0){SN.Init.Notices()}if($("#content .entity_actions").length>0){SN.Init.EntityActions()}if($("#form_login").length>0){SN.Init.Login()}});if(!document.ELEMENT_NODE){document.ELEMENT_NODE=1;document.ATTRIBUTE_NODE=2;document.TEXT_NODE=3;document.CDATA_SECTION_NODE=4;document.ENTITY_REFERENCE_NODE=5;document.ENTITY_NODE=6;document.PROCESSING_INSTRUCTION_NODE=7;document.COMMENT_NODE=8;document.DOCUMENT_NODE=9;document.DOCUMENT_TYPE_NODE=10;document.DOCUMENT_FRAGMENT_NODE=11;document.NOTATION_NODE=12}document._importNode=function(e,a){switch(e.nodeType){case document.ELEMENT_NODE:var d=document.createElement(e.nodeName);if(e.attributes&&e.attributes.length>0){for(var c=0,b=e.attributes.length;c<b;){if(e.attributes[c].nodeName=="class"){d.className=e.getAttribute(e.attributes[c++].nodeName)}else{d.setAttribute(e.attributes[c].nodeName,e.getAttribute(e.attributes[c++].nodeName))}}}if(a&&e.childNodes&&e.childNodes.length>0){for(var c=0,b=e.childNodes.length;c<b;){d.appendChild(document._importNode(e.childNodes[c++],a))}}return d;break;case document.TEXT_NODE:case document.CDATA_SECTION_NODE:case document.COMMENT_NODE:return document.createTextNode(e.nodeValue);break}};if(typeof navigator.geolocation=="undefined"||navigator.geolocation.shim){(function(){(function(){if(window.google&&google.gears){return}var c=null;if(typeof GearsFactory!="undefined"){c=new GearsFactory()}else{try{c=new ActiveXObject("Gears.Factory");if(c.getBuildInfo().indexOf("ie_mobile")!=-1){c.privateSetGlobalObject(this)}}catch(d){if((typeof navigator.mimeTypes!="undefined")&&navigator.mimeTypes["application/x-googlegears"]){c=document.createElement("object");c.style.display="none";c.width=0;c.height=0;c.type="application/x-googlegears";document.documentElement.appendChild(c)}}}if(!c){return}if(!window.google){google={}}if(!google.gears){google.gears={factory:c}}})();var a=(function(){var d=google.gears.factory.create("beta.geolocation");var c=function(f,e){return function(g){f(g);e.lastPosition=g}};return{shim:true,type:"Gears",lastPosition:null,getCurrentPosition:function(e,g,h){var f=this;var i=c(e,f);d.getCurrentPosition(i,g,h)},watchPosition:function(e,f,g){d.watchPosition(e,f,g)},clearWatch:function(e){d.clearWatch(e)},getPermission:function(g,e,f){d.getPermission(g,e,f)}}});var b=(function(){var i=false;var e=function(){if(!d()&&!i){i=true;var j=document.createElement("script");j.src=(document.location.protocol=="https:"?"https://":"http://")+"www.google.com/jsapi?callback=_google_loader_apiLoaded";j.type="text/javascript";document.getElementsByTagName("body")[0].appendChild(j)}};var c=[];var h=function(j){c.push(j)};var f=function(){if(d()){while(c.length>0){var j=c.pop();j()}}};window._google_loader_apiLoaded=function(){f()};var d=function(){return(window.google&&google.loader)};var g=function(j){if(d()){return true}h(j);e();return false};e();return{shim:true,type:"ClientLocation",lastPosition:null,getCurrentPosition:function(k,n,o){var m=this;if(!g(function(){m.getCurrentPosition(k,n,o)})){return}if(google.loader.ClientLocation){var l=google.loader.ClientLocation;var j={coords:{latitude:l.latitude,longitude:l.longitude,altitude:null,accuracy:43000,altitudeAccuracy:null,heading:null,speed:null},address:{city:l.address.city,country:l.address.country,country_code:l.address.country_code,region:l.address.region},timestamp:new Date()};k(j);this.lastPosition=j}else{if(n==="function"){n({code:3,message:"Using the Google ClientLocation API and it is not able to calculate a location."})}}},watchPosition:function(j,l,m){this.getCurrentPosition(j,l,m);var k=this;var n=setInterval(function(){k.getCurrentPosition(j,l,m)},10000);return n},clearWatch:function(j){clearInterval(j)},getPermission:function(l,j,k){return true}}});navigator.geolocation=(window.google&&google.gears)?a():b()})()};
\ No newline at end of file
'class' => 'input_form_nav_tab');
if ($tag == 'status') {
+ // We're actually showing the placeholder form,
+ // but we special-case the 'Status' tab as if
+ // it were a small version of it.
$attrs['class'] .= ' current';
}
-
$this->elementStart('li', $attrs);
$this->element('a',
$this->elementEnd('ul');
+ $attrs = array('class' => 'input_form current',
+ 'id' => 'input_form_placeholder');
+ $this->elementStart('div', $attrs);
+ $form = new NoticePlaceholderForm($this);
+ $form->show();
+ $this->elementEnd('div');
+
foreach ($tabs as $tag => $title) {
$attrs = array('class' => 'input_form',
'id' => 'input_form_'.$tag);
- if ($tag == 'status') {
- $attrs['class'] .= ' current';
- }
-
$this->elementStart('div', $attrs);
$form = null;
'url' => $object->link,
'is_local' => Notice::REMOTE_OMB,
'source' => 'ostatus');
-
- $this->saveNoticeFromActivity($activity, $actor);
+
+ // $actor is an ostatus_profile
+ $this->saveNoticeFromActivity($activity, $actor->localProfile(), $options);
return false;
}
'is_local' => Notice::REMOTE_OMB,
'source' => 'ostatus');
- $this->saveNoticeFromActivity($activity, $actor, $options);
+ // $actor is an ostatus_profile
+ $this->saveNoticeFromActivity($activity, $actor->localProfile(), $options);
return false;
}
$options = array('source' => 'atompub');
+ // $user->getProfile() is a Profile
$this->saveNoticeFromActivity($activity,
$user->getProfile(),
$options);
'url' => $object->link,
'source' => 'restore');
+ // $user->getProfile() is a Profile
$saved = $this->saveNoticeFromActivity($activity,
$user->getProfile(),
$options);
$this->out->hidden('notice_data-location_ns', empty($this->location_ns) ? (empty($this->profile->location_ns) ? null : $this->profile->location_ns) : $this->location_ns, 'location_ns');
$this->out->elementStart('div', array('class' => 'notice_data-geo_wrap',
- 'title' => common_local_url('geocode')));
+ 'data-api' => common_local_url('geocode')));
// @fixme checkbox method allows no way to change the id without changing the name
//$this->out->checkbox('notice_data-geo', _('Share my location'), true);
--- /dev/null
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Form for posting a notice
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Form
+ * @package StatusNet
+ * @author Brion Vibber <brion@status.net>
+ * @copyright 2011 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+ exit(1);
+}
+
+require_once INSTALLDIR.'/lib/form.php';
+
+/**
+ * Placeholder form for posting a notice
+ *
+ * Frequently-used form for posting a notice
+ *
+ * @category Form
+ * @package StatusNet
+ * @author Brion Vibber <brion@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ *
+ * @see HTMLOutputter
+ */
+class NoticePlaceholderForm extends Widget
+{
+ function show()
+ {
+ // Similar to that for inline replies, but not quite!
+ $placeholder = _('Update your status...');
+ $this->out->elementStart('div', 'form_notice_placeholder');
+ $this->out->element('input', array('class' => 'placeholder',
+ 'value' => $placeholder));
+ $this->out->elementEnd('div');
+ }
+}
$this->elementEnd('div');
}
- /**
- * Local navigation
- *
- * This page is part of the public group, so show that.
- *
- * @return void
- */
- function showLocalNav()
- {
- $nav = new PublicGroupNav($this);
- $nav->show();
- }
/**
* Content area
$current = $this->action->arg('filter');
// Highlight the selected filter. If there is no selected
- // filter, highlight the first filter in the list
- if (!isset($current) && $i == 0
+ // filter, highlight the last filter in the list (all)
+ if (!isset($current) && $i == ($size - 1)
|| $current === strtolower($filter)) {
$classes .= 'current ';
}
{
public $__table = 'poll'; // table name
public $id; // char(36) primary key not null -> UUID
+ public $uri;
public $profile_id; // int -> profile.id
public $question; // text
public $options; // text; newline(?)-delimited
return explode("\n", $this->options);
}
+ /**
+ * Is this a valid selection index?
+ *
+ * @param numeric $selection (1-based)
+ * @return boolean
+ */
+ function isValidSelection($selection)
+ {
+ if ($selection != intval($selection)) {
+ return false;
+ }
+ if ($selection < 1 || $selection > count($this->getOptions())) {
+ return false;
+ }
+ return true;
+ }
+
function getNotice()
{
return Notice::staticGet('uri', $this->uri);
class PollPlugin extends MicroAppPlugin
{
const VERSION = '0.1';
- const POLL_OBJECT = 'http://apinamespace.org/activitystreams/object/poll';
+
+ // @fixme which domain should we use for these namespaces?
+ const POLL_OBJECT = 'http://apinamespace.org/activitystreams/object/poll';
+ const POLL_RESPONSE_OBJECT = 'http://apinamespace.org/activitystreams/object/poll-response';
/**
* Database schema setup
function onRouterInitialized($m)
{
$m->connect('main/poll/new',
- array('action' => 'newpoll'),
- array('id' => '[0-9]+'));
+ array('action' => 'newpoll'));
+
+ $m->connect('main/poll/:id',
+ array('action' => 'showpoll'),
+ array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'));
+
+ $m->connect('main/poll/response/:id',
+ array('action' => 'showpollresponse'),
+ array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'));
$m->connect('main/poll/:id/respond',
array('action' => 'respondpoll'),
function types()
{
- return array(self::POLL_OBJECT);
+ return array(self::POLL_OBJECT, self::POLL_RESPONSE_OBJECT);
}
/**
function saveNoticeFromActivity($activity, $profile, $options=array())
{
// @fixme
+ common_log(LOG_DEBUG, "XXX activity: " . var_export($activity, true));
+ common_log(LOG_DEBUG, "XXX profile: " . var_export($profile, true));
+ common_log(LOG_DEBUG, "XXX options: " . var_export($options, true));
+
+ // Ok for now, we can grab stuff from the XML entry directly.
+ // This won't work when reading from JSON source
+ if ($activity->entry) {
+ $pollElements = $activity->entry->getElementsByTagNameNS(self::POLL_OBJECT, 'poll');
+ $responseElements = $activity->entry->getElementsByTagNameNS(self::POLL_OBJECT, 'response');
+ if ($pollElements->length) {
+ $data = $pollElements->item(0);
+ $question = $data->getAttribute('question');
+ $opts = array();
+ foreach ($data->attributes as $node) {
+ $name = $node->nodeName;
+ if (substr($name, 0, 6) == 'option') {
+ $n = intval(substr($name, 6));
+ if ($n > 0) {
+ $opts[$n - 1] = $node->nodeValue;
+ }
+ }
+ }
+ common_log(LOG_DEBUG, "YYY question: $question");
+ common_log(LOG_DEBUG, "YYY opts: " . var_export($opts, true));
+ try {
+ $notice = Poll::saveNew($profile, $question, $opts, $options);
+ common_log(LOG_DEBUG, "YYY ok: " . $notice->id);
+ return $notice;
+ } catch (Exception $e) {
+ common_log(LOG_DEBUG, "YYY fail: " . $e->getMessage());
+ }
+ } else if ($responseElements->length) {
+ $data = $responseElements->item(0);
+ $pollUri = $data->getAttribute('poll');
+ $selection = intval($data->getAttribute('selection'));
+
+ if (!$pollUri) {
+ throw new Exception('Invalid poll response: no poll reference.');
+ }
+ $poll = Poll::staticGet('uri', $pollUri);
+ if (!$poll) {
+ throw new Exception('Invalid poll response: poll is unknown.');
+ }
+ try {
+ $notice = Poll_response::saveNew($profile, $poll, $selection, $options);
+ common_log(LOG_DEBUG, "YYY response ok: " . $notice->id);
+ return $notice;
+ } catch (Exception $e) {
+ common_log(LOG_DEBUG, "YYY response fail: " . $e->getMessage());
+ }
+ } else {
+ common_log(LOG_DEBUG, "YYY no poll data");
+ }
+ }
}
function activityObjectFromNotice($notice)
{
assert($this->isMyNotice($notice));
+ switch ($notice->object_type) {
+ case self::POLL_OBJECT:
+ return $this->activityObjectFromNoticePoll($notice);
+ case self::POLL_RESPONSE_OBJECT:
+ return $this->activityObjectFromNoticePollResponse($notice);
+ default:
+ throw new Exception('Unexpected type for poll plugin: ' . $notice->object_type);
+ }
+ }
+
+ function activityObjectFromNoticePollResponse($notice)
+ {
$object = new ActivityObject();
$object->id = $notice->uri;
$object->type = self::POLL_OBJECT;
- $object->title = 'Poll title';
- $object->summary = 'Poll summary';
+ $object->title = $notice->content;
+ $object->summary = $notice->content;
+ $object->link = $notice->bestUrl();
+
+ $response = Poll_response::getByNotice($notice);
+ if (!$response) {
+ common_log(LOG_DEBUG, "QQQ notice uri: $notice->uri");
+ } else {
+ $poll = $response->getPoll();
+ /**
+ * For the moment, using a kind of icky-looking schema that happens to
+ * work with out code for generating both Atom and JSON forms, though
+ * I don't like it:
+ *
+ * <poll:response xmlns:poll="http://apinamespace.org/activitystreams/object/poll"
+ * poll="http://..../poll/...."
+ * selection="3" />
+ *
+ * "poll:response": {
+ * "xmlns:poll": http://apinamespace.org/activitystreams/object/poll
+ * "uri": "http://..../poll/...."
+ * "selection": 3
+ * }
+ *
+ */
+ // @fixme there's no way to specify an XML node tree here, like <poll><option/><option/></poll>
+ // @fixme there's no way to specify a JSON array or multi-level tree unless you break the XML attribs
+ // @fixme XML node contents don't get shown in JSON
+ $data = array('xmlns:poll' => self::POLL_OBJECT,
+ 'poll' => $poll->uri,
+ 'selection' => intval($response->selection));
+ $object->extra[] = array('poll:response', $data, '');
+ }
+ return $object;
+ }
+
+ function activityObjectFromNoticePoll($notice)
+ {
+ $object = new ActivityObject();
+ $object->id = $notice->uri;
+ $object->type = self::POLL_RESPONSE_OBJECT;
+ $object->title = $notice->content;
+ $object->summary = $notice->content;
$object->link = $notice->bestUrl();
$poll = Poll::getByNotice($notice);
* option2="Option two"
* option3="Option three"></poll:data>
*
- * "poll:data": {
+ * "poll:response": {
* "xmlns:poll": http://apinamespace.org/activitystreams/object/poll
* "question": "Who wants a poll question?"
* "option1": "Option one"
foreach ($poll->getOptions() as $i => $opt) {
$data['option' . ($i + 1)] = $opt;
}
- $object->extra[] = array('poll:data', $data, '');
+ $object->extra[] = array('poll:poll', $data, '');
return $object;
}
* and Bookmark plugin for if that's right.
*/
function showNotice($notice, $out)
+ {
+ switch ($notice->object_type) {
+ case self::POLL_OBJECT:
+ return $this->showNoticePoll($notice, $out);
+ case self::POLL_RESPONSE_OBJECT:
+ return $this->showNoticePollResponse($notice, $out);
+ default:
+ throw new Exception('Unexpected type for poll plugin: ' . $notice->object_type);
+ }
+ }
+
+ function showNoticePoll($notice, $out)
{
$user = common_current_user();
$out->elementStart('div', array('class' => 'entry-content'));
}
+ function showNoticePollResponse($notice, $out)
+ {
+ $user = common_current_user();
+
+ // @hack we want regular rendering, then just add stuff after that
+ $nli = new NoticeListItem($notice, $out);
+ $nli->showNotice();
+
+ // @fixme
+ $out->elementStart('div', array('class' => 'entry-content'));
+ }
+
function entryForm($out)
{
return new NewPollForm($out);
class Poll_response extends Managed_DataObject
{
public $__table = 'poll_response'; // table name
- public $poll_id; // char(36) primary key not null -> UUID
+ public $id; // char(36) primary key not null -> UUID
+ public $poll_id; // char(36) -> poll.id UUID
public $profile_id; // int -> profile.id
public $selection; // int -> choice #
public $created; // datetime
return array(
'description' => 'Record of responses to polls',
'fields' => array(
- 'poll_id' => array('type' => 'char', 'length' => 36, 'not null' => true, 'description' => 'UUID'),
+ 'id' => array('type' => 'char', 'length' => 36, 'not null' => true, 'description' => 'UUID of the response'),
+ 'uri' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'UUID to the response notice'),
+ 'poll_id' => array('type' => 'char', 'length' => 36, 'not null' => true, 'description' => 'UUID of poll being responded to'),
'profile_id' => array('type' => 'int'),
'selection' => array('type' => 'int'),
'created' => array('type' => 'datetime', 'not null' => true),
),
+ 'primary key' => array('id'),
'unique keys' => array(
+ 'poll_uri_key' => array('uri'),
'poll_response_poll_id_profile_id_key' => array('poll_id', 'profile_id'),
),
'indexes' => array(
)
);
}
+
+ /**
+ * Get a poll response based on a notice
+ *
+ * @param Notice $notice Notice to check for
+ *
+ * @return Poll_response found response or null
+ */
+
+ function getByNotice($notice)
+ {
+ return self::staticGet('uri', $notice->uri);
+ }
+
+ /**
+ * Get the notice that belongs to this response...
+ *
+ * @return Notice
+ */
+ function getNotice()
+ {
+ return Notice::staticGet('uri', $this->uri);
+ }
+
+ function bestUrl()
+ {
+ return $this->getNotice()->bestUrl();
+ }
+
+ /**
+ *
+ * @return Poll
+ */
+ function getPoll()
+ {
+ return Poll::staticGet('id', $this->poll_id);
+ }
+ /**
+ * Save a new poll notice
+ *
+ * @param Profile $profile
+ * @param Poll $poll the poll being responded to
+ * @param int $selection (1-based)
+ * @param array $opts (poll responses)
+ *
+ * @return Notice saved notice
+ */
+
+ static function saveNew($profile, $poll, $selection, $options=null)
+ {
+ if (empty($options)) {
+ $options = array();
+ }
+
+ if (!$poll->isValidSelection($selection)) {
+ throw new ClientException(_m('Invalid poll selection.'));
+ }
+ $opts = $poll->getOptions();
+ $answer = $opts[$selection - 1];
+
+ $pr = new Poll_response();
+ $pr->id = UUID::gen();
+ $pr->profile_id = $profile->id;
+ $pr->poll_id = $poll->id;
+ $pr->selection = $selection;
+
+ if (array_key_exists('created', $options)) {
+ $pr->created = $options['created'];
+ } else {
+ $pr->created = common_sql_now();
+ }
+
+ if (array_key_exists('uri', $options)) {
+ $pr->uri = $options['uri'];
+ } else {
+ $pr->uri = common_local_url('showpollresponse',
+ array('id' => $pr->id));
+ }
+
+ common_log(LOG_DEBUG, "Saving poll response: $pr->id $pr->uri");
+ $pr->insert();
+
+ $content = sprintf(_m('voted for "%s"'),
+ $answer);
+ $rendered = sprintf(_m('voted for “<a href="%s">%s</a>”'),
+ htmlspecialchars($poll->uri),
+ htmlspecialchars($answer));
+
+ $tags = array();
+ $replies = array();
+
+ $options = array_merge(array('urls' => array(),
+ 'rendered' => $rendered,
+ 'tags' => $tags,
+ 'replies' => $replies,
+ 'reply_to' => $poll->getNotice()->id,
+ 'object_type' => PollPlugin::POLL_RESPONSE_OBJECT),
+ $options);
+
+ if (!array_key_exists('uri', $options)) {
+ $options['uri'] = $pr->uri;
+ }
+
+ $saved = Notice::saveNew($profile->id,
+ $content,
+ array_key_exists('source', $options) ?
+ $options['source'] : 'web',
+ $options);
+
+ return $saved;
+ }
}
function prepare($argarray)
{
parent::prepare($argarray);
+ if ($this->boolean('ajax')) {
+ StatusNet::setApi(true);
+ }
$this->user = common_current_user();
function respondPoll()
{
try {
- $response = new Poll_response();
- $response->poll_id = $this->poll->id;
- $response->profile_id = $this->user->id;
- $response->selection = $this->selection;
- $response->created = common_sql_now();
- $response->insert();
-
+ $notice = Poll_response::saveNew($this->user->getProfile(),
+ $this->poll,
+ $this->selection);
} catch (ClientException $ce) {
$this->error = $ce->getMessage();
$this->showPage();
return;
}
- if ($this->arg('ajax')) {
+ if ($this->boolean('ajax')) {
header('Content-Type: text/xml;charset=utf-8');
$this->xw->startDocument('1.0', 'UTF-8');
$this->elementStart('html');
--- /dev/null
+Default avatars are modified from an image by Francesco 'Architetto' Rollandin.
+http://www.openclipart.org/detail/34957
body {
background-color: #C6C8CC;
background-image: url(../images/bg.png);
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
- font-size: 82%;
+ font-family: 'Lato', "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-size: 14px;
+ line-height: 1.6;
+ color: #222;
+}
+
+input, textarea, select, option {
+ font-family: 'Lato', "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-size: 1em;
}
a {color: #3e3e8c;}
+a:hover {color: blue;}
h1 {font-size: 1.6em;}
h2 {font-size: 1.6em;}
h6 {font-size: 1em;}
#wrap {
- width: 930px;
+ width: 960px;
margin: 0px auto;
- padding: 0px 15px 10px 15px;
- background-color: #fff;
- border-left: 10px solid #E0E0E0;
- border-right: 10px solid #E0E0E0;
+ background: #fff url('../images/brdr_black_dot.png') repeat-x 0px 10px;
+ border-left: 10px solid #fff;
+ border-right: 10px solid #fff;
+ padding-top: 10px;
}
#header {
- width: 940px;
+ width: 960px;
padding: 0px;
- padding-top: 50px;
+ padding-top: 12px;
}
address {
float: left;
- margin-right: 20px;
- margin-top: 0px;
-}
-
-.poweredby {
- background: url(../images/sn-tiny.png) no-repeat top left;
- height: 40px;
- font-size: 0.8em;
- color: #fff;
- line-height: 42px;
- padding-left: 50px;
- position: absolute;
- top: 6px;
- left: 0;
+ position: relative;
+ top: 1px;
+ left: 2px;
+ margin: 0px;
+ padding: 0px;
+ height: 24px;
+ width: 148px;
z-index: 99;
- font-style: normal;
-}
-
-.poweredby a {
- color: #fff !important;
- font-weight: bold;
}
#site_nav_global_primary {
display: block;
position: absolute;
- top: 0;
- left: 0;
- z-index: 98;
- background-color: #364A84;
- width: 960px;
- margin-left: -15px;
- margin-top: 0px;
+ top: 10px;
+ right: 0;
+ width: 800px;
+ margin: 0px;
height: 24px;
line-height: 20px;
- border-top: 10px solid #fff;
- border-bottom: 1px solid #fff;
+ -webkit-border-top-right-radius: 6px;
+ -moz-border-radius-topright: 6px;
+ border-top-right-radius: 6px;
+ background: #364A84;
+ background: -moz-linear-gradient(top, #516499 , #364a84);
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#516499), color-stop(100%,#364a84));
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#516499', endColorstr='#364a84',GradientType=0 ); /* XXX move all to ie.css */
}
#site_nav_global_primary ul {
}
#site_nav_global_primary li:last-child {
- margin-right: 16px;
+ margin-right: 10px;
}
#site_nav_global_primary a {
color: #fff !important;
text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.5);
- padding: 2px 12px 2px 12px;
+ padding: 2px 10px 2px 10px;
height: 20px;
display: block;
float: left;
color: #3e3e8c;
}
-.form_notice {
+#core {
+ clear: both;
+ margin: 0px;
+ width: 960px;
+ border-top: 5px solid #FB6104;
+}
+
+#site_nav_local_views {
+ display: block;
float: left;
+ width: 138px;
margin-top: 0px;
- width: 510px;
padding: 10px;
- -webkit-border-radius: 6px;
- -moz-border-radius: 6px;
- border-radius: 6px;
- background: #cdd1dd;
+ padding-top: 22px;
+ background-color: #ececf2;
+ border-left: 1px solid #d8dae6;
+ border-right: 1px solid #d8dae6;
+ min-height: 800px; /* XXX set up equal column heights! */
}
-.form_notice fieldset {
- width: 100%;
+#site_nav_local_views H3 {
+ margin-bottom: 10px;
+ padding-bottom: 6px;
+ background: url('../images/brdr_black_dot.png') repeat-x bottom left;
+ color: #7a7c87;
+ font-size: 1.1em;
+ letter-spacing: 2px;
+ text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.5);
+ text-transform: uppercase;
}
-.form_notice textarea {
- width: 378px;
- height: 54px;
- -webkit-border-radius: 6px;
- -moz-border-radius: 6px;
- border-radius: 6px;
+#site_nav_local_views li {
+ display: block;
+ margin: 0px 0px 8px 0px;
}
-.form_notice label.notice_data-attach {
- top: 27px;
- right: 86px;
+#site_nav_local_views li ul {
+ margin-bottom: 20px;
}
-.form_notice #notice_data-geo_wrap label,
-.form_notice #notice_data-geo_wrap input {
- top: 52px;
- right: 86px;
+#site_nav_local_views a {
+ display: block;
+ padding: 0px 0px 1px 10px;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ text-transform: uppercase;
+ text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.5);
}
-.form_notice #notice_action-submit {
- font-size: 0.9em;
- top: 80px;
- right: -2px;
- height: 2.4em;
- width: 106px;
+#site_nav_local_views a:hover, #site_nav_local_views .current a {
+ color: #fff;
+ text-decoration: none;
+ text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.5);
+ background: #364a84;
+ background: -moz-linear-gradient(top, #7b8dbb , #364a84);
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#7b8dbb), color-stop(100%,#364a84));
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7b8dbb', endColorstr='#364a84',GradientType=0 );
}
-.form_notice .error,
-.form_notice .success,
-.form_notice .notice-status {
- width: 341px;
+#content {
+ width: 520px;
+ margin-right: 0px;
+ padding: 20px;
}
-.form_notice .error {
- margin-left: 0px;
-}
+/* Input forms */
-#core {
- clear: both;
- margin: 0px;
- width: 930px;
- margin-left: 0px;
- margin-top: 8px;
+.input_forms {
+ float: left;
+ position: relative;
+ top: -20px;
+ left: -20px;
+ padding: 18px 20px 0px 20px;
+ background: #fafafa url('../images/brdr_black_dot.png') repeat-x bottom left;
}
-#content {
- width: 530px;
- margin-right: 0px;
- padding-left: 30px;
- padding-right: 30px;
+#input_form_nav {
+ float: left;
+ margin-bottom: 10px;
}
-#site_nav_local_views {
+#input_form_nav li a {
display: block;
float: left;
- width: 130px;
- margin-top: 5px;
+ padding: 0px 10px 1px 10px;
+ margin-right: 10px;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ border: 1px solid #ECECF2;
+ font-weight: bold;
+ line-height: 1.4em;
+ text-shadow: 0px 1px 0px rgba(255, 255, 255, 0.9);
+ background: #ececf2;
+ background: -moz-linear-gradient(top, #fff , #ececf2);
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fff), color-stop(100%,#ececf2));
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fff', endColorstr='#ececf2',GradientType=0 );
}
-#site_nav_local_views H3 {
- border-bottom: 3px solid #A6ADBF;
- color: #A6ADBF;
- font-size: 1.1em;
- letter-spacing: 2px;
- margin-bottom: 10px;
- text-transform: uppercase;
+#input_form_nav li:hover a, #input_form_nav li.current a {
+ color: #fff;
+ text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.5);
+ border: 1px solid #ececf2;
+ background: #364a84;
+ background: -moz-linear-gradient(top, #7b8dbb , #364a84);
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#7b8dbb), color-stop(100%,#364a84));
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7b8dbb', endColorstr='#364a84',GradientType=0 );
}
-#site_nav_local_views li {
- display: block;
- margin: 0px 0px 6px 0px;
+.input_form_nav_tab a, .input_form_nav_tab.current {
+ text-decoration: none !important; /* XXX cf rebase */
}
-#site_nav_local_views li ul {
- margin-bottom: 20px;
+.input_form {
+ position: relative;
+ float: left;
+ width: 520px;
+ padding-bottom: 15px;
}
-#site_nav_local_views a {
- padding: 2px 0px 2px 10px;
- display: block;
- -webkit-border-radius: 6px;
- -moz-border-radius: 6px;
- border-radius: 6px;
+#input_form_status {
+ padding-bottom: 45px;
}
-#site_nav_local_views a:hover {
- background: #8e98b4 !important;
- color: #fff !important;
- text-decoration: none;
- text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.5);
+.form_notice {
+ padding: 0px;
+ background: none;
}
-#site_nav_local_views .current a {
- text-decoration: none;
- background: #8e98b4 !important;
- color: #fff !important;
- text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.5);
+.form_notice fieldset {
+ width: auto;
+ position: static;
}
-#aside_primary {
- background: none;
- width: 210px;
- padding-top: 0px;
+.form_notice #notice_data-text-label {
+ display: none; /* XXX move into input with js */
+}
+
+.form_notice textarea,
+.form_notice_placeholder .placeholder {
+ width: 473px;
+}
+.form_notice textarea {
+ height: 42px;
+ padding: 6px 10px 18px 10px;
+ border: 1px solid #a6a6a6;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.2);
+ -moz-box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.2);
+ -webkit-box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.2);
+ z-index: 97;
+ font-size: 1.2em;
+}
+
+.form_notice label.notice_data-attach {
+ top: 0px;
+ right: 0px;
+ z-index: 96;
+}
+
+.form_notice .notice_data-geo_wrap label,
+.form_notice .notice_data-geo_wrap input {
+ top: 26px;
+ right: 0px;
+ z-index: 99;
+}
+
+.form_notice .count {
+ position: absolute;
+ top: 50px;
+ right: 35px;
+ font-size: 0.8em;
+ height: 1em;
+ z-index: 99;
+}
+
+.form_notice #notice_action-submit {
+ position: absolute;
+ top: 100%;
+ left: 0px;
+ margin-top: -44px;
+ float: left;
+ width: 90px;
+ padding: 0px;
+ z-index: 99;
+}
+
+.form_notice .error,
+.form_notice .success,
+.form_notice .notice-status {
+ width: 478px;
+ position: relative;
+ top: 0px;
+ float: none;
+ clear: none;
+ margin-left: 0px;
margin-top: 5px;
+ padding: 5px 5px 5px 10px;
+ border: 1px solid #ccc;
+}
+
+.form_notice .error {
+ border: 1px solid #d05858;
+}
+
+.form_notice .attach-status code {
+ font-size: 1em;
+}
+
+.input_form fieldset {
+ margin: 0px;
+ padding: 0px;
+}
+
+.input_form fieldset fieldset {
+ margin-bottom: 10px !important;
+}
+
+#aside_primary {
+ width: 218px;
+ padding: 10px;
+ padding-top: 22px;
+ margin-top: 0px;
+ background-color: #ececf2;
+ border-left: 1px solid #d8dae6;
+ border-right: 1px solid #d8dae6;
+ min-height: 800px; /* XXX set up equal column heights! */
}
#aside_primary .section {
width: 100%;
margin-left: 0px;
margin-right: 0px;
+ font-size: 0.88em;
}
#aside_primary h2 {
- border-bottom: 3px solid #A6ADBF;
- color: #A6ADBF;
- font-size: 1.1em;
- letter-spacing: 2px;
margin-bottom: 10px;
+ padding-bottom: 6px;
+ background: url('../images/brdr_black_dot.png') repeat-x bottom left;
+ color: #7a7c87;
+ font-size: 1.25em;
+ letter-spacing: 2px;
+ text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.5);
text-transform: uppercase;
- text-align: right;
}
.section ul.entities {
- width: 290px;
+ width: 220px;
}
.section .entities li {
#popular_notices .avatar {
position: relative;
- top: 2px;
- margin-bottom: 4px;
+ top: 4px;
+ margin-bottom: 6px;
}
#aside_primary td {
color: #A6ADBF;
font-size: 1.4em;
letter-spacing: 4px;
- text-transform: uppercase;
+ text-transform: none;
}
#notices_primary {
}
.notice {
- line-height: 1.35em;
+ line-height: 1.36em;
margin-bottom: 10px;
}
#content .notice .author .photo {
left: 0px;
- top: 6px;
+ top: 9px;
}
#content .notice .entry-title {
- min-height: 34px;
+ min-height: 35px;
}
#showstream .notice .entry-title {
}
.notice div.entry-content {
- font-size: 0.9em;
+ font-size: 0.88em;
line-height: 1.2em;
margin-top: 6px;
opacity: 0.6;
margin-top: 4px;
}
+.threaded-replies {
+ clear: both;
+ float: left;
+ width: 458px;
+ margin-left: 59px;
+ margin-top: 10px;
+ padding-right: 2px;
+ border-left: 3px solid #ECECF2;
+ background: #fafafa;
+ font-size: 1em;
+}
+
+#content .notice .threaded-replies .notice {
+ padding-bottom: 14px;
+ padding-top: 5px;
+ border-bottom: 2px dotted #eee;
+ line-height: 1.36em;
+ margin-top: 0px;
+ margin-bottom: 0px;
+ margin-left: 10px;
+ background: none;
+}
+
+#content .notice .threaded-replies .entry-title {
+ min-height: 1px;
+}
+
+#content .threaded-replies .notice .author .photo {
+ height: 24px;
+ width: 24px;
+ top: 14px;
+ box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
+ -moz-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
+ -webkit-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
+}
+
+#content .notice .threaded-replies .notice .entry-title {
+ margin: 2px 7px 0px 35px;
+}
+
+#content .notice .threaded-replies .notice div.entry-content {
+ clear:left;
+ float:left;
+ margin-left: 35px;
+ margin-top: 10px;
+}
+
+.threaded-replies li {
+ list-style-type: none;
+}
+
+.threaded-replies .notice-reply-comments {
+ margin: 2px 0px 4px 10px;
+}
+
+.threaded-replies .placeholder {
+ margin: 10px;
+ width: 426px;
+}
+
+.threaded-replies .notice-reply {
+ clear: left;
+ position: relative;
+ padding: 10px;
+ padding-bottom: 44px;
+}
+
+.threaded-replies .form_notice textarea {
+ width: 385px;
+}
+
+.threaded-replies .form_notice label.notice_data-attach {
+ top: 10px;
+ right: 10px;
+}
+
+.threaded-replies .form_notice .notice_data-geo_wrap label,
+.threaded-replies .form_notice .notice_data-geo_wrap input {
+ top: 36px;
+ right: 10px;
+}
+
+.threaded-replies .form_notice .count {
+ top: 60px;
+ right: 50px;
+}
+
+.threaded-replies .form_notice #notice_action-submit {
+ left: 10px;
+}
+
+.threaded-replies .form_notice .error,
+.threaded-replies .form_notice .success,
+.threaded-replies .form_notice .notice-status {
+ width: 390px;
+}
+
.pagination {
height: 1.2em;
}
.entity_profile {
float: left;
- width: 435px;
+ width: 360px;
margin-top: 4px;
}
-td.entity_profile { /* cf directory table */
- width: auto;
-}
-
.entity_profile .entity_depiction {
margin-top: 4px;
}
top: -3px;
}
-.pagination {
+#pagination {
height: 1.2em;
padding-bottom: 12px;
-webkit-border-radius: 6px;
}
.form_notice input.submit, .form_settings input.submit, .form_settings input.cancel {
- border-radius: 3px;
- -moz-border-radius: 3px;
- -webkit-border-radius: 3px;
- text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.5);
+ height: 1.9em;
+ padding: 0px 10px;
color:#fff;
- font-weight: normal;
- font-size: 1em;
- height: 2.2em;
- padding-left: 1em;
- padding-right: 1em;
- background: #7080aa;
- background: -moz-linear-gradient(top, #7b8dbb , #7080aa);
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#7b8dbb), color-stop(100%,#7080aa));
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7b8dbb', endColorstr='#7080aa',GradientType=0 );
- border-width: 1px;
+ font-weight: bold;
+ text-transform: uppercase;
+ font-size: 1.2em;
+ text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2);
+ border: 1px solid #d7621c;
+ border-radius: 4px;
+ -moz-border-radius: 4px;
+ -webkit-border-radius: 4px;
+ background: #FB6104;
+ background: -moz-linear-gradient(top, #ff9d63 , #FB6104);
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ff9d63), color-stop(100%,#FB6104));
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff9d63', endColorstr='#FB6104',GradientType=0 );
}
.form_notice input.submit:hover, .form_settings input.submit:hover, .form_settings input.cancel:hover {
- text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.8);
- background: #7b8dbb;
- background: -moz-linear-gradient(top, #7080aa , #7b8dbb);
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#7080aa), color-stop(100%,#7b8dbb));
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7080aa', endColorstr='#7b8dbb',GradientType=0 );
+ text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.6);
+ background: #ff9d63;
+ background: -moz-linear-gradient(top, #FB6104 , #fc8035);
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#FB6104), color-stop(100%,#fc8035));
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#FB6104', endColorstr='#fc8035',GradientType=0 );
}
.form_settings input#settings_design_reset, .form_settings input.cancel {
margin-right: 0px;
}
+/* Directory specific styles */
+
+td.entity_profile {
+ width: auto;
+}
+
+#user_directory {
+ position: relative;
+ top: -20px;
+}
+
+div#user_directory div.alpha_nav > a {
+ border-left: 1px solid #ccc !important;
+ padding-left: 3.5px !important;
+ padding-right: 4px !important;
+ margin-right: 0px;
+ float: left;
+ line-height: 1.4em;
+}
+
+div#user_directory div.alpha_nav > a.first {
+ border-left: none !important;
+}
+
+div#user_directory div.alpha_nav a.current {
+ background-color: #ECECF2 !important;
+}
+
+table.profile_list {
+ margin-top: 10px;
+}
+
+.profile_list th#created {
+ width: 100px;
+}
+
+.profile_list th#subscriptions {
+ width: 120px;
+}
+
+table.profile_list tr.alt {
+ background-color: #fafafa !important;
+}
+
+.profile_list .entity_actions {
+ width: 30px;
+ height: 26px;
+ margin-right: 5px;
+}
+
+.profile_list .entity_actions input {
+ width: 26px;
+ height: 26px;
+ display: block;
+ overflow: hidden;
+ font-size: 0em;
+}
+
+
}/*end of @media screen, projection, tv*/
+external[]="http://fonts.googleapis.com/css?family=Lato:100,100italic,300,300italic,400,400italic,700,700italic,900,900italic"
include=rebase
text-indent:-9999px;
}
-.pagination {
+#pagination {
background-color: #f2f2f2;
clear: left;
margin-top: 20px;
height: 1em;
}
-.pagination dt {
- display: none;
-}
-
-.pagination li {
+#pagination li {
display: inline;
}
-.pagination .nav_prev {
+#pagination .nav_prev {
float: left;
}
-.pagination .nav_next {
+#pagination .nav_next {
float: right;
}
right: 70px;
}
-.realtime-popup .form_notice .notice_data-geo_wrap label, .form_notice .notice_data-geo_wrap input {
+.realtime-popup .form_notice .notice_data-geo_wrap label, .realtime-popup .form_notice .notice_data-geo_wrap input {
right: 2px;
}
.notice-options .notice_delete,
.notice-options form.form_repeat input.submit,
#new_group a,
-.pagination .nav_prev a,
-.pagination .nav_next a,
+#pagination .nav_prev a,
+#pagination .nav_next a,
button.close,
.form_group_leave input.submit,
.form_user_unsubscribe input.submit,
background-position: 0 -1846px;
}
-.pagination .nav_prev a {
+#pagination .nav_prev a {
padding-top: 8px;
padding-left: 25px;
background-position:0 -187px;
}
-.pagination .nav_next a {
+#pagination .nav_next a {
padding-top: 9px;
padding-right: 25px;
background-position: 115% -252px;