From 69a1ecec9b4b7168fb570d2d07bcfaa0f29fc856 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 24 Oct 2010 15:04:12 -0400 Subject: check for a post --- lib/action.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/action.php') diff --git a/lib/action.php b/lib/action.php index 01bb0f7e9..d8f139246 100644 --- a/lib/action.php +++ b/lib/action.php @@ -1354,4 +1354,15 @@ class Action extends HTMLOutputter // lawsuit $this->clientError(_('There was a problem with your session token.')); } } + + /** + * Check if the current request is a POST + * + * @return boolean true if POST; otherwise false. + */ + + function isPost() + { + return ($_SERVER['REQUEST_METHOD'] == 'POST'); + } } -- cgit v1.2.3-54-g00ecf From da4f8d465ffdf9833c495699eff966810b522c5d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 17 Nov 2010 12:16:50 -0500 Subject: Use minified version of util.js --- js/util.min.js | 1 + lib/action.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 js/util.min.js (limited to 'lib/action.php') diff --git a/js/util.min.js b/js/util.min.js new file mode 100644 index 000000000..0b9dee8f0 --- /dev/null +++ b/js/util.min.js @@ -0,0 +1 @@ +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]},S:{Disabled:"disabled",Warning:"warning",Error:"error",Success:"success",Processing:"processing",CommandResult:"command_result",FormNotice:"form_notice",NoticeDataText:"notice_data-text",NoticeTextCount:"notice_text-count",NoticeInReplyTo:"notice_in-reply-to",NoticeDataAttach:"notice_data-attach",NoticeDataAttachSelected:"notice_data-attach_selected",NoticeActionSubmit:"notice_action-submit",NoticeLat:"notice_data-lat",NoticeLon:"notice_data-lon",NoticeLocationId:"notice_data-location_id",NoticeLocationNs:"notice_data-location_ns",NoticeGeoName:"notice_data-geo_name",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(a){if(jQuery.data(a[0],"ElementData")===undefined){MaxLength=a.find("#"+SN.C.S.NoticeTextCount).text();if(typeof(MaxLength)=="undefined"){MaxLength=SN.C.I.MaxLength}jQuery.data(a[0],"ElementData",{MaxLength:MaxLength});SN.U.Counter(a);NDT=a.find("#"+SN.C.S.NoticeDataText);NDT.bind("keyup",function(b){SN.U.Counter(a)});NDT.bind("keydown",function(b){SN.U.SubmitOnReturn(b,a)})}else{a.find("#"+SN.C.S.NoticeTextCount).text(jQuery.data(a[0],"ElementData").MaxLength)}if($("body")[0].id!="conversation"&&window.location.hash.length===0&&$(window).scrollTop()==0){a.find("textarea").focus()}},SubmitOnReturn:function(b,a){if(b.keyCode==13||b.keyCode==10){a.submit();b.preventDefault();b.stopPropagation();$("#"+a[0].id+" #"+SN.C.S.NoticeDataText).blur();$("body").focus();return false}return true},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("#"+SN.C.S.NoticeTextCount);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("#"+SN.C.S.NoticeDataText).val().length},ClearCounterBlackout:function(a){SN.C.I.CounterBlackout=false;SN.U.Counter(a)},FormXHR:function(a){$.ajax({type:"POST",dataType:"xml",url: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(a){SN.C.I.NoticeDataGeo={};a.append('');a.ajaxForm({dataType:"xml",timeout:"60000",beforeSend:function(b){if(a.find("#"+SN.C.S.NoticeDataText)[0].value.length===0){a.addClass(SN.C.S.Warning);return false}a.addClass(SN.C.S.Processing).find("#"+SN.C.S.NoticeActionSubmit).addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled);SN.C.I.NoticeDataGeo.NLat=$("#"+SN.C.S.NoticeLat).val();SN.C.I.NoticeDataGeo.NLon=$("#"+SN.C.S.NoticeLon).val();SN.C.I.NoticeDataGeo.NLNS=$("#"+SN.C.S.NoticeLocationNs).val();SN.C.I.NoticeDataGeo.NLID=$("#"+SN.C.S.NoticeLocationId).val();SN.C.I.NoticeDataGeo.NDG=$("#"+SN.C.S.NoticeDataGeo).attr("checked");cookieValue=$.cookie(SN.C.S.NoticeDataGeoCookie);if(cookieValue!==null&&cookieValue!="disabled"){cookieValue=JSON.parse(cookieValue);SN.C.I.NoticeDataGeo.NLat=$("#"+SN.C.S.NoticeLat).val(cookieValue.NLat).val();SN.C.I.NoticeDataGeo.NLon=$("#"+SN.C.S.NoticeLon).val(cookieValue.NLon).val();if($("#"+SN.C.S.NoticeLocationNs).val(cookieValue.NLNS)){SN.C.I.NoticeDataGeo.NLNS=$("#"+SN.C.S.NoticeLocationNs).val(cookieValue.NLNS).val();SN.C.I.NoticeDataGeo.NLID=$("#"+SN.C.S.NoticeLocationId).val(cookieValue.NLID).val()}}if(cookieValue=="disabled"){SN.C.I.NoticeDataGeo.NDG=$("#"+SN.C.S.NoticeDataGeo).attr("checked",false).attr("checked")}else{SN.C.I.NoticeDataGeo.NDG=$("#"+SN.C.S.NoticeDataGeo).attr("checked",true).attr("checked")}return true},error:function(c,d,b){a.removeClass(SN.C.S.Processing).find("#"+SN.C.S.NoticeActionSubmit).removeClass(SN.C.S.Disabled).removeAttr(SN.C.S.Disabled,SN.C.S.Disabled);a.find(".form_response").remove();if(d=="timeout"){a.append('

Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.

