Файл: touchSpace/js/form_toolbar.extended.js
Строк: 208
<?php
module_init("form_toolbar",function(){extend(Toolbar,{colors:["#ffffff","#bcbcbc","#708090","#6c6c6c","#454545","#fcc9c9","#fe8c8c","#fe5e5e","#fd5b36","#f82e00","#ffe1c6","#ffc998","#fcad66","#ff9331","#ff810f","#d8ffe0","#92f9a7","#34ff5d","#b2fb82","#89f641","#b7e9ec","#56e5ed","#21cad3","#03939b","#039b80","#cac8e9","#9690ea","#6a60ec","#4866e7","#173bd3","#f3cafb","#e287f4","#c238dd","#a476af","#b53dd2","#000000"]}),FormToolbar.loadStickers=function(e){e?FormToolbar.stickers=e:$.isEmptyObject(FormToolbar.stickers)&&Spaces.services.getStickers(FormToolbar.loadStickers)},extend(FormToolbar.prototype,{has_validator:!0,_initValidator:function(){var e=this;this.form&&$(this.form).submit(function(t){if(e.opts.disable_all||$(e.form.submit_btn).hasClass("main_submit"))for(var s in e.elements)if(e.elements[s].validate(!0)){t.preventDefault();break}})}}),extend(Toolbar.prototype,{validate:function(e){this._setError(!1);var t=[];return this.opts.maxlength&&(e&&this.opts.required&&!this.el.value.length?t.push("Введите текст записи!"):this.el.value.length>this.opts.maxlength&&t.push("Текст не должен превышать "+this.opts.maxlength+" символов!")),t.length&&this._setError(t.join("<br />")),t.length>0},_setError:function(e){var t=$(this.view.wrap),s=$(this.view.error);e?(t.addClass("textarea_error"),s.html(e).show()):(t.removeClass("textarea_error"),s.hide())},has_colors:!0,_colorTable:function(e,t){var s,i,o,l,r,n=this;t.className+=" bb_opt bb_color_layout",s=function(){return n.insert("["+i.tag+"="+this.color+"]","[/"+i.tag+"]",""),!1},i=Toolbar.toolbar_items[e],o=t.appendChild(ce("div",{className:"bb_hide bb_color"})).appendChild(ce("table"));for(r in Toolbar.colors)r&&r%6!=0||(l=o.appendChild(ce("tr"))),l.appendChild(ce("td",{onclick:s,color:Toolbar.colors[r],tid:e},{backgroundColor:Toolbar.colors[r]}))},_initQuoteText:function(){var e=this;e.quote_text=null,$(document.documentElement).on("mouseup.sp_toolbar",function(){window.getSelection?quote_text=window.getSelection():document.getSelection?quote_text=document.getSelection():document.selection&&(quote_text=document.selection.createRange().text),quote_text&&(e.quote_text=quote_text)}),page_loader&&page_loader.push("shutdown",function(){$(document.documentElement).on(".sp_toolbar")})},smiles:!0,_initSmiles:function(){var e=this;e.opts.smile_btn&&$(e.opts.smile_btn).show().click(function(t){t.preventDefault(),e.selectSmiles()})},selectSmiles:function(){this.$smiles_menu=$("#smile_menu_"+this.id),this._renderSmilesMenu(),this.$smiles_menu_body=this.$smiles_menu.find(".smiles_menu-body"),this._smilesCategories()},_smilesCategories:function(){var e,t,s=this,i='<div class="smiles_menu-categories lh_160">';for(e in FormToolbar.smiles.categories)t=FormToolbar.smiles.categories[e],i+='<a href="#smc-'+e+'" smile-cat="'+t.id+'">'+t.title+' <img src="'+ICONS_BASEURL+t.icon+'" alt="" class="middle" /></a>';i+="</div>",this.$smiles_menu_body.html(i).find("a[smile-cat]").click(function(e){e.preventDefault(),s._smilesList(this.getAttribute("smile-cat"))})},_smilesList:function(e,t){var s,i,o,l=this,r="";if("stickers"==t){s=FormToolbar.stickers[e],r+='<div class="stickers_list t_center">',s.bought||(r+='<div>Этот набор стикеров пока недоступен. <a class="free t-block_item t-link_no_underline_block region_link t_center" style="padding:10px !important;" href="'+s.info_link+'"><span class="t-strong_special t-link_item_hover">Купить за 12 монет.</span></a></div>');for(i in s.stickers)o=l._sm(s.stickers[i].split("|")),r+='<img src="'+ICONS_BASEURL+"st/t/"+o.src+'.gif" class="smile" smile="'+o.name+'" />';s.bought&&(r+='<div><a class="free t-block_item t-link_no_underline_block region_link t_center" style="padding:10px !important;" href="'+s.info_link+'">Подробнее »</a></div>'),r+="</div>"}else{r+='<div class="smiles_list">';for(i in FormToolbar.smiles.list[e])o=l._sm(FormToolbar.smiles.list[e][i].split("|")),r+='<img src="'+ICONS_BASEURL+o.src+'.gif" smile="'+o.name+'" /> ';r+='</div><div class="stnd_padd" style="clear:both; border-top: 1px solid #cccaca;"><a href="#back" class="arrow_link smiles_cats">← <span>Вернуться к выбору категорий</span></a></div>'}l.$smiles_menu_body.html(r).find("img[smile]").click(function(e){var t=this;e.preventDefault(),l.replace(function(){return t.getAttribute("smile")+" "}),l._destroySmilesMenu()}),l.$smiles_menu_body.find(".smiles_cats").click(function(e){e.preventDefault(),l._smilesCategories()})},_sm:function(e){var t,s=e[0];return s=s.indexOf("@")>=0?s.substr(1):":"+s,t=1==e.length?":"==s.charAt(0)?s.substr(1):s:e[1],{name:s,src:t}},_renderSmilesMenu:function(){var e,t,s,i=this;if(this.$smiles_menu.show().is(":empty")){e='<div class="smiles_menu-header '+(this.opts.stickers?"":" hide")+'">';for(t in FormToolbar.smiles.st_categories)s=FormToolbar.smiles.st_categories[t],e+='<a href="#ct'+t+'" cat="'+t+'" class="'+(t>0&&!FormToolbar.stickers[t]?"hide":"")+'"><img src="'+ICONS_BASEURL+s.icon+'" alt="" /></a>';$.isEmptyObject(FormToolbar.stickers)&&(e+='<img src="'+ICONS_BASEURL+'roundPreloader.gif" alt="" title="Загрузка стикеров" class="st_preload" />',Spaces.services.getStickers(function(e){FormToolbar.loadStickers(e),i.$smiles_menu.is(":empty")||(i.$smiles_menu.find(".smiles_menu-header").find("a[cat]").each(function(){var e=this.getAttribute("cat");e>0&&FormToolbar.stickers[e]&&$(this).show()}),i.$smiles_menu.find(".st_preload").remove())})),e+='<img src="'+ICONS_BASEURL+'cross_r.gif" alt="" class="close" /></div><div class="smiles_menu-body"></div>',this.$smiles_menu.html(e).find("a[cat]").click(function(e){e.preventDefault();var t=this.getAttribute("cat");0==t?i._smilesCategories():i._smilesList(t,"stickers")}),this.$smiles_menu.click(function(e){e.stopPropagation()}),tick(function(){$([document.body,i.$smiles_menu.find(".close")[0]]).on("click.sp_toolbar",function(e){e.preventDefault(),i._destroySmilesMenu()})})}},_destroySmilesMenu:function(){$(document.body).off(".sp_toolbar"),this.$smiles_menu.empty().hide()}})});
?>