forked from OpenNeo/impress
1 line
23 KiB
JavaScript
1 line
23 KiB
JavaScript
|
$.fn.notify=function(){return this.stop(!0,!0).show("slow").delay(5e3).hide("fast")},$.fn.startLoading=function(){return this.delay(1e3).queue(function(e){$(this).addClass("loading"),e()})},$.fn.stopLoading=function(){return this.removeClass("loading").clearQueue()};var Partial={},main_wardrobe,View=Wardrobe.getStandardView({Preview:{swf_url:"/swfs/preview.swf?v=0.12",wrapper:$("#preview-swf"),placeholder:$("#preview-swf-container"),image_container:"#preview-image-container"}});Partial.ItemSet=function(t,n){function h(e){return function(t){var n,r,i;for(var o=0;o<s.length;o++)n=s[o],in_set=$.inArray(n,t)!=-1,i=$("li.object-"+n.id).toggleClass(e,in_set).data("item",n).data(e,in_set)}}function p(e){var n,r,i,s;for(var o=0,u=e.length;o<u;o++)n=e[o],r=n.couldNotLoadAssetsFitting(t.outfits.getPetType()),i=$("li.object-"+n.id).toggleClass("no-assets",r)}var r=this,i=$(n),s=[],o,u,a,f=$("#no-assets-full-message"),l=$("#container"),c=$("#item-template");Partial.ItemSet.setWardrobe(t),o=h("closeted"),a=h("worn"),u=function(e){a(e),p(e)},this.setItems=function(e){var n,r,a,f;s=e,i.children().remove();for(var l=0;l<s.length;l++)n=s[l],r=c.tmpl({id:n.id,name:n.name,description:n.description,thumbnail_url:n.thumbnail_url,url:n.getURL(),nc:typeof n.rarity_index!="undefined"&&(n.rarity_index==500||n.rarity_index==0),owned:n.owned,wanted:n.wanted}),r.appendTo(i);o(t.outfits.getClosetItems()),u(t.outfits.getWornItems())},$("span.no-assets-message").live("mouseover",function(){var e=$(this),t=e.offset();f.css({left:t.left+e.width()/2-f.width()/2-l.offset().left,top:t.top+e.height()+10})}).live("mouseout",function(){f.removeAttr("style")}),t.outfits.bind("updateItemAssets",function(){p(t.outfits.getWornItems())}),t.outfits.bind("updateWornItems",u),t.outfits.bind("updateClosetItems",o)},Partial.ItemSet.CONTROL_SETS={},Partial.ItemSet.setWardrobe=function(e){var t,n,r={},i={worn:{},closeted:{}};i.worn["false"]="wear-item",i.worn["true"]="unwear-item",i.closeted["false"]="closet-item",i.closeted["true"]="uncloset-item";for(t in i)for(toggleKey in i[t]){var n=toggleKey=="true";(function(e,t){$("li."+i[e][t]+" a").live("click",function(n){n.preventDefault();var i=$(this).closest(".object").data("item");log(this,i,e,t,!t),r[e][!t](i)})})(t,n)}r.closeted={},r.closeted[!0]=$.proxy(e.outfits,"closetItem"),r.closeted[!1]=$.proxy(e.outfits,"unclosetItem"),r.worn={},r.worn[!0]=$.proxy(e.outfits,"wearItem"),r.worn[!1]=$.proxy(e.outfits,"unwearItem"),Partial.ItemSet.setWardrobe=$.noop},View.Closet=function(e){var t=new Partial.ItemSet(e,"#preview-closet ul");e.outfits.bind("updateClosetItems",$.proxy(t,"setItems"))},View.Fullscreen=function(e){function h(){if(!c){var e=l.height()>500;e!=t&&(t=e,$(document.body).toggleClass("fullscreen",t),t||(s.removeAttr("style").css("visibility","visible"),r.removeAttr("style"),u.removeAttr("style")))}if(t){s=$("#preview-swf");var n={height:i.offset().top-r.offset().top,width:r.innerWidth()-o.outerWidth()-12},f={},h={},p={old:{height:s.height(),width:s.width()},next:{}},d;n.height>n.width?(f.larger="height",f.smaller="width",h.active="marginTop",h.inactive="marginLeft"):(f.larger="width",f.smaller="height",h.active="marginLeft",h.inactive="marginTop"),p.next[f.smaller]=n[f.smaller],p.next[f.larger]=n[f.smaller],p.next[h.active]=(n[f.larger]-p.next[f.larger])/2,p.next[h.inactive]=0,s.css(p.next),r.height(n.height);var v=n.height-a.outerHeight()-1;u.height(v)}}function p(){setTimeout(h,0)}var t=$(document.body).hasClass("fullscreen"),n=$(window),r=$("#preview"),i=$("#preview-search-form"),s=$("#preview-swf"),o=$("#preview-sidebar"),u=$("#preview-sidebar-content"),a=$("#preview-sidebar-navbar"),f=$("#footer"),l=$(window),c=!1;$("#preview").data("fit",h),n.resize(h).load(h),e.item_zone_sets.bind("update",p),e.pet_attributes.bind("update",p),h()},View.Hash=function(e){function a(){var e=(document.location.hash||document.location.search).substr(1);e!=r&&(f(e),r=e)}function f(n){var r={},u=n.split("&");i=!0;for(var a=0;a<u.length;a++){var f=u[a].split("="),l=decodeURIComponent(f[0]),c=decodeURIComponent(f[1]);c&&(o[l]==s.I
|