')}else{if($("."+SN.C.S.Error,c.responseXML).length>0){a.append(document._importNode($("."+SN.C.S.Error,c.responseXML)[0],true))}else{if(parseInt(c.status)===0||jQuery.inArray(parseInt(c.status),SN.C.I.HTTP20x30x)>=0){a.resetForm().find("#"+SN.C.S.NoticeDataAttachSelected).remove();SN.U.FormNoticeEnhancements(a)}else{a.append('

(Sorry! We had trouble sending your notice ('+c.status+" "+c.statusText+"). Please report the problem to the site administrator if this happens again.

")}}}},success:function(f,h){a.find(".form_response").remove();var b;if($("#"+SN.C.S.Error,f).length>0){b=document._importNode($("p",f)[0],true);b=b.textContent||b.innerHTML;a.append('

'+b+"

")}else{if($("body")[0].id=="bookmarklet"){self.close()}if($("#"+SN.C.S.CommandResult,f).length>0){b=document._importNode($("p",f)[0],true);b=b.textContent||b.innerHTML;a.append('

'+b+"

")}else{var e=document._importNode($("li",f)[0],true);var g=$("#notices_primary .notices");if(g.length>0&&SN.U.belongsOnTimeline(e)){if($("#"+e.id).length===0){var c=$("#"+SN.C.S.NoticeInReplyTo).val();var d="#notices_primary #notice-"+c;if($("body")[0].id=="conversation"){if(c.length>0&&$(d+" .notices").length<1){$(d).append('')}$($(d+" .notices")[0]).append(e)}else{g.prepend(e)}$("#"+e.id).css({display:"none"}).fadeIn(2500);SN.U.NoticeWithAttachment($("#"+e.id));SN.U.NoticeReplyTo($("#"+e.id))}}else{b=document._importNode($("title",f)[0],true);result_title=b.textContent||b.innerHTML;a.append('

'+result_title+"

")}}a.resetForm();a.find("#"+SN.C.S.NoticeInReplyTo).val("");a.find("#"+SN.C.S.NoticeDataAttachSelected).remove();SN.U.FormNoticeEnhancements(a)}},complete:function(b,c){a.removeClass(SN.C.S.Processing).find("#"+SN.C.S.NoticeActionSubmit).removeAttr(SN.C.S.Disabled).removeClass(SN.C.S.Disabled);$("#"+SN.C.S.NoticeLat).val(SN.C.I.NoticeDataGeo.NLat);$("#"+SN.C.S.NoticeLon).val(SN.C.I.NoticeDataGeo.NLon);if($("#"+SN.C.S.NoticeLocationNs)){$("#"+SN.C.S.NoticeLocationNs).val(SN.C.I.NoticeDataGeo.NLNS);$("#"+SN.C.S.NoticeLocationId).val(SN.C.I.NoticeDataGeo.NLID)}$("#"+SN.C.S.NoticeDataGeo).attr("checked",SN.C.I.NoticeDataGeo.NDG)}})},NoticeReply:function(){if($("#"+SN.C.S.NoticeDataText).length>0&&$("#content .notice_reply").length>0){$("#content .notice").each(function(){SN.U.NoticeReplyTo($(this))})}},NoticeReplyTo:function(a){a.find(".notice_reply").live("click",function(){var b=($(".author .nickname",a).length>0)?$($(".author .nickname",a)[0]):$(".author .nickname.uid");SN.U.NoticeReplySet(b.text(),$($(".notice_id",a)[0]).text());return false})},NoticeReplySet:function(b,d){if(b.match(SN.C.I.PatternUsername)){var c=$("#"+SN.C.S.NoticeDataText);if(c.length>0){replyto="@"+b+" ";c.val(replyto+c.val().replace(RegExp(replyto,"i"),""));$("#"+SN.C.S.FormNotice+" #"+SN.C.S.NoticeInReplyTo).val(d);c[0].focus();if(c[0].setSelectionRange){var a=c.val().length;c[0].setSelectionRange(a,a)}}}},NoticeFavor:function(){$(".form_favor").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_disfavor").live("click",function(){SN.U.FormXHR($(this));return false})},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('').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(){NDA=$("#"+SN.C.S.NoticeDataAttach);NDA.change(function(){S='
'+$(this).val()+'
';NDAS=$("#"+SN.C.S.NoticeDataAttachSelected);if(NDAS.length>0){NDAS.replaceWith(S)}else{$("#"+SN.C.S.FormNotice).append(S)}$("#"+SN.C.S.NoticeDataAttachSelected+" button").click(function(){$("#"+SN.C.S.NoticeDataAttachSelected).remove();NDA.val("");return false})})},NoticeLocationAttach:function(){var c=$("#"+SN.C.S.NoticeLat).val();var h=$("#"+SN.C.S.NoticeLon).val();var d=$("#"+SN.C.S.NoticeLocationNs).val();var i=$("#"+SN.C.S.NoticeLocationId).val();var a=$("#"+SN.C.S.NoticeGeoName).text();var b=$("#"+SN.C.S.NoticeDataGeo);function e(){$("label[for="+SN.C.S.NoticeDataGeo+"]").attr("title",jQuery.trim($("label[for="+SN.C.S.NoticeDataGeo+"]").text())).removeClass("checked");$("#"+SN.C.S.NoticeLat).val("");$("#"+SN.C.S.NoticeLon).val("");$("#"+SN.C.S.NoticeLocationNs).val("");$("#"+SN.C.S.NoticeLocationId).val("");$("#"+SN.C.S.NoticeDataGeo).attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"})}function j(k,l){$.getJSON(k,l,function(m){var n,o;if(typeof(m.location_ns)!="undefined"){$("#"+SN.C.S.NoticeLocationNs).val(m.location_ns);n=m.location_ns}if(typeof(m.location_id)!="undefined"){$("#"+SN.C.S.NoticeLocationId).val(m.location_id);o=m.location_id}if(typeof(m.name)=="undefined"){NLN_text=l.lat+";"+l.lon}else{NLN_text=m.name}$("label[for="+SN.C.S.NoticeDataGeo+"]").attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");$("#"+SN.C.S.NoticeLat).val(l.lat);$("#"+SN.C.S.NoticeLon).val(l.lon);$("#"+SN.C.S.NoticeLocationNs).val(n);$("#"+SN.C.S.NoticeLocationId).val(o);$("#"+SN.C.S.NoticeDataGeo).attr("checked",true);var p={NLat:l.lat,NLon:l.lon,NLNS:n,NLID:o,NLN:NLN_text,NLNU:m.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(p),{path:"/"})})}if(b.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){b.attr("checked",false)}else{b.attr("checked",true)}var f=$("#notice_data-geo_wrap");var g=f.attr("title");f.removeAttr("title");$("label[for="+SN.C.S.NoticeDataGeo+"]").attr("title",jQuery.trim($("label[for="+SN.C.S.NoticeDataGeo+"]").text()));b.change(function(){if($("#"+SN.C.S.NoticeDataGeo).attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){$("label[for="+SN.C.S.NoticeDataGeo+"]").attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(m){$("#"+SN.C.S.NoticeLat).val(m.coords.latitude);$("#"+SN.C.S.NoticeLon).val(m.coords.longitude);var n={lat:m.coords.latitude,lon:m.coords.longitude,token:$("#token").val()};j(g,n)},function(m){switch(m.code){case m.PERMISSION_DENIED:e();break;case m.TIMEOUT:$("#"+SN.C.S.NoticeDataGeo).attr("checked",false);break}},{timeout:10000})}else{if(c.length>0&&h.length>0){var k={lat:c,lon:h,token:$("#token").val()};j(g,k)}else{e();$("#"+SN.C.S.NoticeDataGeo).remove();$("label[for="+SN.C.S.NoticeDataGeo+"]").remove()}}}else{var l=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));$("#"+SN.C.S.NoticeLat).val(l.NLat);$("#"+SN.C.S.NoticeLon).val(l.NLon);$("#"+SN.C.S.NoticeLocationNs).val(l.NLNS);$("#"+SN.C.S.NoticeLocationId).val(l.NLID);$("#"+SN.C.S.NoticeDataGeo).attr("checked",l.NDG);$("label[for="+SN.C.S.NoticeDataGeo+"]").attr("title",NoticeDataGeo_text.ShareDisable+" ("+l.NLN+")").addClass("checked")}}else{e()}}).change()}},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('');$(".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(".entry-title .author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false}},Init:{NoticeForm:function(){if($("body.user_in").length>0){SN.U.NoticeLocationAttach();$("."+SN.C.S.FormNotice).each(function(){SN.U.FormNoticeXHR($(this));SN.U.FormNoticeEnhancements($(this))});SN.U.NoticeDataAttach()}},Notices:function(){if($("body.user_in").length>0){SN.U.NoticeFavor();SN.U.NoticeRepeat();SN.U.NoticeReply()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});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})}}};$(document).ready(function(){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;c0){for(var c=0,b=e.childNodes.length;c0){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 diff --git a/lib/action.php b/lib/action.php index 17d3e2311..318c3063e 100644 --- a/lib/action.php +++ b/lib/action.php @@ -282,7 +282,7 @@ class Action extends HTMLOutputter // lawsuit } if (Event::handle('StartShowStatusNetScripts', array($this)) && Event::handle('StartShowLaconicaScripts', array($this))) { - $this->script('util.js'); + $this->script('util.min.js'); $this->showScriptMessages(); // Frame-busting code to avoid clickjacking attacks. $this->inlineScript('if (window.top !== window.self) { window.top.location.href = window.self.location.href; }'); -- cgit v1.2.3-54-g00ecf From bacc3d2a74ca09e0287ca7b14f2bb746810311da Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 17 Nov 2010 12:19:01 -0500 Subject: move EndScriptMessages event into if block --- lib/action.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/action.php') diff --git a/lib/action.php b/lib/action.php index 17d3e2311..c2285894e 100644 --- a/lib/action.php +++ b/lib/action.php @@ -300,9 +300,11 @@ class Action extends HTMLOutputter // lawsuit * events and appending to the array. Try to avoid adding strings that won't be used, as * they'll be added to HTML output. */ + function showScriptMessages() { $messages = array(); + if (Event::handle('StartScriptMessages', array($this, &$messages))) { // Common messages needed for timeline views etc... @@ -310,11 +312,14 @@ class Action extends HTMLOutputter // lawsuit $messages['showmore_tooltip'] = _m('TOOLTIP', 'Show more'); $messages = array_merge($messages, $this->getScriptMessages()); + + Event::handle('EndScriptMessages', array($this, &$messages)); } - Event::handle('EndScriptMessages', array($this, &$messages)); - if ($messages) { + + if (!empty($messages)) { $this->inlineScript('SN.messages=' . json_encode($messages)); } + return $messages; } -- cgit v1.2.3-54-g00ecf From d3d91f0f6eff49b4d36d2352cdadc23f3825270d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 17 Nov 2010 12:31:35 -0500 Subject: use minified version of jquery.form.js --- js/jquery.form.min.js | 11 +++++++++++ lib/action.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 js/jquery.form.min.js (limited to 'lib/action.php') diff --git a/js/jquery.form.min.js b/js/jquery.form.min.js new file mode 100644 index 000000000..04c26a6ec --- /dev/null +++ b/js/jquery.form.min.js @@ -0,0 +1,11 @@ +/* + * jQuery Form Plugin + * version: 2.49 (18-OCT-2010) + * @requires jQuery v1.3.2 or later + * + * Examples and documentation at: http://malsup.com/jquery/form/ + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + */ +(function(b){b.fn.ajaxSubmit=function(s){if(!this.length){a("ajaxSubmit: skipping submit process - no element selected");return this}if(typeof s=="function"){s={success:s}}var d=b.trim(this.attr("action"));if(d){d=(d.match(/^([^#]+)/)||[])[1]}d=d||window.location.href||"";s=b.extend(true,{url:d,type:this.attr("method")||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},s);var t={};this.trigger("form-pre-serialize",[this,s,t]);if(t.veto){a("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this}if(s.beforeSerialize&&s.beforeSerialize(this,s)===false){a("ajaxSubmit: submit aborted via beforeSerialize callback");return this}var f,o,l=this.formToArray(s.semantic);if(s.data){s.extraData=s.data;for(f in s.data){if(s.data[f] instanceof Array){for(var h in s.data[f]){l.push({name:f,value:s.data[f][h]})}}else{o=s.data[f];o=b.isFunction(o)?o():o;l.push({name:f,value:o})}}}if(s.beforeSubmit&&s.beforeSubmit(l,this,s)===false){a("ajaxSubmit: submit aborted via beforeSubmit callback");return this}this.trigger("form-submit-validate",[l,this,s,t]);if(t.veto){a("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this}var c=b.param(l);if(s.type.toUpperCase()=="GET"){s.url+=(s.url.indexOf("?")>=0?"&":"?")+c;s.data=null}else{s.data=c}var r=this,j=[];if(s.resetForm){j.push(function(){r.resetForm()})}if(s.clearForm){j.push(function(){r.clearForm()})}if(!s.dataType&&s.target){var p=s.success||function(){};j.push(function(n){var k=s.replaceTarget?"replaceWith":"html";b(s.target)[k](n).each(p,arguments)})}else{if(s.success){j.push(s.success)}}s.success=function(v,n,w){var u=s.context||s;for(var q=0,k=j.length;q0;var e="multipart/form-data";var i=(r.attr("enctype")==e||r.attr("encoding")==e);if(s.iframe!==false&&(g||s.iframe||i)){if(s.closeKeepAlive){b.get(s.closeKeepAlive,m)}else{m()}}else{b.ajax(s)}this.trigger("form-submit-notify",[this,s]);return this;function m(){var k=r[0];if(b(":input[name=submit],:input[id=submit]",k).length){alert('Error: Form elements must not have name or id of "submit".');return}var y=b.extend(true,{},b.ajaxSettings,s);y.context=y.context||y;var B="jqFormIO"+(new Date().getTime()),w="_"+B;window[w]=function(){var n=q.data("form-plugin-onload");if(n){n();window[w]=undefined;try{delete window[w]}catch(K){}}};var q=b('