|
|
/** # Semantic UI * Version: 0.1 * http://github.com/quirkyinc/semantic
* * * Copyright 2013 Contributors * Released under the MIT license * http://opensource.org/licenses/MIT
* * Released: 05/29/2013 */ (function(e,t,n,o){e.fn.accordion=function(t){var n=e.extend(!0,{},e.fn.accordion.settings,t),i=arguments||!1;return e(this).each(function(){var t,a=e(this),r=a.find(n.selector.title),s=(a.find(n.selector.icon),a.find(n.selector.content)),l=a.data("module"),c=n.className;return t={initialize:function(){r.on("click",t.change),a.data("module",t)},change:function(){var o=e(this),i=(o.next(s),o.hasClass(c.active));i?n.collapsible&&e.proxy(t.close,o)():e.proxy(t.open,o)()},open:function(){var t=e(this),o=t.next(s),i=r.filter("."+c.active),a=i.next(r);n.exclusive&&i.size()>0&&(i.removeClass("active"),a.stop().slideUp(n.speed,n.easing,function(){e(this).removeClass("active").removeAttr("style")})),t.addClass(c.active),o.hide().addClass(c.active).stop().slideDown(n.speed,n.easing,function(){e(this).removeAttr("style")})},close:function(){var t=e(this),o=t.next(s);t.removeClass(c.active),o.removeClass(c.active).show().stop().slideUp(n.speed,n.easing,function(){e(this).removeAttr("style")})},debug:function(e){n.debug&&console.info(n.moduleName+": "+e)},error:function(e){console.warn(n.moduleName+": "+e)},invoke:function(i,a,r){var s;return r=r||Array.prototype.slice.call(arguments,2),"string"==typeof i&&l!==o&&(i=i.split("."),e.each(i,function(o,i){return e.isPlainObject(l[i])?(l=l[i],!0):e.isFunction(l[i])?(s=l[i],!0):(t.error(n.errors.method),!1)})),e.isFunction(s)?s.apply(a,r):s}},l!==o&&i?("invoke"==i[0]&&(i=Array.prototype.slice.call(i,1)),t.invoke(i[0],this,Array.prototype.slice.call(i,1))):(t.initialize(),o)}),this},e.fn.accordion.settings={moduleName:"Accordion",debug:!1,exclusive:!0,collapsible:!0,errors:{method:"The method you called is not defined"},className:{active:"active",hover:"hover"},selector:{title:".title",icon:".icon",content:".content"},speed:500,easing:"easeInOutQuint"}})(jQuery,window,document),function(e,t,n,o){e.animationSettings=function(t,n,i,a){return t=n===o?t:"object"==typeof n?e.extend({},t,n):"function"==typeof i?e.extend({},t,{duration:n,complete:i}):"object"==typeof i?e.extend(!0,{},t,{duration:n},i):e.extend({},t,{duration:n,easing:i,complete:a})},e.fn.popIn=function(t,n,o){var i=e.animationSettings(e.fn.popIn.settings,t,n,o),a=e(this),r=a.size(),s=0,l=function(){0==a.filter(":animated").size(),s++,e(this).css("transform","").removeClass(i.className.init),e.proxy(i.eachComplete,this)(),s==r&&e.proxy(i.complete,a)()},c=function(t){e(this).delay(i.delay*t).animate({opacity:i.endOpacity,transform:"scale("+i.endScale+")"},i.duration,i.easing,l)};return i.isLegacyBrowser?a.show():a.addClass(i.className.init).show().css({opacity:i.startOpacity,transform:"scale("+i.startScale+")"}).each(c),e(this)},e.fn.popOut=function(t,n,o){var i=e.animationSettings(e.fn.popIn.settings,t,n,o),a={complete:function(){e(this).hide(),e.proxy(i.complete,this)()},startOpacity:i.endOpacity,endOpacity:0,startScale:i.endScale,endScale:i.startScale},r=e.extend(!0,{},i,a);e(this).popIn(r)},e.fn.popIn.settings={isLegacyBrowser:!1,className:{init:"init"},duration:450,easing:"easeOutExpo",delay:100,startOpacity:0,endOpacity:1,startScale:.7,endScale:1,eachComplete:function(){},complete:function(){}},e.fn.kenBurns=function(t,n,i){var a=e.animationSettings(e.fn.kenBurns.settings,t,n,i),r={randomPosition:function(e,t,n){var n=n!==o?n:t,i=Math.random()*(e+n-(e-t))+(e-t);return parseInt(i,10)},animate:function(){var t={},n={};t=a.useStartPosition?{x:parseInt(e(this).css("background-position-x"),10),y:parseInt(e(this).css("background-position-y"),10)}:{x:r.randomPosition(50,a.xRange),y:r.randomPosition(50,a.yRange)},n.x=t.x>50?r.randomPosition(t.x,a.xMaxTravelDistance,-a.xMinTravelDistance):r.randomPosition(t.x,-a.xMinTravelDistance,a.xMaxTravelDistance),n.y=t.y>50?r.randomPosition(t.y,a.yMaxTravelDistance,-a.yMinTravelDistance):r.randomPosition(t.y,-a.yMinTravelDistance,a.yMaxTravelDistance),e(this).css({backgroundPosition:t.x+"%",backgroundPositionY:t.y+"%"}).stop().animate({backgroundPosition:n.x+"%",backgroundPositionY:n.y+"%"},a.duration,a.easing,a.complete)}};return a.isLegacyBrowser||e(this).each(r.animate),e(this)},e.fn.kenBurns return d={channel:!1,width:{log:v.width(),userList:g.outerWidth()},initialize:function(){return Pusher===o&&d.error(a.errors.pusher),t===o||n===o?(d.error(a.errors.key),!1):a.endpoint.message||a.endpoint.authentication?(u=new Pusher(t),Pusher.channel_auth_endpoint=a.endpoint.authentication,d.channel=u.subscribe(n),d.channel.bind("pusher:subscription_succeeded",d.user.list.create),d.channel.bind("pusher:subscription_error",d.error),d.channel.bind("pusher:member_added",d.user.joined),d.channel.bind("pusher:member_removed",d.user.left),d.channel.bind("update_messages",d.message.receive),e.each(a.customEvents,function(e,t){d.channel.bind(e,t)}),e.fn.hoverClass!==o&&e.fn.downClass!==o&&(m.hoverClass().downClass(),p.hoverClass().downClass(),y.hoverClass().downClass()),p.on("click."+C,d.event.toggleUserList),m.on("click."+C,d.event.toggleExpand),b.on("keydown."+C,d.event.input.keydown).on("keyup."+C,d.event.input.keyup),y.on("mouseenter."+C,d.event.hover).on("mouseleave."+C,d.event.hover).on("click."+C,d.event.submit),v.animate({scrollTop:v.prop("scrollHeight")},400),f.data("module",d).addClass(w.loading),o):(d.error(a.errors.endpoint),!1)},refresh:function(){p.removeClass(w.active),d.width={log:v.width(),userList:g.outerWidth()},p.hasClass(w.active)&&d.user.list.hide(),f.data("module",d)},user:{updateCount:function(){a.userCount&&(T=f.data("users"),l=0,e.each(T,function(){l++}),h.html(a.templates.userCount(l)))},joined:function(t){T=f.data("users"),"anonymous"!=t.id&&T[t.id]===o&&(T[t.id]=t.info,a.randomColor&&t.info.color===o&&(t.info.color=a.templates.color(t.id)),k=a.templates.userList(t.info),t.info.isAdmin?e(k).prependTo(g).preview({type:"user",placement:"left"}):e(k).appendTo(g).preview({type:"user",placement:"left"}),e.fn.preview!==o&&g.children().last().preview({type:"user",placement:"left"}),a.partingMessages&&(v.append(a.templates.joined(t.info)),d.message.scroll.test()),d.user.updateCount())},left:function(e){T=f.data("users"),e!==o&&"anonymous"!==e.id&&(delete T[e.id],f.data("users",T),g.find("[data-id="+e.id+"]").remove(),a.partingMessages&&(v.append(a.templates.left(e.info)),d.message.scroll.test()),d.user.updateCount())},list:{create:function(t){T={},t.each(function(e){"anonymous"!==e.id&&"undefined"!==e.id&&(a.randomColor&&e.info.color===o&&(e.info.color=a.templates.color(e.id)),k=e.info.isAdmin?a.templates.userList(e.info)+k:k+a.templates.userList(e.info),T[e.id]=e.info)}),f.data("users",T).data("user",T[t.me.id]).removeClass(w.loading),g.html(k),e.fn.preview!==o&&g.children().preview({type:"user",placement:"left"}),d.user.updateCount(),e.proxy(a.onJoin,g.children())()},show:function(){v.animate({width:d.width.log-d.width.userList},{duration:a.speed,easing:a.easing,complete:d.message.scroll.move})},hide:function(){v.stop().animate({width:d.width.log},{duration:a.speed,easing:a.easing,complete:d.message.scroll.move})}}},message:{scroll:{test:function(){c=v.prop("scrollHeight")-v.height(),Math.abs(v.scrollTop()-c)<a.scrollArea&&d.message.scroll.move()},move:function(){c=v.prop("scrollHeight")-v.height(),v.scrollTop(c)}},send:function(t){d.utils.emptyString(t)||e.api({url:a.endpoint.message,method:"POST",data:{chat_message:{content:t,timestamp:(new Date).getTime()}}})},receive:function(e){s=e.data,T=f.data("users"),i=f.data("user"),T[s.userID]!==o&&(i===o||i.id!=s.userID)&&(s.user=T[s.userID],d.message.display(s))},display:function(t){v.append(a.templates.message(t)),d.message.scroll.test(),e.proxy(a.onMessage,v.children().last())()}},expand:function(){f.addClass(w.expand),e.proxy(a.onExpand,f)(),d.refresh()},contract:function(){f.removeClass(w.expand),e.proxy(a.onContract,f)(),d.refresh()},event:{input:{keydown:function(e){13==e.which&&y.addClass(w.down)},keyup:function(e){13==e.which&&(y.removeClass(w.down),d.event.submit())}},submit:function(){var e=b.val(),t=f.data("user");t===o||d.utils.emptyString(e)||(d.message.send(e),d.message.display({user:t,text:e}),d.message.scroll.move(),b.val(""))},toggleExpand:function(){f.hasClass(w.expand)?(m.removeClass(w.active),d.contract()):(m.addClass(w.active),d.expand())} break;case"left center":e="top center"}return e}},toggle:function(){p=e(this),i.debug("Toggling pop-up"),i.refresh(),0===v.size()&&i.create(),p.hasClass(C.visible)?i.hide():i.position()&&i.show()},position:function(n,o){var a,r,l=(e(t).width(),e(t).height(),p.outerWidth()),c=p.outerHeight(),u=v.outerWidth(),d=v.outerHeight(),f=s.inline?p.position():p.offset(),m=s.inline?h.outerWidth():g.outerWidth(),y=s.inline?h.outerHeight():g.outerHeight();switch(n=n||p.data(T.position)||s.position,o=o||p.data(T.arrowOffset)||s.arrowOffset,i.debug("Calculating offset for position",n),n){case"top left":a={top:"auto",bottom:y-f.top+s.distanceAway,left:f.left+o};break;case"top center":a={bottom:y-f.top+s.distanceAway,left:f.left+l/2-u/2+o,top:"auto",right:"auto"};break;case"top right":a={bottom:y-f.top+s.distanceAway,right:m-f.left-l-o,top:"auto",left:"auto"};break;case"left center":a={top:f.top+c/2-d/2,right:m-f.left+s.distanceAway-o,left:"auto",bottom:"auto"};break;case"right center":a={top:f.top+c/2-d/2,left:f.left+l+s.distanceAway+o,bottom:"auto",right:"auto"};break;case"bottom left":a={top:f.top+c+s.distanceAway,left:f.left+o,bottom:"auto",right:"auto"};break;case"bottom center":a={top:f.top+c+s.distanceAway,left:f.left+l/2-u/2+o,bottom:"auto",right:"auto"};break;case"bottom right":a={top:f.top+c+s.distanceAway,right:m-f.left-l-o,left:"auto",bottom:"auto"}}return e.extend(a,{width:v.width()+1}),v.removeAttr("style").removeClass("top right bottom left center").css(a).addClass(n).addClass(C.loading),r=i.get.offstagePosition(),r?(i.debug("Element is outside boundaries ",r),s.maxSearchDepth>b?(n=i.get.nextPosition(n),b++,i.debug("Trying new position: ",n),i.position(n)):(i.error(k.recursion),b=0,!1)):(i.debug("Position is on stage",n),b=0,!0)},show:function(){i.debug("Showing pop-up"),e(w.popup).filter(":visible").stop().fadeOut(200).prev(p).removeClass(C.visible),p.addClass(C.visible),v.removeClass(C.loading),"pop"==s.animation&&e.fn.popIn!==o?v.stop().popIn(s.duration,s.easing):v.stop().fadeIn(s.duration,s.easing),"click"==s.on&&s.clicktoClose&&(i.debug("Binding popup close event"),e(n).on("click."+N,i.gracefully.hide)),e.proxy(s.onShow,v)()},hide:function(){p.removeClass(C.visible),v.is(":visible")&&(i.debug("Hiding pop-up"),"pop"==s.animation&&e.fn.popOut!==o?v.stop().popOut(s.duration,s.easing,function(){v.hide()}):v.stop().fadeOut(s.duration,s.easing)),"click"==s.on&&s.clicktoClose&&e(n).off("click."+N),e.proxy(s.onHide,v)(),s.inline||i.remove()},gracefully:{hide:function(t){0===e(t.target).closest(w.popup).size()&&i.hide()}},setting:function(t,n){return n===o?s[t]:(e.isPlainObject(t)?e.extend(!0,s,t):s[t]=n,o)},internal:function(t,n){return n===o?i[t]:(e.isPlainObject(t)?e.extend(!0,i,t):i[t]=n,o)},debug:function(){s.debug&&(s.performance?i.performance.log(arguments):i.debug=Function.prototype.bind.call(console.info,console,s.moduleName+":"))},verbose:function(){s.verbose&&s.debug&&(s.performance?i.performance.log(arguments):i.verbose=Function.prototype.bind.call(console.info,console,s.moduleName+":"))},error:function(){i.error=Function.prototype.bind.call(console.log,console,s.moduleName+":")},performance:{log:function(e){var t,n,o;s.performance&&(t=(new Date).getTime(),o=c||t,n=t-o,c=t,u.push({Element:y,Name:e[0],Arguments:e[1]||"None","Execution Time":n}),clearTimeout(i.performance.timer),i.performance.timer=setTimeout(i.performance.display,100))},display:function(){var t=s.moduleName,n=(s.moduleName+": "+l+"("+r.size()+" elements)",0);l&&(t+=" Performance ("+l+")"),(console.group!==o||console.table!==o)&&u.length>0&&(console.groupCollapsed(t),console.table?(e.each(u,function(e,t){n+=t["Execution Time"]}),console.table(u)):e.each(u,function(e,t){n+=t["Execution Time"],console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.log("Total Execution Time:",n+"ms"),console.groupEnd(),u=[],c=!1)}},invoke:function(t,n,a){var r,s;return n=n||m,a=y||a,"string"==typeof t&&x!==o&&(t=t.split("."),r=t.length-1,e.each(t,function(t,n){return e.isPlainObject(x[n])&&t!=r?(x=x[n],!0):x[n]!==o?(s=x[n],!0):(i.error(k.method),!1)})),e.isFunction }(jQuery,window,document);
|