(function(){var GoogleMapsWidget,Sheet,SlideshowWidget,TwitterWidget,Widget,YouTubeWidget,n,_i,_len,_ref,_ref2;var __slice=Array.prototype.slice,__bind=function(fn,me){return function(){return fn.apply(me,arguments);};},_this=this,__hasProp=Object.prototype.hasOwnProperty,__extends=function(child,parent){for(var key in parent){if(__hasProp.call(parent,key))child[key]=parent[key];}function ctor(){this.constructor=child;}ctor.prototype=parent.prototype;child.prototype=new ctor;child.__super__=parent.prototype;return child;};this.XMLHTTPRequest=XMLHttpRequest;_ref=['cut','copy','paste'];for(_i=0,_len=_ref.length;_i<_len;_i++){n=_ref[_i];if((_ref2=$.attrFn)!=null)_ref2[n]=true;$.fn[n]=function(d,f){var _ref3;if(!f)_ref3=[d,null],f=_ref3[0],d=_ref3[1];if(arguments.length>0){return this.bind(n,d,f);}else{return this.trigger(n);}};}
$.extend({defer:function(callback){return this.timeout(0,callback);},timeout:function(time,callback){return setTimeout(callback,time);},interval:function(time,callback){return setInterval(callback,time);},clearInterval:function(id){return clearInterval(id);},capitalize:function(string){return string.charAt(0).toUpperCase()+string.slice(1);},propertyReader:function(object,name){return object.prototype.__defineGetter__(name,object.prototype['get'+this.capitalize(name)]);},propertyWriter:function(object,name){return object.prototype.__defineSetter__(name,object.prototype['set'+this.capitalize(name)]);},propertyAccessor:function(object,name){this.propertyReader(object,name);return this.propertyWriter(object,name);},xhr:function(options){var formData,key,value,xhr,_ref10,_ref11,_ref3,_ref4,_ref5,_ref6,_ref7,_ref8,_ref9;if((_ref3=options.data)==null)options.data={};if((_ref4=options.type)==null)options.type='get';if((_ref5=options.path)==null)options.path=location.pathname;if((_ref6=options.start)==null)options.start=function(){};if((_ref7=options.error)==null)options.error=function(){};if((_ref8=options.success)==null)options.success=function(){};if((_ref9=options.progress)==null)options.progress=function(){};if((_ref10=options.complete)==null)options.complete=function(){};formData=new FormData;_ref11=options.data;for(key in _ref11){value=_ref11[key];formData.append(key,value);}
xhr=new XMLHTTPRequest;$(xhr).bind('readystatechange',function(e){switch(e.target.readyState){case 4:options.complete(xhr);if($.isXHRSuccesful(xhr)){return typeof options.success==="function"?options.success(xhr):void 0;}else{return typeof options.failure==="function"?options.failure(xhr):void 0;}}});if(xhr.upload){$(xhr.upload).bind('progress',function(e){return options.progress(e.originalEvent.loaded/e.originalEvent.total);});}
options.start(xhr);xhr.open(options.type,options.path,true);xhr.setRequestHeader('Cache-Control','no-cache');xhr.setRequestHeader('X-Requested-With','XMLHttpRequest');return xhr.send(formData);},isXHRSuccesful:function(xhr){try{return!xhr.status&&location.protocol==="file:"||xhr.status>=200&&xhr.status<300||xhr.status===304||xhr.status===1223;}catch(e){}
return false;},cookie:function(name,value,options){var cookie,date,domain,expires,path,secure,_j,_len2,_ref3;if(options==null)options={};if((name!=null)&&(value!=null)){if(value===null||value===false){return $.cookie(name,'',{expires:-1});}
expires='';if(options.expires&&(typeof options.expires==='number'||options.expires.toUTCString)){if(typeof options.expires==='number'){date=new Date;date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires="; expires="+(date.toUTCString());}
path=options.path?"; path="+options.path:'';domain=options.domain?"; domain="+options.domain:'';secure=options.secure?"; secure":'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');return value;}else{if(document.cookie&&document.cookie!==''){_ref3=document.cookie.split(';');for(_j=0,_len2=_ref3.length;_j<_len2;_j++){cookie=_ref3[_j];if((cookie=$.trim(cookie)).substring(0,name.length+1)===(""+name+"=")){return decodeURIComponent(cookie.substring(name.length+1));}}}
return null;}},preloadImage:function(url,callback){var image;image=$(new Image);image.load(callback);image.attr({src:url});return image;},ensurePlaceholders:function(){if(!('placeholder'in $('<input/>')[0])){return $('[placeholder]').each(function(){var container,element;var _this=this;container=$('<div class="placeheld"/>');element=$('<div class="placeholder"/>');container.css({position:'relative',width:$(this).outerWidth(),height:$(this).outerHeight(),marginTop:$(this).css('marginTop'),marginLeft:$(this).css('marginLeft'),marginRight:$(this).css('marginRight'),marginBottom:$(this).css('marginBottom')});element.css({color:'gray',cursor:'text',top:0,left:0,right:0,bottom:0,position:'absolute',borderWidth:$(this).css('borderWidth')||0,borderStyle:'solid',borderColor:'transparent',fontSize:$(this).css('fontSize'),fontFamily:$(this).css('fontFamily'),lineHeight:$(this).css('lineHeight'),paddingTop:$(this).css('paddingTop'),paddingLeft:$(this).css('paddingLeft'),paddingRight:$(this).css('paddingRight'),paddingBottom:$(this).css('paddingBottom')});element.text($(this).attr('placeholder'));element.click(function(){return _this.focus();});element.appendTo(container);container.insertBefore($(this));container.append($(this));$(this).css({margin:0});$(this).removeAttr('placeholder');$(this).change(function(){return $.defer(function(){return element[_this.value.length>0?'hide':'show']();});});return $(this).keydown(function(){return $.defer(function(){return element[_this.value.length>0?'hide':'show']();});});});}},range:function(v){var s;if(v!=null){if(window.getSelection){s=window.getSelection();s.removeAllRanges();return s.addRange(v);}else if(document.selection){return v.select();}}else{if(window.getSelection){s=window.getSelection();if(s.rangeCount)return s.getRangeAt(0);}else if(document.selection){return document.selection.createRange();}}}});$.fn.extend({shake:function(duration,options){var callback;if(duration==null)duration=60;if(options==null)options={};if($.isFunction(duration)){callback=duration;duration=60;}
return this.effect('shake',options,duration,callback);},tagName:function(){return this[0].tagName.toLowerCase();},designMode:function(value){if(!(this[0]instanceof Document))return;if(value!=null){this[0].designMode=value===true?'on':'off';return this;}else{return this[0].designMode==='on';}},clearStyle:function(){var n,names,_j,_len2;names=1<=arguments.length?__slice.call(arguments,0):[];for(_j=0,_len2=names.length;_j<_len2;_j++){n=names[_j];this.css(n,'');}
return this;},execCommand:function(name,value){if(!(this[0]instanceof Document))return;return this[0].execCommand(name,false,value);},commandEnabled:function(name){if(!(this[0]instanceof Document))return;return this[0].queryCommandEnabled(name);},commandState:function(name){if(!(this[0]instanceof Document))return;return this[0].queryCommandState(name);},commandValue:function(name){if(!(this[0]instanceof Document))return;return this[0].queryCommandValue(name);},outerHTML:function(){return $('<div/>').append(this.clone()).html();},slidingMenu:function(klass,selector){var current,element,_ref3;if(selector==null)selector="> ."+klass;this.css({position:'relative'});current=this.find(selector);element=current.clone();current.removeClass(klass);element.css({position:'absolute',top:0,left:current!=null?(_ref3=current.position())!=null?_ref3.left:void 0:void 0});element.width(current.width());element.height(current.height());element.zIndex(current.zIndex()-1);element.empty().appendTo(this);this.children().click(function(){return current=$(this);});return this.children().hover(function(){return element.stop().animate({left:$(this).position().left,width:$(this).width()});},function(){return element.stop().animate({left:current.position().left,width:current.width()});});},refreshImage:function(){var src;if(!this.is('img[src]'))return false;src=this.attr('src');if(src.match(/\?.+&/)){if(typeof console!=="undefined"&&console!==null){if(typeof console.error==="function"){console.error("$.fn.refreshImage does not currently support images with specific query strings.");}}}
src=src.replace(/\?.+$/,'');return this.attr({src:src+'?'+Date.now()});},serialize:function(){var results;results=[];this.find(':input').each(function(){if(this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type))){return results.push(""+(encodeURIComponent(this.name))+"="+(encodeURIComponent($(this).val())));}});return results.join('&').replace(/%20/g,"+");}});$(function(){});;window.innerShiv=(function(){var d,r;return function(h,u){if(!d){d=document.createElement('div');r=document.createDocumentFragment();}var e=d.cloneNode(true);e.innerHTML=h.replace(/^\s\s*/,'').replace(/\s\s*$/,'');if(u===false)return e.childNodes;var f=r.cloneNode(true),i=e.childNodes.length;while(i--)f.appendChild(e.firstChild);return f}}());;this.S=function(e){if($.browser.msie)e=innerShiv(e,false);return $(e);};this.Lipsum={version:[0,0,103],isLoggedIn:false,siteSelector:'#outer-wrapper',currentLocale:'English',authenticationPath:'/lipsum/session',initialize:function(){if(navigator.userAgent.match(/WebKit/)){this.LoginIcon.initialize();if(this.isLoggedIn)this.initializeAdministration();}
this.initializeWidgets();return this;},initializeWidgets:function(){this.GoogleMapsWidget.initialize();this.SlideshowWidget.initialize();this.TwitterWidget.initialize();this.YouTubeWidget.initialize();return this;},enterAdministrationMode:function(){var _this=this;this.reloadCurrentPage(function(){_this.initializeAdministration();return _this.ToolbarContainer.present();});return this;},logIn:function(identifier,passphrase){var _this=this;$.ajax({url:this.authenticationPath,type:'post',data:{username:identifier,password:passphrase},cache:false,error:function(r){return _this.LoginSheet.shake();},success:function(r){return _this.LoginSheet.dismiss(function(){return _this.enterAdministrationMode();});}});return this;},reloadCurrentPage:function(callback){var curtain,makeCurtain;var _this=this;makeCurtain=function(){var curtain;curtain=$('<div class="lipsum-curtain"/>');curtain.css({background:'rgba(0,0,0,.5)'});return curtain;};curtain=makeCurtain();curtain.hide().prependTo($('body'));return curtain.fadeIn(300,function(){return $.ajax({type:'get',path:location.pathname,cache:false,success:function(r){var body,head,_ref3,_ref4;head=$((_ref3=r.match(/<head.*>([\s\S]*)<\/head>/i))!=null?_ref3[1]:void 0);body=$((_ref4=r.match(/<body.*>([\s\S]*)<\/body>/i))!=null?_ref4[1]:void 0);head.filter('script').each(function(){var source;if(!(source=$(this).attr('src')))return;if(source.match(/^\/extern\.js/))return;if(source.match(/^\/lipsum\.js/))return;if($("head script[src='"+source+"']").length===0){return $('head').append(this);}});$(':not(link, script)','head').replaceWith(head.filter(':not(link, script)'));$(_this.siteSelector,'body').replaceWith(body);_this.initializeWidgets();curtain.fadeOut(150,function(){return $(this).detach();});return typeof callback==="function"?callback():void 0;}});});}};$(function(){return $.defer(function(){return Lipsum.initialize();});});Lipsum.I18n={translations:{english:{SaveButtonCaption:"Save",CropButtonCaption:"Crop",LogInButtonCaption:"Log In",CancelButtonCaption:"Cancel",CreateButtonCaption:"Create",RecropButtonCaption:"Crop Existing",InsertButtonCaption:"Insert",ConfirmButtonCaption:"OK",SettingsButtonCaption:"Settings",PickFileButtonCaption:"Pick File",AuthenticationFieldsetCaption:"Enter your credentials to continue.",AuthenticationIdentifierInputLabel:"Name",AuthenticationPassphraseInputLabel:"Secret",HasUncommitedContentWarningText:"Unsaved content!",ChromeFrameNecessityExplanation:"Chrome Frame neccessary!",SitePreferencesGlobalSettingsFieldsetCaption:"System Configuration",SitePreferencesLipsumVersionLabel:"Lipsum Version",SitePreferencesContactEmailInputLabel:"Contact E-mail",SitePreferencesContactEmailInputPlaceholder:"contact@example.com",SitePreferencesTrafficStatisticsFieldsetCaption:"Traffic Statistics",SitePreferencesGoogleAnalyticsProfileIDInputLabel:"Google Analytics ID",SitePreferencesExternalCredentialsFieldsetCaption:"External Credentials",SitePreferencesFacebookInputLabel:"Facebook",SitePreferencesTwitterInputLabel:"Twitter",SitePreferencesLinkedInInputLabel:"LinkedIn",PagePropertiesPathFieldLabel:"Path",PagePropertiesTitleInputLabel:"Title",PagePropertiesTitleFormatEmDashInputLabel:"Before Dash",PagePropertiesTitleFormatColonInputLabel:"After Color",PagePropertiesKeywordsInputLabel:"Keyword",PagePropertiesDescriptionInputLabel:"Description"}}};this._=Lipsum.I18n.translations.english;this.Lipsum.Sheet=Sheet=(function(){Sheet.current=null;Sheet.present=function(content,options){var o;o=new this(content,options);o.present();return o;};Sheet.dismiss=function(callback){var _ref3;return(_ref3=this.current)!=null?_ref3.dismiss(callback):void 0;};Sheet.commit=function(callback){var _ref3;return(_ref3=this.current)!=null?_ref3.commit(callback):void 0;};Sheet.cancel=function(callback){var _ref3;return(_ref3=this.current)!=null?_ref3.cancel(callback):void 0;};Sheet.shake=function(callback){var _ref3;return(_ref3=this.current)!=null?_ref3.shake(callback):void 0;};Sheet.defaultOptions={transitionEasing:'easeInOutQuad',transitionDuration:333};Sheet.prototype.isVisible=false;Sheet.prototype.isShaking=false;function Sheet(content,options){var key,_base,_ref3;this.content=content;this.options=options!=null?options:{};this.keyUpHandler=__bind(this.keyUpHandler,this);for(key in Sheet.defaultOptions){if((_ref3=(_base=this.options)[key])==null){_base[key]=Sheet.defaultOptions[key];}}
this.element=$('<div class="lipsum-sheet"/>');this.element.wrapper=$('<div class="lipsum-sheet-wrapper"/>');this.element.content=$('<div class="lipsum-sheet-content"/>');this.element.curtain=$('<div class="lipsum-sheet-curtain"/>');this.element.content.append(this.content);this.element.wrapper.append(this.element);this.element.addClass(this.options["class"]);this.element.append(this.element.content);}
Sheet.prototype.attach=function(){this.element.curtain.prependTo($('body'));this.element.wrapper.prependTo($('body'));this.element.find('input').first().focus();return this;};Sheet.prototype.detach=function(){this.element.curtain.detach();this.element.wrapper.detach();return this;};Sheet.prototype.present=function(options){var _ref3;var _this=this;if(options==null)options={};$.fx.off=options.animated===false;Lipsum.Sheet.current=this;$(window).keyup(this.keyUpHandler);this.attach();if((_ref3=this.options.present)!=null)_ref3.call(this,this);this.element.find('button').mousedown(function(e){return _this.lastClickedButton=$(e.target);});this.element.wrapper.css({top:-this.element.outerHeight()-16});this.element.wrapper.animate({top:0},this.options.transitionDuration,this.options.transitionEasing,function(){_this.isVisible=true;return _this.element.find('input, textarea').first().focus();});return this;};Sheet.prototype.dismiss=function(callback){var _ref3;var _this=this;$.fx.off=false;Lipsum.Sheet.current=null;$(window).unbind('keyup',this.keyUpHandler);if((_ref3=this.lastClickedButton)!=null)_ref3.addClass('active');this.element.wrapper.css({top:0});this.element.wrapper.animate({top:-this.element.outerHeight()-16},this.options.transitionDuration,this.options.transitionEasing,function(){var _ref4;_this.isVisible=false;if((_ref4=_this.options.dismiss)!=null)_ref4.call(_this,_this);if(typeof callback==="function")callback();_this.release();return _this.detach();});return this;};Sheet.prototype.commit=function(){var _ref3;if(false!==((_ref3=this.options.commit)!=null?_ref3.call(this,this):void 0)){this.dismiss();}
return this;};Sheet.prototype.cancel=function(){var _ref3;if(false!==((_ref3=this.options.cancel)!=null?_ref3.call(this,this):void 0)){this.dismiss();}
return this;};Sheet.prototype.release=function(){this.element.find('button.active').removeClass('active');return this;};Sheet.prototype.shake=function(callback){var focus;var _this=this;if(this.isShaking)return;focus=this.element.find(':focus');this.isShaking=true;this.element.wrapper.shake(function(){_this.isShaking=false;focus.focus();if(typeof callback==="function")callback();return _this.release();});focus.focus();return this;};Sheet.prototype.animateTo=function(dimensions,callback){if(dimensions==null)dimensions={};this.element.stop();return this.element.animate({width:dimensions.width,height:dimensions.height},500,'easeOutSine',callback);};Sheet.prototype.freezeDimensions=function(){this.element.width(this.element.outerWidth());this.element.height(this.element.outerHeight());return this;};Sheet.prototype.unfreezeDimensions=function(){this.element.width(null);this.element.height(null);return this;};Sheet.prototype.replaceContentWith=function(element){var _this=this;this.element.content.fadeOut(function(){_this.element.content.empty();_this.element.content.append(element);return _this.element.content.fadeIn();});return this;};Sheet.prototype.enterProgressMode=function(labelText){this.progressLabelElement=$('<label/>');this.progressMeterElement=$('<progress/>');this.progressFieldsetElement=$('<fieldset class="progress"/>');this.progressLabelElement.text(labelText);if(labelText!=null){this.progressFieldsetElement.append(this.progressLabelElement);}
this.progressFieldsetElement.append(this.progressMeterElement);this.replaceContentWith(this.progressFieldsetElement);return this;};Sheet.prototype.reportProgressUpdate=function(newValue){if(!this.progressMeterElement)return;this.progressMeterElement.val(newValue);return this;};Sheet.prototype.leaveProgressMode=function(){var _this=this;this.progressFieldsetElement.fadeOut(function(){_this.progressFieldsetElement.detach();_this.element.content.children().fadeIn();_this.unfreezeDimensions();_this.progressLabelElement=null;_this.progressMeterElement=null;return _this.progressFieldsetElement=null;});return this;};Sheet.prototype.findElement=function(selector){return this.element.find(selector);};Sheet.prototype.valueOfField=function(name){return this.findElement("[name='"+name+"']").val();};Sheet.prototype.setValueOfField=function(name,value){return this.findElement("[name='"+name+"']").val(value);};Sheet.prototype.keyUpHandler=function(event){if($('textarea:focus').length){if(event.ctrlKey===true){event.stopPropagation();}else{return;}}
delete this.lastClickedButton;if(event.keyCode===27){return this.element.find('button.cancel').addClass('active').click();}else if(event.keyCode===13){return this.element.find('button.default').addClass('active').click();}};return Sheet;})();$(function(){var _ref3,_ref4,_ref5,_ref6;if($.browser.msie)return;return _this.Lipsum.LoginSheet=(function(func,args,ctor){ctor.prototype=func.prototype;var child=new ctor,result=func.apply(child,args);return typeof result==="object"?result:child;})(Lipsum.Sheet,__slice.call([(_ref6=$('<fieldset/>')).append.apply(_ref6,[S('<caption/>').text(_.AuthenticationFieldsetCaption),(_ref3=$('<div/>')).append.apply(_ref3,[$('<label/>').text(_.AuthenticationIdentifierInputLabel),$('<input value="" type="text" name="username" spellcheck="no"/>')]),(_ref4=$('<div/>')).append.apply(_ref4,[$('<label/>').text(_.AuthenticationPassphraseInputLabel),$('<input value="" type="password" name="password" spellcheck="no"/>')]),(_ref5=S('<section class="controls"/>')).append.apply(_ref5,[$('<button class="default"/>').text(_.LogInButtonCaption).click(function(){return Lipsum.Sheet.commit();}),$('<button class="cancel" />').text(_.CancelButtonCaption).click(function(){return Lipsum.LoginSheet.dismiss(function(){return Lipsum.LoginIcon.present();});})])])]).concat([{"class":'authentication prompt',commit:function(s){var password,username;username=s.valueOfField('username');password=s.valueOfField('password');if(username===''||password===''){s.shake();}else{Lipsum.logIn.apply(Lipsum,[username,password]);}
return false;}}]),function(){});});this.Lipsum.LoginIcon={initialize:function(){this.setup();if(!Lipsum.isLoggedIn)return this.present();},setup:function(){var _this=this;this.button=$('<button/>');this.button.text(_.LogInButtonCaption);this.button.click(function(){if($.browser.msie){return alert(_.ChromeFrameNecessityExplanation);}else{_this.dismiss();return setTimeout((function(){return Lipsum.LoginSheet.present();}),150);}});this.element=S('<section id="lipsum-authentication"/>');this.element.hide();this.element.append(this.button);this.insert();return this;},insert:function(){return this.element.prependTo($('body'));},detach:function(){this.element.detach();return this.button.removeClass('on');},present:function(){this.insert();this.element.fadeIn();return this;},dismiss:function(){var _this=this;this.button.addClass('on');this.element.fadeOut(function(){return _this.detach();});return this;}};this.Lipsum.Widget=Widget=(function(){function Widget(element){this.element=element;this.settingsSheet=typeof this.settingsSheet==="function"?this.settingsSheet():void 0;this.ID=this.element.data('id');this;}
Widget.prototype.setupElements=function(){if(Lipsum.isLoggedIn)return this.attachSettingsIcon();};Widget.prototype.settingsSheet=function(){return;};Widget.prototype.settingsPath=function(){return"/lipsum/widgets/"+this.ID;};Widget.prototype.commitSettings=function(successCallback){var _this=this;return $.ajax({url:this.settingsPath(),type:'put',data:this.settings,failure:function(){var _ref3;return(_ref3=_this.settingsSheet)!=null?_ref3.shake():void 0;},success:function(){var _ref3;if((_ref3=_this.settingsSheet)!=null)_ref3.dismiss();return typeof successCallback==="function"?successCallback():void 0;}});};Widget.prototype.attachSettingsIcon=function(){var _this=this;this.controlsContainer=S('<section class="lipsum-controls"/>');this.settingsIconButton=$('<button class="lipsum-settings"/>');this.settingsIconButton.click(function(){return _this.presentSettingsSheet();});this.controlsContainer.prepend(this.settingsIconButton);return this.controlsContainer.prependTo(this.element);};Widget.prototype.detachSettingsIcon=function(){return this.settingsIconButton.detach();};Widget.prototype.presentSettingsSheet=function(){var _ref3;return(_ref3=this.settingsSheet)!=null?_ref3.present():void 0;};return Widget;})();this.Lipsum.GoogleMapsWidget=GoogleMapsWidget=(function(){__extends(GoogleMapsWidget,Widget);GoogleMapsWidget.Selector='.map[data-location]';GoogleMapsWidget.initialize=function(){return $(this.Selector).each(function(e){return new GoogleMapsWidget($(this));});};function GoogleMapsWidget(element){this.element=element;this.location=this.element.data('location');this.setupElements();}
GoogleMapsWidget.prototype.setupElements=function(){};return GoogleMapsWidget;})();this.Lipsum.SlideshowWidget=SlideshowWidget=(function(){__extends(SlideshowWidget,Widget);SlideshowWidget.Selector='.slideshow';SlideshowWidget.initialize=function(){return $(this.Selector).each(function(e){return new SlideshowWidget($(this));});};SlideshowWidget.defaultSettings={cycleSpeed:6.5*1000,transitionType:'fade',transitionDuration:.5*1000,randomizeFirstIndex:true};function SlideshowWidget(element){var thumbnail;this.element=element;this.settings=SlideshowWidget.defaultSettings;this.settings.cycleSpeed=parseInt(this.element.data('cycleSpeed'))||this.settings.cycleSpeed;this.settings.transitionType=(this.element.data('transitionType'))||this.settings.transitionType;this.settings.transitionDuration=parseInt(this.element.data('transitionDuration'))||this.settings.transitionDuration;this.settings.randomizeFirstIndex=this.element.data('randomizeFirstIndex')!=null?{"true":true,"false":false}[this.element.data('randomizeFirstIndex')]:this.settings.randomizeFirstIndex;this.mainImage=this.element.find('.slideshow-main-image img');this.slideStage=this.element.find('.slideshow-stage');this.thumbnails=this.element.find('.slideshow-thumbnails').children();this.indicators=this.element.find('.slideshow-indicators').children();this.slides=this.slideStage.children().hide();this.targets=(function(){var _j,_len2,_ref3,_results;_ref3=this.thumbnails;_results=[];for(_j=0,_len2=_ref3.length;_j<_len2;_j++){thumbnail=_ref3[_j];_results.push($(thumbnail).data('target'));}
return _results;}).call(this);this.setupElements();this.currentImageIndex=this.settings.randomizeFirstIndex===true?Math.round(Math.random()*this.targets.length):-1;this.currentSlide=this.slides.first().show();this.refreshThumbnails();this.refreshIndicators();if(this.targets.length>1){$.fx.off=true;this.displayNextSlide();$.fx.off=false;}
this.beginCycling();SlideshowWidget.__super__.constructor.apply(this,arguments);}
SlideshowWidget.prototype.setupElements=function(){var indicator,thumbnail,_j,_k,_len2,_len3,_ref3,_ref4;var _this=this;SlideshowWidget.__super__.setupElements.apply(this,arguments);_ref3=this.thumbnails;for(_j=0,_len2=_ref3.length;_j<_len2;_j++){thumbnail=_ref3[_j];$(thumbnail).click(function(e){_this.ceaseCycling();return _this.displaySlide($(e.currentTarget).index());});}
_ref4=this.indicators;for(_k=0,_len3=_ref4.length;_k<_len3;_k++){indicator=_ref4[_k];$(indicator).click(function(e){_this.resetCycling();return _this.displaySlide($(e.currentTarget).index());});}
this.element.find('.slideshow-previous').click(function(){return _this.displayPreviousSlide();});this.element.find('.slideshow-next').click(function(){return _this.displayNextSlide();});this.mainImage.parent().width(this.mainImage.parent().width());this.mainImage.parent().height(this.mainImage.parent().height());this.mainImage.css({position:'absolute'});this.mainImage.width(this.mainImage.width());this.mainImage.height(this.mainImage.height());this.slideStage.children().css({position:'absolute'});this.slideStage.children().width(this.slideStage.width());return this.slideStage.children().height(this.slideStage.height());};SlideshowWidget.prototype.settingsSheet=function(){var _ref3,_ref4,_ref5,_ref6,_ref7,_ref8,_ref9;var _this=this;return(function(func,args,ctor){ctor.prototype=func.prototype;var child=new ctor,result=func.apply(child,args);return typeof result==="object"?result:child;})(Lipsum.Sheet,__slice.call([(_ref9=$('<fieldset/>')).append.apply(_ref9,[(_ref4=$('<div/>')).append.apply(_ref4,[$('<label/>').text("Transition"),(_ref3=$('<select name="type"/>')).append.apply(_ref3,[$('<option value="fade"/>').text("Fade"),$('<option value="slide"/>').text("Slide")])]),(_ref5=$('<div/>')).append.apply(_ref5,[$('<label/>').text("Delay (ms)"),$('<input type="text" name="delay""/>')]),(_ref6=$('<div/>')).append.apply(_ref6,[$('<label/>').text("Length (ms)"),$('<input type="text" name="duration""/>')]),(_ref7=$('<div/>')).append.apply(_ref7,[]),(_ref8=S('<section class="controls"/>')).append.apply(_ref8,[$('<button class="default"/>').text(_.ConfirmButtonCaption).click(function(){return Lipsum.Sheet.commit();}),$('<button class="cancel" />').text(_.CancelButtonCaption).click(function(){return Lipsum.Sheet.cancel();})])])]).concat([{"class":'slideshow widget settings',commit:function(sheet){_this.resetSettings({cycleSpeed:parseInt(sheet.element.find('[name="delay"]').val()),transitionType:sheet.element.find('[name="type"]').val(),transitionDuration:parseInt(sheet.element.find('[name="duration"]').val())});return _this.commitSettings();},present:function(sheet){sheet.element.find('[name=type]').val(_this.settings.transitionType);sheet.element.find('[name=duration]').val(_this.settings.transitionDuration);return sheet.element.find('[name=delay]').val(_this.settings.cycleSpeed);}}]),function(){});};SlideshowWidget.prototype.resetSettings=function(object){this.settings=object;return this.beginCycling();};SlideshowWidget.prototype.displaySlide=function(index){var nextSlide,target,thisSlide;var _this=this;if(this.targets.length>1){index%=this.targets.length;if(index===this.currentImageIndex)return;this.currentImageIndex=index;target=this.targets[index];this.displayImage(target);this.refreshThumbnails();}else if(this.slides.length>1){nextSlide=this.slides.eq(index%this.slides.length);if(nextSlide===this.currentSlide)return;thisSlide=this.currentSlide;this.currentSlide=nextSlide;nextSlide.stop().css({left:this.slideStage.width()});thisSlide.stop().css({left:0});nextSlide.show();$.timeout(800,function(){nextSlide.animate({left:0},_this.settings.transitionDuration,function(){return thisSlide.hide();});return thisSlide.animate({left:-_this.slideStage.width()},_this.settings.transitionDuration);});}
return this.refreshIndicators();};SlideshowWidget.prototype.displayImage=function(newPath){var newImage,oldImage;newImage=this.mainImage.clone().attr({src:newPath});oldImage=this.mainImage;this.mainImage=newImage;switch(this.settings.transitionType){case'fade':oldImage.after(newImage);newImage.hide().position(oldImage.position());newImage.fadeIn(this.settings.transitionDuration);return oldImage.fadeOut(this.settings.transitionDuration,function(){return oldImage.detach();});case'slide':oldImage.after(newImage);newImage.animate({left:0},this.settings.transitionDuration);return oldImage.animate({left:-oldImage.width()},this.settings.transitionDuration,function(){return oldImage.detach();});}};SlideshowWidget.prototype.refreshThumbnails=function(){var _this=this;return this.thumbnails.each(function(index,element){if(!$(element).hasClass('active')&&index===_this.currentImageIndex){$(element).addClass('active');}
if($(element).hasClass('active')&&index!==_this.currentImageIndex){return $(element).removeClass('active');}});};SlideshowWidget.prototype.refreshIndicators=function(){this.indicators.removeClass('current');if(this.targets.length>1){return this.indicators.eq(this.currentImageIndex).addClass('current');}else if(this.slides.length>1){return this.indicators.eq(this.currentSlide.index()).addClass('current');}};SlideshowWidget.prototype.displayNextSlide=function(){if(this.targets.length>1){return this.displaySlide(this.currentImageIndex+1);}else if(this.slides.length>1){return this.displaySlide(this.currentSlide.index()+1);}};SlideshowWidget.prototype.displayPreviousSlide=function(){if(this.targets.length>1){return this.displaySlide(this.currentImageIndex-1);}else if(this.slides.length>1){return this.displaySlide(this.currentSlide.index()-1);}};SlideshowWidget.prototype.beginCycling=function(){var _this=this;this.ceaseCycling();return this.intervalID=$.interval(this.settings.cycleSpeed,function(){return _this.displayNextSlide();});};SlideshowWidget.prototype.ceaseCycling=function(){clearInterval(this.intervalID);return this.intervalID=null;};SlideshowWidget.prototype.resetCycling=function(){this.ceaseCycling();return this.beginCycling();};return SlideshowWidget;})();Lipsum.NewSlideshowWidget=(function(){__extends(NewSlideshowWidget,Lipsum.Widget);function NewSlideshowWidget(){NewSlideshowWidget.__super__.constructor.apply(this,arguments);}
NewSlideshowWidget.prototype.settingsSheetConstructor=function(){var s,_ref3,_ref4,_ref5;return s=(function(func,args,ctor){ctor.prototype=func.prototype;var child=new ctor,result=func.apply(child,args);return typeof result==="object"?result:child;})(Lipsum.Sheet,[(_ref5=$('<fieldset/>')).append.apply(_ref5,[(_ref3=$('<div/>')).append.apply(_ref3,[]),(_ref4=$('<section class="controls"/>')).append.apply(_ref4,[])])],function(){});};return NewSlideshowWidget;})();this.Lipsum.TwitterWidget=TwitterWidget=(function(){__extends(TwitterWidget,Widget);TwitterWidget.Selector='.twitter';TwitterWidget.initialize=function(){return $(this.Selector).each(function(e){return new TwitterWidget($(this));});};TwitterWidget.defaultSettings={cycleSpeed:6.5*1000,numberOfTweets:5,includeRetweets:true};TwitterWidget.prototype.isCycling=false;TwitterWidget.prototype.currentTweet=null;function TwitterWidget(element){this.element=element;this.resetSettings({username:this.element.data('username'),numberOfTweets:this.element.data('numberOfTweets')});TwitterWidget.__super__.constructor.apply(this,arguments);}
TwitterWidget.prototype.setupElements=function(){TwitterWidget.__super__.setupElements.apply(this,arguments);return this.presentThrobber();};TwitterWidget.prototype.resetSettings=function(object){var _this=this;this.settings={};$.extend(this.settings,TwitterWidget.defaultSettings);$.extend(this.settings,object);this.setupElements();this.ceaseCycling();return $.defer(function(){return _this.fetchTweets();});};TwitterWidget.prototype.settingsSheet=function(){var _ref3,_ref4,_ref5,_ref6;var _this=this;return(function(func,args,ctor){ctor.prototype=func.prototype;var child=new ctor,result=func.apply(child,args);return typeof result==="object"?result:child;})(Lipsum.Sheet,__slice.call([(_ref6=$('<fieldset/>')).append.apply(_ref6,[(_ref3=$('<div/>')).append.apply(_ref3,[$('<label/>').text("Username"),$('<input type="text" name="username""/>')]),(_ref4=$('<div/>')).append.apply(_ref4,[$('<label/>').text("Amount"),$('<input type="text" name="amount""/>')]),(_ref5=S('<section class="controls"/>')).append.apply(_ref5,[$('<button class="default"/>').text(_.ConfirmButtonCaption).click(function(){return Lipsum.Sheet.commit();}),$('<button class="cancel" />').text(_.CancelButtonCaption).click(function(){return Lipsum.Sheet.cancel();})])])]).concat([{"class":'twitter widget settings',commit:function(sheet){_this.resetSettings({username:sheet.valueOfField('username'),numberOfTweets:parseInt(sheet.valueOfField('amount'))});return _this.commitSettings();},present:function(sheet){sheet.element.find('[name="username"]').val(_this.settings.username);return sheet.element.find('[name="amount"]').val(_this.settings.numberOfTweets);}}]),function(){});};TwitterWidget.prototype.presentThrobber=function(){this.element.find('.body').text('');return this.element.addClass('throbbing');};TwitterWidget.prototype.dismissThrobber=function(){return this.element.removeClass('throbbing');};TwitterWidget.prototype.fetchTweets=function(){var _this=this;this.fetchedTweets=[];$.ajax({url:"http://api.twitter.com/1/statuses/user_timeline.json?callback=?",data:{count:this.settings.numberOfTweets,include_rts:this.settings.includeRetweets,screen_name:this.settings.username},dataType:'json',error:function(response){return typeof console!=="undefined"&&console!==null?console.error(response):void 0;},success:function(results){var tweet,_j,_len2;for(_j=0,_len2=results.length;_j<_len2;_j++){tweet=results[_j];_this.fetchedTweets.push(tweet);}
if(!_this.isCycling){_this.beginCycling();_this.dismissThrobber();return _this.displayNextTweet();}}});return this;};TwitterWidget.prototype.displayTweet=function(tweet){if(!tweet)return;this.currentTweet=tweet;this.element.find('.user').text(tweet.user.screen_name);this.element.find('.body').html(tweet.text);this.element.find('.time').text($.timeago(new Date(tweet.created_at.replace('+','UTC+'))));return this;};TwitterWidget.prototype.displayNextTweet=function(){return this.displayTweet(this.fetchedTweets[1+$.inArray(this.currentTweet,this.fetchedTweets)]||this.fetchedTweets[0]);};TwitterWidget.prototype.beginCycling=function(){var _this=this;this.ceaseCycling();this.intervalID=$.interval(this.settings.cycleSpeed,function(){return _this.displayNextTweet();});this.isCycling=true;return this;};TwitterWidget.prototype.ceaseCycling=function(){$.clearInterval(this.intervalID);this.isCycling=false;return this;};return TwitterWidget;})();this.Lipsum.YouTubeWidget=YouTubeWidget=(function(){__extends(YouTubeWidget,Widget);YouTubeWidget.initialize=function(){};function YouTubeWidget(element){this.element=element;}
YouTubeWidget.prototype.setupElements=function(){};return YouTubeWidget;})();}).call(this);
