Friends.YauserSearch=function(a,b){if(arguments.length>0){this.init.apply(this,arguments)}};Friends.YauserSearch.prototype={init:function(a,b){this.control=a;this.control.YauserSearchControl=this;this.params=b;this.searchError_b=y5.Dom.getDescendants(this.control,"b","b-note-attention")[0];this.search_input=y5.Dom.getDescendant(this.control,"input","text");this.usersList_table=y5.Dom.getDescendant(this.control,"table","b-write-users-list");this.search_btn=y5.Dom.getDescendants(this.control,"input","submit")[0];this.myFriends_link=y5.Dom.getDescendant(this.control,"a","my-friends");this.friendControl=new Friends.FriendControl(this.control);this.search_btn.disabled=false;this.INVALID_SEARCH_TEXT="Логин или имя пользователя должны быть заданы";this.ajaxMethod_search="ajax/search_users_by_name_not_me";if(this.params){this.ajaxMethod_get="ajax/"+this.params.ajaxMethod_get}this.setEvents()},setEvents:function(){var a=this;$(this.control).find(".my-friends").die("click.yausersearch").live("click.yausersearch",function(g){a.hideErrorMessages();a.resetSearchResults();g.preventDefault();a.friendControl.setStatusMessage('Идёт загрузка пользователей
');y5.Events.notify("y5:usersAreFound",a.friendControl,true);if(a.friendsHTML){a.onFriendsSearch(a.friendsHTML);return}var b=a;function f(e,h){b.onFriendsSearch(e.html);b.friendsHTML=e.html}function d(e){a.friendControl.setStatusMessage("ошибка "+e)}var c=friendsURL(a.ajaxMethod_get);jQuery.ajax({url:c,dataType:"json",success:f,error:d})});y5.ShortCut.down([{key:y5.ShortCut.ENTER}],function(b){return new y5.Event("click",this.search_btn,true)},this.search_input,{checkTarget:false,context:this})},onFriendsSearch:function(a){this.fillUsers_select(a);if(this.users_select.options.length===0){this.friendControl.setStatusMessage("никого не найдено");return}this.users_select.selectedIndex=0;this.friendControl.setStatusMessage("← выберите человека");this.friendControl.list=this.users_select;this.friendControl.showUserInfo();y5.Events.notify("y5:userIsSelected",this.friendControl,true);new y5.AEventListener("change",function(){this.friendControl.list=this.users_select;this.friendControl.showUserInfo();y5.Events.notify("y5:userIsSelected",this.friendControl,true)},this.users_select,true,this)},fillUsers_select:function(a){this.users_select=y5.Dom.getDescendant(this.control,"td","list").getElementsByTagName("select")[0];var b=this.users_select.parentNode;a=a.replace(/'/g,"\x27");b.innerHTML=a;this.users_select=b.firstChild},onSearch:function(){this.resetSearchResults();if(!this.isYauserLogin()){this.showErrorMessage(this.searchError_b,this.INVALID_SEARCH_TEXT);return false}y5.Events.notify("y5:usersAreFound",this.friendControl,true);return true},isYauserLogin:function(){return !y5.Strings.isVoid(this.search_input.value)},showErrorMessage:function(a,b){if(b){a.innerHTML=b}y5.Classes.remove(a,"i-hidden")},hideErrorMessages:function(a){y5.Classes.add(this.searchError_b,"i-hidden");y5.Events.notify("y5:hideErrorMessages",this.friendControl,true)},resetSearchResults:function(){this.hideErrorMessages();y5.Events.notify("y5:resetSearchResults",this.friendControl,true)},initUsers_select:function(){this.users_select=y5.Dom.getDescendant(this.control,"td","list").getElementsByTagName("select")[0];new y5.AEventListener("change",function(){y5.Events.notify("y5:userIsSelected",this.friendControl,true)},this.users_select,true,this)}};y5.require(["Dom","Events","ShortCuts","{Friends}.FriendControl"],function(){y5.loaded("{Friends}.YauserSearch");Friends.FriendControl.prototype.searchResponseOKOld=Friends.FriendControl.prototype.searchResponseOK;Friends.FriendControl.prototype.searchResponseOK=function(a,b){var c=b.parent;c.searchResponseOKOld(a,b);if(c.list.length){c.list.selectedIndex=0;c.showUserInfo();c.control.YauserSearchControl.initUsers_select();y5.Events.notify("y5:userIsSelected",c.control.YauserSearchControl.friendControl,true)}};Friends.FriendControl.prototype.searchResponseError=function(a){var b=a.parent;b.setStatusMessage("ошбика "+a)};Friends.FriendControl.prototype.onSearch=function(){if(!this.control.YauserSearchControl.onSearch()){return false}var c=this;this.setStatusMessage('Идёт загрузка пользователей
');var a=getByTagName("input",this.submit.form);var b=friendsURL(this.control.YauserSearchControl.ajaxMethod_search,y5.FormCollector.collectTags(this.control));jQuery.ajax({url:b,dataType:"json",success:function(d){c.searchResponseOK(d,{parent:c})},error:function(d){c.searchResponseError(d,{parent:c})}});return false}});y5.require(["{Friends}.YauserSearch","{Friends}.CommonConstructor"],function(){var a=Friends.CommonConstructor(Friends.YauserSearch);a.prototype.init=function(){Friends.YauserSearch.prototype.init.apply(this,arguments);this.insertError_b=y5.Dom.getDescendants(this.control,"b","b-note-attention")[1];this.yauser_span=y5.Dom.getDescendant(this.control,"b","b-user");this.yauserPreview_div=y5.Dom.getDescendant(this.control,"div","b-friend-name-preview");this.toChange_link=y5.Dom.getDescendant(this.control,"a","to-change");this.yauserName_input=y5.cssQuery('input[name="yauser-name"]',this.control)[0];this.dialogBtns=y5.Dom.getDescendant(this.control,"div","y5-w-buttons");this.ajaxMethod_search="ajax/search_users_by_name";this.ajaxMethod_get="ajax/get_friends";y5.Events.observe("y5:userIsSelected",this.showPreviewBlock,this.friendControl,true,this);y5.Events.observe("y5:usersAreFound",this.showSearchResult,this.friendControl,true,this);y5.Events.observe("y5:resetSearchResults",this.resetSearchResults,this.friendControl,true,this);y5.Events.observe("y5:hideErrorMessages",function(){y5.Classes.add(this.insertError_b,"i-hidden")},this.friendControl,true,this);y5.Events.observe("click",function(b){this.hideErrorMessages();this.yauserName_input.value=this.yauserName;y5.Classes.add(this.yauserPreview_div,"b-friend-name-preview-edit");this.yauserName_input.focus();this.yauserName_input.select();b.preventDefault()},this.toChange_link,true,this);if(!this.has_been_inited){y5.Events.observe("y5:show",function(b){if(typeof b.caller==="object"){this.caller=b.caller;this.caller_params=b.caller_params||{};this.title=this.caller_params.title||"Вставить ссылку на страницу пользователя Я.ру";this.showWidget()}},a,true,this);y5.Events.observe("y5:make",function(c){this.dialog=c;this.control=c.window;var b=this.dialog.element;this.init(this.control);y5.ShortCut.down([{key:y5.ShortCut.ENTER}],function(d){y5.Events.notify("click",this.dialog.button_ok)},this.yauserName_input,{checkTarget:false,context:this});y5.Events.notify("y5:yauser_make",this.caller,true,{caller:this});this.initDialogEvents()},this.getWidgetInitElement(),true,this);this.has_been_inited=true}y5.loaded("{Friends}.YauserSearchInPostInstance")};a.prototype.showSearchResult=function(){y5.Classes.remove(this.usersList_table,"i-hidden")};a.prototype.resetSearchResults=function(){this.yauserLogin="";this.yauserName="";this.yauser_span.innerHTML="";y5.Classes.add(this.usersList_table,"i-hidden");y5.Classes.add(this.yauserPreview_div,"i-hidden");if(this.dialogBtns){y5.Classes.add(this.dialogBtns,"i-hidden")}};a.prototype.showPreviewBlock=function(){y5.Classes.add(this.insertError_b,"i-hidden");if(!this.caller_params.dont_preview){y5.Classes.remove(this.yauserPreview_div,"i-hidden");y5.Classes.remove(this.yauserPreview_div,"b-friend-name-preview-edit")}var c=this.users_select;$(".b-friend-name-preview").yhide();if(c.options&&c.options.length){var b=c.options[this.users_select.selectedIndex];this.yauserLogin=b.id;var d=b.onclick();this.yauserName=d.title;this.data=d;this.data.id=b.value;this.setYauserName();$(".b-friend-name-preview").yshow();y5.Classes.remove(this.dialogBtns,"i-hidden")}};a.prototype.setYauserName=function(){this.yauser_span.innerHTML=this.createYauserLink(this.yauserLogin,this.yauserName)};a.prototype.createYauserLink=function(b,d){var e=d.substring(0,1);var c=d.substring(1);return''+ya.xmlEscape(e)+""+ya.xmlEscape(c)+""};a.prototype.defineYauserName=function(){if(!y5.Strings.isVoid(this.yauserName_input.value)){this.yauserName=this.yauserName_input.value;this.setYauserName()}};a.prototype.getWidgetInitElement=function(){var b=this.dialog?this.dialog.element:this.control;return b};a.prototype.showWidget=function(){var b={title:this.title},d=this.caller_params;if("valign" in d){b.valign=d.valign}if("halign" in d){b.halign=d.halign}var c=y5.Widget.make(this.getWidgetInitElement(),"Widget.Dialog.Standard",b)};a.prototype.showErrorMessage=function(b,c){if(c){b.innerHTML=c}y5.Classes.remove(b,"i-hidden")};a.prototype.initDialogEvents=function(){var b=this.dialog.element;y5.Events.observe("y5:ok",this.onDialogOK,b,true,this);y5.Events.observe("y5:esc",this.onDialogEsc,b,true,this);y5.Events.observe("y5:cancel",this.onDialogCancel,b,true,this);this.initDialogEvents=function(){}};a.prototype.onDialogOK=function(){this.hideErrorMessages();this.defineYauserName();if(this.yauserName.length){y5.Events.notify("y5:yauser_defined",this.caller,true,{login:this.yauserLogin,name:this.yauserName,inflects:this.data.inflects,id:this.data.id})}else{this.showErrorMessage(this.insertError_b,"Не задано имя пользователя");return false}return true};a.prototype.onDialogEsc=function(){y5.Events.notify("y5:yauser_src",this.caller,true,{caller:this});return true};a.prototype.onDialogCancel=function(){y5.Events.notify("y5:yauser_cancel",this.caller,true,{caller:this});return true};Friends.YauserSearchInPost=a;y5.loaded("{Friends}.YauserSearchInPost")});(function(b,a){var c={regAll:/\s?b-smile-(\w+)/ig,regText:/b-smile-disabled/ig,themeText:" b-smile-disabled",processSmiles:function(d){if(!d||typeof(d)=="function"){d=document}b(d).find(".b-smile").each(function(){var e=this;e.className=e.className.replace(c.regAll,"");e.className+=c.themeCurrent;e.onclick=function(){var f=e.className;if(c.regText.test(f)){e.className=f.replace(c.regAll,c.themeCurrent)}else{e.className=f.replace(c.regAll,c.themeText)}}})}};a.namespace("helpers");a.helpers.smileHelper=c;a.queue.add("onload",function(){c.themeCurrent=" b-smile-"+(a.options?a.options.theme:"default");c.processSmiles.apply(this,arguments)})})(jQuery,ya);(function(a,d){var c,b=[{name:"yaru",title:"Я.ру"},{name:"vkontakte",title:"ВКонтакте"},{name:"twitter",title:"Twitter"},{name:"facebook",title:"Facebook"},{name:"lj",title:"LiveJournal"},{name:"odnoklassniki",title:"Одноклассники"},{name:"friendfeed",title:"FriendFeed"},{name:"moimir",title:"Мой Мир"},{name:"moikrug",title:"Мой круг"}];a.namespace("controls");a.controls.share={templates:{layout:a.template('
{items}
'),item:a.template('')},bind:function(){var e=this;c=new a.Popup();d(".b-share-shortcut").live("click.share",function(){e.onClickOn(this)});d(c.params.id).undelegate("selectUrl").delegate(".b-share-popup__input__input","click.selectUrl",function(){this.select()})},onClickOn:function(l){var n=a.getId(l),g=l.onclick(),m="",j,h,k,f=encodeURIComponent(g.link||window.location),e=encodeURIComponent(g.title||document.title);for(h=0,k=b.length;h0){for(h=0,k=j.length;h