mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-23 11:17:26 +02:00
3 lines
No EOL
40 KiB
JavaScript
3 lines
No EOL
40 KiB
JavaScript
angular.module("rallly",["ui.router","ngResource","btford.modal","ngTagsInput","ngAnimate"]).config(["$stateProvider","$urlRouterProvider","$locationProvider",function(e,n,t){t.html5Mode(!0),n.otherwise("/notfound"),e.state("index",{url:"/",templateUrl:"templates/home.html",controller:"HomeCtrl"}).state("newevent",{url:"/new",templateUrl:"templates/newEvent/layout.html",controller:"NewEventCtrl"}).state("newevent.general",{templateUrl:"templates/newEvent/general.html"}).state("newevent.datetime",{templateUrl:"templates/newEvent/datetime.html"}).state("newevent.invite",{templateUrl:"templates/newEvent/invite.html"}).state("newevent.success",{templateUrl:"templates/newEvent/success.html"}).state("about",{url:"/about",templateUrl:"templates/about.html",controller:"AboutCtrl"}).state("notfound",{url:"/notfound",templateUrl:"templates/notfound.html"}).state("event",{url:"/:id",templateUrl:"templates/event.html",controller:"EventCtrl"}).state("editevent",{url:"/:id/edit",templateUrl:"templates/editevent.html",controller:"EditEventCtrl"}).state("verifyevent",{url:"/verify/:id/code/:code",controller:"VerificationCtrl"}).state("deleteevent",{url:"/delete/:id/code/:code",controller:"DeletionCtrl"})}]).factory("Event",["$resource",function(e){return e("/api/event/:id",{id:"@_id"},{update:{method:"PUT"},verify:{method:"GET",url:"/api/event/:id/code/:code"},destroy:{method:"DELETE",url:"/api/event/:id/code/:code"}})}]).factory("Participant",["$resource",function(e){return e("/api/event/:id/participant/:pid",{id:"@_id"},{update:{method:"PUT"}})}]).factory("Comment",["$resource",function(e){return e("/api/event/:id/comment/:cid",{id:"@_id"},{update:{method:"PUT"}})}]).factory("Title",function(){return{set:function(e){document.title=e}}}),angular.module("rallly").run(["$templateCache",function(e){e.put("templates/about.html",'<div class="box">\n <div class="box-title">Frequently Asked Questions</div>\n <div class="box-description">\n Want to find out more about Rallly? Check out the FAQs below.\n </div> <h2>What is Rallly?</h2>\n <p>\n Rallly is a collaborative scheduling service that makes deciding on a date fast and easy. In other words, Rallly helps you and your friends decide on a date to host an event.\n </p>\n <h2>Why is it called Rallly?</h2>\n <p>\n The name is derived from the proper spelling of the word, “rally”. The Webster dictionary defines rally as, “to muster for a common purpose” which accurately describes the goal of this service. The inproper spelling can be attributed to the difficulty of finding short and meaningful domain names.\n </p>\n <h2>Who made this?</h2>\n <p>\n Rallly was created by <a href="http://lukevella.com">Luke Vella</a>.\n </p>\n</div>\n'),e.put("templates/confirmmodal.html",'<div class="rl-modal-overlay" ng-click="modal.cancel()"></div>\n\n<div class="rl-modal">\n <div class="rl-modal-title">{{modal.title}}</div>\n <div class="rl-modal-message">\n {{modal.message}}\n </div>\n <div class="rl-modal-actions">\n <button type="button" ng-click="modal.confirm()" ng-show="modal.confirm" class="btn" ng-class="{danger : modal.isDestructive}">{{modal.confirmText}}</button>\n <button type="button" ng-click="modal.cancel()" class="btn">{{modal.cancelText}}</button>\n </div>\n</div>\n'),e.put("templates/editevent.html",'<div ng-show="event._id">\n <div class="box">\n\n <div class="box-title">Edit Event</div>\n <div class="box-description">\n You can makes changes to your existing event by changing the fields in the form below.\n </div>\n\n <form novalidate name="form" ng-submit="submit()">\n\n <section class="box-section" user-form form="form" event="event">\n\n </section>\n\n <section class="box-section" event-form form="form" event="event">\n\n </section>\n <section class="box-section" date-form form="form" event="event">\n\n </section>\n\n <section class="box-section" settings-form form="form" event="event">\n\n </section>\n\n <div class="box-controls box-bottom-sticky">\n <button type="submit" ng-show="didChange()" class="btn btn-primary" ng-class="{disabled : !didChange()}">\n Save Changes\n </button>\n <button type="button" ng-click="undoChanges()" class="btn" ng-show="didChange()">Undo Changes</button>\n <a href="/{{event._id}}" class="btn" ng-hide="didChange()">Done</a>\n </div>\n\n </form>\n\n </div>\n\n</div>\n'),e.put("templates/event.html",'<div ng-show="event._id && !event.isDeleted">\n <div class="box ">\n <div class="event-header">\n <div class="details">\n <div class="title">\n {{event.title}}\n <span class="title-label danger" ng-show="event.isClosed">Poll Closed</span>\n <span class="title-label success" ng-hide="event.isClosed">Poll Open</span>\n </div>\n <div class="subtitle">\n Created by <a href="mailto:{{event.creator.email}}">{{event.creator.name}}</a> • {{event.created | elapsed}}\n </div>\n </div>\n <div class="actions">\n <button class="btn" ng-click="editEvent()">Edit Event</button>\n </div>\n </div>\n <div class="event-description box-side-sticky" ng-if="event.description">{{event.description}}</div>\n <div class="event-location" ng-if="event.location">\n Location:\n <a href="http://maps.google.com?q={{event.location}}" target="_blank">{{event.location}}</a>\n </div>\n\n <div poll event="event" class="poll">\n </div>\n </div>\n\n <div class="box" ng-hide="event.comments.length == 0 && event.isClosed">\n <div class="box-title">\n Discussion\n </div>\n <div class="box-description">\n You can discuss the event with your friends by leaving a comment below.\n </div>\n <div discussion event="event">\n\n </div>\n </div>\n</div>\n'),e.put("templates/home.html",'<div class="page-placeholder">\n <div class="image">\n <img src="/images/mark_large.png" width="67" />\n </div>\n <div class="title">\n Schedule an Event\n </div>\n <div class="content">\n Want to host an event but can’t decide on a date? Click on the button below to start!\n </div>\n <button ng-click="newEvent()" class="btn">Schedule New Event</button>\n</div>\n'),e.put("templates/notfound.html","<h1>Error 404</h1>\n<h2>Not Found</h2>\n"),e.put("templates/notification.html",'<div class="notification {{notification.type}}" ng-click="notification.close()">\n <div class="title">\n {{notification.title}}\n </div>\n <div class="message">\n {{notification.message}}\n </div>\n</div>\n'),e.put("templates/directives/datePicker.html",'<div class="date-picker">\n <div class="wrapper">\n <div class="date-picker-head">\n <a href="#" class="arrow" ng-click="prevMonth()">❮</a>\n <span class="title">\n <span class="title-text">{{title}}</span>\n </span>\n <a href="#" class="arrow" ng-click="nextMonth()">❯</a>\n </div>\n <div class="dow">\n <div class="day">\n Sun\n </div>\n <div class="day">\n Mon\n </div>\n <div class="day">\n Tue\n </div>\n <div class="day">\n Wed\n </div>\n <div class="day">\n Thu\n </div>\n <div class="day">\n Fri\n </div>\n <div class="day">\n Sat\n </div>\n </div>\n <div class="values">\n <div ng-repeat="day in days" class="value" ng-class="{ outside : day.isOutsideMonth, today : day.isToday, active : isActive(day.date) }" ng-click="selectDay(day)">\n {{day.date | date : \'d\' }}\n </div>\n </div>\n </div>\n</div>\n'),e.put("templates/directives/discussion.html",'<ul class="comment-thread" ng-show="event.comments.length">\n <li ng-repeat="comment in event.comments" class="comment">\n <div class="avatar-section">\n <img src="/images/avatar.png" />\n </div>\n <div class="comment-section">\n <a href="#" class="comment-delete" ng-click="deleteComment(comment)">×</a>\n <div class="meta">\n <span class="name">{{comment.author.name}}</span>\n <span class="time">{{comment.created | elapsed}}</span>\n </div>\n <div class="content">{{comment.content}}</div>\n </div>\n </li>\n</ul>\n<form novalidate ng-submit="postComment()" name="commentForm" class="comment-form">\n <div class="avatar-section">\n <img src="/images/avatar.png" />\n </div>\n <div class="input-section form-group">\n <div class="content-section">\n <textarea class="form-control" required ng-model="comment.content" placeholder="Write a comment..."></textarea>\n </div>\n <div class="name-section">\n <div class="name-container">\n <input type="text" class="form-control" required placeholder="Your Name" ng-model="comment.author.name" />\n <button type="submit" class="btn">Post Comment</button>\n <span class="form-error" ng-show="commentForm.$submitted && commentForm.$error">\n <img src="/images/error.png" width="14" /> Make sure you fill in all the fields.\n </span>\n </div>\n </div>\n </div>\n</form>\n'),e.put("templates/directives/poll.html",'<div class="poll-header">\n <div class="header participants-header">\n {{event.participants.length}} participants\n </div>\n <div class="header date-header" ng-repeat="d in event.dates">\n <div class="daticon">\n <div class="dow">\n {{d | date: \'EEE\'}}\n </div>\n <div class="day">\n {{d | date: \'d\'}}\n </div>\n <div class="month">\n {{d | date : \'MMM\'}}\n </div>\n <span class="count" ng-show="selectedDate($index)" ng-class={top:isTopDate($index)}>{{selectedDate($index)}}</span>\n </div>\n </div>\n <div class="header actions-header">\n\n </div>\n</div>\n<div class="poll-body">\n <div class="poll-entry" ng-repeat="participant in event.participants">\n <form novalidate ng-submit="update(participant); editMode = false">\n <div class="cell name-cell">\n <span class="avatar style-{{$index + 1}}">\n <img src="/images/user.png" width="11" />\n </span>\n <input required autocomplete="off" type="text" class="form-control" ng-model="participant.name" ng-show="editMode" value="participant.name"/>\n <span ng-hide="editMode" class="name editable" ng-click="editMode = true && !event.isClosed; edit(participant)">{{participant.name}}</span>\n </div>\n <div class="cell vote-cell" ng-repeat="date in event.dates">\n <img src="/images/tick@2x.png" width="16" ng-hide="editMode" ng-if="participant.votes[$index]" />\n <img src="/images/nope@2x.png" width="8" ng-hide="editMode" ng-if="!participant.votes[$index]" />\n <input ng-model="participant.votes[$index]" ng-show="editMode" ng-false-value="false" type="checkbox" />\n <div class="overlay" ng-show="editMode" ng-click="participant.votes[$index] = !participant.votes[$index]"></div>\n </div>\n <div class="cell action-cell" ng-hide="event.isClosed">\n <button type="button" ng-hide="editMode" ng-click="editMode = true; edit(participant)" class="btn hover">Edit</button>\n <button type="button" ng-hide="editMode" ng-click="delete(participant)" class="btn danger hover">Delete</button>\n <button type="submit" ng-show="editMode" class="btn">Save</button>\n <button type="button" ng-show="editMode" ng-click="editMode = false; cancel($index)" class="btn">Cancel</button>\n </div>\n </form>\n </div>\n <div class="poll-example" ng-class="{hidden : event.participants.length > 0}">\n <div class="poll-entry" ng-repeat="example in examples">\n <div class="cell name-cell">\n <span class="avatar style-{{$index + 1}}">\n <img src="/images/user.png" width="11" />\n </span>\n <span class="name">{{example.name}}</span>\n </div>\n <div class="cell vote-cell" ng-repeat="date in event.dates">\n <img src="/images/tick@2x.png" width="16" ng-if="example.votes[$index]" />\n <img src="/images/nope@2x.png" width="8" ng-if="!example.votes[$index]" />\n </div>\n <div class="cell action-cell">\n\n </div>\n </div>\n <div class="overlay">\n <div class="overlay-text">\n Fill in the form below to get started\n </div>\n </div>\n </div>\n <div ng-hide="event.isClosed" class="poll-entry highlight">\n <form novalidate name="formnew" ng-submit="save()">\n <div class="cell name-cell">\n <span class="avatar style-{{participant.style}}">\n <img src="/images/user.png" width="11" />\n </span>\n <input autocomplete="off" name="username" type="text" class="form-control" placeholder="Your name..." ng-model="participant.name" required value="participant.name"/>\n </div>\n <div class="cell vote-cell" ng-repeat="date in event.dates">\n <input ng-model="participant.votes[$index]" ng-false-value="false" type="checkbox" />\n <div class="overlay" ng-click="participant.votes[$index] = !participant.votes[$index]"></div>\n </div>\n <div class="cell action-cell">\n <button type="submit" ng-class="{ \'animated shake\' : formnew.$submitted && formnew.$invalid }" class="btn">Save</button>\n </div>\n </form>\n </div>\n</div>\n'),e.put("templates/directives/timePicker.html",'<div class="time-picker">\n <div class="time-picker-col">\n <div class="daticon">\n <div class="dow">\n {{date | date: \'EEE\'}}\n </div>\n <div class="day">\n {{date | date: \'d\'}}\n </div>\n <div class="month">\n {{date | date : \'MMM\'}}\n </div>\n <!-- <span class="delete" ng-click="datepicker.unsetDate(date)"></span> -->\n </div>\n </div>\n <div class="time-picker-col" ng-repeat="time in date.times track by $index">\n <input type="text" class="time-picker-input" time-picker ng-model="time" ng-model-options="{ updateOn: \'blur\' }" />\n </div>\n</div>\n'),e.put("templates/form/dateForm.html",'<div class="section-details">\n <div class="section-title">Choose Dates</div>\n <ul class="daticon-list">\n <li ng-repeat="d in event.dates">\n <div class="daticon">\n <div class="dow">\n {{d | date: \'EEE\'}}\n </div>\n <div class="day">\n {{d | date: \'d\'}}\n </div>\n <div class="month">\n {{d | date : \'MMM\'}}\n </div>\n <span class="delete" ng-click="datepicker.removeDate(d)"></span>\n </div>\n </li>\n </ul>\n</div>\n<div class="section-main">\n <div class="form-row">\n <div class="form-group">\n <label for="email">Calendar</label>\n <span class="form-error" ng-show="form.$submitted && form.datepicker.$error.required">\n <img src="/images/error.png" width="14" /> You need to select a few dates\n </span>\n <div datepicker required name="datepicker" control="datepicker" ng-model="event.dates">\n\n </div>\n </div>\n </div>\n</div>\n'),e.put("templates/form/eventForm.html",'<div class="section-details">\n <div class="section-title">Event Details</div>\n</div>\n<div class="section-main">\n <div class="form-row">\n <div class="form-col">\n <div class="form-group">\n <label for="title">Title</label>\n <span class="form-error" ng-show="(form.title.$touched || form.$submitted) && errors.title">\n <img src="/images/error.png" width="14" /> {{errors.title}}\n </span>\n <input id="title" name="title" ng-maxlength="30" required ng-model="event.title" type="text" placeholder="Monthly Meetup..." class="form-control extend"/>\n </div>\n </div>\n <div class="form-col">\n <div class="form-group optional">\n <label for="location">Location</label>\n <span class="form-error" ng-show="(form.location.$touched || form.$submitted) && errors.location">\n <img src="/images/error.png" width="14" /> {{errors.location}}\n </span>\n <input id="location" name="location" ng-model="event.location" ng-maxlength="50" type="text" placeholder="Rick\'s Cafe..." class="form-control extend"/>\n </div>\n </div>\n </div>\n <div class="form-row">\n <div class="form-group optional">\n <label for="description" >Description</label>\n <textarea id="description" name="description" ng-model="event.description" placeholder="Enter Description..." class="form-control extend"></textarea>\n </div>\n </div>\n</div>\n'),e.put("templates/form/participantsForm.html",'<div class="section-details">\n <div class="section-title">Invite Participants</div>\n</div>\n<div class="section-main">\n <div class="form-row">\n <div class="form-group optional">\n <label>Participant\'s Emails</label>\n <tags-input max-length="50" allowed-tags-pattern="{{emailRegex}}" display-property="email" ng-model="event.emails" placeholder="Add an Email" type="email" autocomplete="off"></tags-input>\n <input type="hidden" name="shouldCreate" value="true" />\n\n </div>\n </div>\n</div>\n'),e.put("templates/form/settingsForm.html",'<div class="section-details">\n <div class="section-title">Settings</div>\n</div>\n<div class="section-main">\n <div class="switch-row">\n <div class="switch-details">\n <div class="title">\n Poll Status\n </div>\n <div class="description">\n Let people vote on the poll.\n </div>\n </div>\n <div class="switch">\n <div class="switch-value">\n {{event.isClosed ? \'Closed\' : \'Open\' }}\n </div>\n <div switch-toggle ng-model="event.isClosed" invert>\n </div>\n </div>\n </div>\n <div class="switch-row">\n <div class="switch-details">\n <div class="title">\n Notifications\n </div>\n <div class="description">\n Send email notifications to the creator of this event.\n </div>\n </div>\n <div class="switch">\n <div class="switch-value">\n {{event.creator.allowNotifications ? \'Enabled\' : \'Disabled\' }}\n </div>\n <div switch-toggle ng-model="event.creator.allowNotifications">\n </div>\n </div>\n </div>\n <div class="switch-row">\n <div class="switch-details">\n <div class="title">\n Delete Event\n </div>\n <div class="description">\n Once you delete an event it will no longer be accessible.\n </div>\n </div>\n <div class="switch">\n <button type="button" ng-click="deleteEvent()" class="btn" ng-class="{danger : !deleteRequestSent, disabled : deleteRequestSent}">{{deleteRequestSent ? \'Request Sent\' : \'Delete Event\' }}</button>\n </div>\n </div>\n</div>\n</section>\n'),e.put("templates/form/timeForm.html",'<div class="section-details">\n <div class="section-title">Choose Times</div>\n</div>\n<div class="section-main">\n <table class="time-form">\n <thead>\n <tr>\n <th>\n\n </th>\n <th>\n Time 1\n </th>\n <th>\n Time 2\n </th>\n <th>\n Time 3\n </th>\n </tr>\n </thead>\n <tbody>\n <tr ng-repeat="d in event.dates">\n <td>\n <div class="daticon">\n <div class="dow">\n {{d.date | date: \'EEE\'}}\n </div>\n <div class="day">\n {{d.date | date: \'d\'}}\n </div>\n <div class="month">\n {{d.date | date : \'MMM\'}}\n </div>\n <span class="delete" ng-click="unsetDate(d.date)"></span>\n </div>\n </td>\n <td ng-repeat="time in [1,2,3] track by $index">\n <input type="text" time-picker ng-model-options="{ updateOn: \'blur\' }" ng-model="d.times[$index]" class="time-picker-input" />\n </td>\n </tr>\n </tbody>\n </table>\n</div>\n'),e.put("templates/form/userForm.html",'<div class="section-details">\n <div class="section-title">Your Details</div>\n</div>\n<div class="section-main">\n <div class="form-row">\n <div class="form-col">\n <div class="form-group">\n <label for="name">Name</label>\n <span class="form-error" ng-show="(form.name.$touched || form.$submitted) && errors.name">\n <img src="/images/error.png" width="14" /> {{errors.name}}\n </span>\n <input id="name" name="name" ng-maxlength="30" required ng-model="event.creator.name" type="text" placeholder="John Doe..." class="form-control extend"/>\n </div>\n </div>\n <div class="form-col">\n <div class="form-group">\n <label for="email">Email</label>\n <span class="form-error" ng-show="(form.email.$touched || form.$submitted) && errors.email">\n <img src="/images/error.png" width="14" /> {{errors.email}}\n </span>\n <input type="email" id="email" name="email" ng-pattern="emailRegex" required ng-model="event.creator.email" placeholder="john.doe@email.com..." class="form-control extend"/>\n </div>\n </div>\n </div>\n</div>\n'),e.put("templates/newEvent/datetime.html",'<section class="box-section" date-form form="form" event="event">\n\n</section>\n\n<div class="box-controls box-bottom-sticky">\n <button type="button" class="btn" ng-click="prevPage()">Previous</button>\n <button type="submit" class="btn">Next</button>\n</div>\n'),e.put("templates/newEvent/general.html",'<section class="box-section" user-form form="form" event="event">\n\n</section>\n\n<section class="box-section" event-form form="form" event="event">\n\n</section>\n\n<div class="box-controls box-bottom-sticky">\n <button type="submit" class="btn">Next Step</button>\n</div>\n'),e.put("templates/newEvent/invite.html",'<section class="box-section">\n <div class="section-details">\n <div class="section-title">Summary</div>\n </div>\n <div class="section-main">\n <div class="summary">\n <div class="summary-pair">\n <div class="key">\n Your Name\n </div>\n <div class="value">\n {{event.creator.name}}\n </div>\n </div>\n <div class="summary-pair">\n <div class="key">\n Email\n </div>\n <div class="value">\n {{event.creator.email}}\n </div>\n </div>\n <div class="summary-pair">\n <div class="key">\n Title\n </div>\n <div class="value">\n {{event.title}}\n </div>\n </div>\n <div ng-if="event.location" class="summary-pair">\n <div class="key">\n Location\n </div>\n <div class="value">\n {{event.location}}\n </div>\n </div>\n <div ng-if="event.description" class="summary-pair extend">\n <div class="key">\n Description\n </div>\n <div class="value wrap">{{event.description}}</div>\n </div>\n <div class="summary-pair extend">\n <div class="key">\n Dates\n </div>\n <div class="value">\n <ul class="daticon-list">\n <li ng-repeat="d in event.dates">\n <div class="daticon">\n <div class="dow">\n {{d | date: \'EEE\'}}\n </div>\n <div class="day">\n {{d | date: \'d\'}}\n </div>\n <div class="month">\n {{d | date : \'MMM\'}}\n </div>\n </div>\n </li>\n </ul>\n </div>\n </div>\n </div>\n </div>\n</section>\n<section class="box-section" participants-form form="form" event="event">\n\n</section>\n\n<div class="box-controls box-bottom-sticky">\n <button type="button" class="btn" ng-click="prevPage()">Previous</button>\n <button type="submit" class="btn">Create</button>\n</div>\n'),e.put("templates/newEvent/layout.html",'<div class="box">\n\n <div class="box-title">Schedule a New Event</div>\n <div class="box-description">\n Fill in the form below to create your event and share it with your friends and colleagues.\n </div>\n <ol class="newevent-steps">\n <li class="step" ng-class="{ active : page == 1, complete : page > 1 }">\n General Details\n </li>\n <li class="step" ng-class="{ active : page == 2, complete : page > 2 }">\n Dates & Times\n </li>\n <li class="step" ng-class="{ active : page == 3, complete : page > 3 }">\n Create & Send\n </li>\n </ol>\n <form novalidate autocomplete="off" name="form" ng-submit="submit()">\n <div ui-view>\n\n </div>\n </form>\n</div>\n'),e.put("templates/newEvent/success.html",'<div class="box-message">\n <div class="main-image">\n <img src="/images/success_large.png" width="100" />\n </div>\n <div class="title">Event Created</div>\n <div class="content">\n Your event has been created successfully! You should receive an email shortly with instructions to verify your email address.\n </div>\n <div class="mini-divider">\n </div>\n <div class="form-group">\n <input type="text" class="form-control" disabled="true" value="{{eventUrl}}" />\n <a href="{{eventUrl}}" class="btn form-btn">GO</a>\n </div>\n</div>\n')}]),angular.module("rallly").controller("AboutCtrl",["Title",function(e){e.set("About Rallly")}]),angular.module("rallly").controller("AccountCtrl",["$scope","ConfirmModal",function(e){e.showNotice=function(){}}]),angular.module("rallly").controller("DeletionCtrl",["$state","Notification","Event",function(e,n,t){t.destroy({id:e.params.id,code:e.params.code},function(){new n({title:"Event deleted",message:"This event has been deleted",type:"success",timeout:5e3})},function(){new n({title:"Deletion Failed",message:"The event could not be deleted. Make sure that it exists and that the url is correct",type:"error"})}),e.go("event",{id:e.params.id})}]),angular.module("rallly").controller("EditEventCtrl",["$scope","$http","$state","$timeout","Event","ConfirmModal","Notification","Title",function(e,n,t,i,a,s,o,l){var d=t.params.id;e.event=a.get({id:d},function(){l.set("Edit: "+e.event.title),e.master=angular.copy(e.event)},function(){t.go("notfound")}),e.undoChanges=function(){e.event=angular.copy(e.master)},e.didChange=function(){return JSON.stringify(e.master)!=JSON.stringify(e.event)},e.didChangeDates=function(){return JSON.stringify(e.master.dates)!=JSON.stringify(e.event.dates)},e.submit=function(){if(e.form.$valid)if(e.didChangeDates()){new s({title:"Hold up!",message:"Changing the dates will reset all entries by the participants. Are you sure you want to do that?",confirmText:"Yes, I'm sure",isDestructive:!0,confirm:function(){e.event.participants=[],r()}})}else r();else{new o({title:"Not so fast",message:"Make sure you fill in all the required fields and try again.",type:"error"})}};var r=function(){a.update({id:d},e.event,function(){new o({title:"Changes Saved",message:"Your changes have been saved successfully.",type:"success"});e.master=angular.copy(e.event)})}}]),angular.module("rallly").controller("EventCtrl",["$scope","$http","$state","Title","Event","ConfirmModal",function(e,n,t,i,a,s){var o=t.params.id;e.event=a.get({id:o},function(){i.set(e.event.title),e.eventUrl=t.href("event",{id:e.event._id},{absolute:!0})},function(){t.go("notfound")}),e.openEvent=function(){e.event.isClosed=!1,a.update({id:o},e.event,function(){new s({title:"Event Open",message:"People can vote and comment on this event.",cancelText:"OK"})})},e.closeEvent=function(){e.event.isClosed=!0,a.update({id:o},e.event,function(){new s({title:"Event Closed",message:"People can no longer vote or comment on this event.",cancelText:"OK"})})},e.editEvent=function(){t.go("editevent",{id:e.event._id})}}]),angular.module("rallly").controller("HomeCtrl",["$scope","$state","Title",function(e,n,t){t.set("Rallly - Collaborative Scheduling"),e.newEvent=function(){n.go("newevent")}}]),angular.module("rallly").controller("NavigationCtrl",["$scope","$location",function(e,n){e.isActive=function(e){return n.path()==e?!0:!1}}]),angular.module("rallly").controller("NewEventCtrl",["$scope","$http","$state","Event","ConfirmModal","Notification",function(e,n,t,i,a){e.title="Schedule a New Event",e.description="Fill in the form below to create your event and share it with your friends and colleagues.",e.event={};var s=["newevent.general","newevent.datetime","newevent.invite"];e.page=1;var o=function(n){e.page=n,t.go(s[n-1])};o(e.page),e.submit=function(){e.form.$valid&&e.page==s.length?n.post("/api/event",e.event).success(function(n){e.event=n,e.eventUrl=t.href("event",{id:e.event._id},{absolute:!0}),e.page++,t.go("newevent.success")}).error(function(){new a({title:"Uh oh!",message:"There was an error creating your event. Please try again later.",cancelText:"OK"})}):e.form.$valid&&(e.form.$setPristine(),e.nextPage())
|
||
},e.nextPage=function(){o(e.page+1)},e.prevPage=function(){o(e.page-1)}}]),angular.module("rallly").controller("VerificationCtrl",["Event","Notification","$state",function(e,n,t){e.verify({id:t.params.id,code:t.params.code},function(){new n({title:"Email Verified",message:"Your email has been verified. You will now be able to receive email notifications for this event",type:"success",timeout:5e3})},function(){new n({title:"Verification Failed",message:"Your verification code has expired.",type:"error"})}),t.go("event",{id:t.params.id})}]),angular.module("rallly").directive("backImg",function(){return function(e,n,t){var i=t.backImg;n.css({"background-image":"url(/images/"+i+".png)"})}}),angular.module("rallly").directive("datepicker",function(){return{restrict:"A",require:"ngModel",scope:{model:"=ngModel",control:"="},templateUrl:"templates/directives/datePicker.html",link:function(e,n,t,i){e.model=e.model||[],e.control=e.control||{},e.$watchCollection("model",function(e){i.$setViewValue(e),i.$validate()}),i.$validators.required=function(e){return e&&0!=e.length?!0:!1};var a=Date.today(),s=a.clone(),o=function(n){s=n;var t=s.clone().moveToFirstDayOfMonth(),i=t.getDay();t.add(i-7).days(),e.title=s.toString("MMMM yyyy");for(var o=new Array(42),l=0;l<o.length;l++){var d=t.clone().add(l).days();o[l]={date:d,isOutsideMonth:d.getMonth()!=s.getMonth()?!0:!1,isToday:Date.equals(d,a)}}e.days=o};o(s),e.selectDay=function(n){if(n.isOutsideMonth&&o(n.date),-1!=(t=e.isActive(n.date,!0)))e.model.splice(t,1);else{var t=0,i=!1;do(void 0==e.model[t]||Date.compare(Date.parse(e.model[t]),n.date)>0)&&(e.model.splice(t,0,n.date),i=!0),t++;while(0==i)}},e.isActive=function(n,t){e.model=e.model||[];for(var i=0;i<e.model.length;i++)if(Date.equals(Date.parse(e.model[i]),n))return t?i:!0;return t?-1:!1},e.nextMonth=function(){o(s.add(1).months())},e.prevMonth=function(){o(s.add(-1).months())},e.control.removeDate=function(n){-1!=(index=e.isActive(Date.parse(n),!0))&&e.model.splice(index,1)}}}}),angular.module("rallly").directive("discussion",["$timeout","Comment","ConfirmModal",function(e,n,t){return{restrict:"A",templateUrl:"templates/directives/discussion.html",scope:{event:"="},link:function(i){i.comment={};var a=angular.element(".comment-thread");e(function(){a.scrollTop(a.prop("scrollHeight"))}),i.deleteComment=function(e){new t({title:"Are you sure?",message:"Are you sure you want to remove this comment?",confirmText:"Yes - delete",cancelText:"No - nevermind",isDestructive:!0,confirm:function(){n.remove({id:i.event._id,cid:e._id},function(e){i.event=e})}})},i.postComment=function(){if(i.commentForm.$valid){var e=new n(i.comment);e.$save({id:i.event._id},function(e){i.event=e,i.comment={}}),i.commentForm.$setPristine()}}}}}]),angular.module("rallly").directive("dropdown",["$document",function(e){return{restrict:"A",link:function(n,t){t.addClass("dropdown"),n.open=!1;var i=function(e){var i=t.find(e.target).length>0;i||n.toggle()};n.toggle=function(){n.open=!n.open,n.open?(t.addClass("open"),e.bind("click",i)):(t.removeClass("open"),e.unbind("click",i))}}}}]),angular.module("rallly").service("FormHelper",function(){this.emailRegexString="^([\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4})?$",this.emailRegex=new RegExp(this.emailRegexString),this.prettyError=function(e,n){return e.required?n+" is required":e.pattern?n+" is invalid":e.maxlength?n+" is too long":!1}}).directive("userForm",["FormHelper",function(e){return{scope:{event:"=",form:"="},templateUrl:"templates/form/userForm.html",link:function(n){n.errors={},n.emailRegex=e.emailRegex,n.$watchCollection("form.name.$error",function(t){n.errors.name=e.prettyError(t,"Name")}),n.$watchCollection("form.email.$error",function(t){n.errors.email=e.prettyError(t,"Email")})}}}]).directive("eventForm",["FormHelper",function(e){return{scope:{event:"=",form:"="},templateUrl:"templates/form/eventForm.html",link:function(n){n.errors={},n.$watchCollection("form.title.$error",function(t){n.errors.title=e.prettyError(t,"Title")}),n.$watchCollection("form.location.$error",function(t){n.errors.location=e.prettyError(t,"Location")})}}}]).directive("dateForm",function(){return{scope:{event:"=",form:"="},templateUrl:"templates/form/dateForm.html"}}).directive("participantsForm",["FormHelper",function(e){return{scope:{event:"=",form:"="},templateUrl:"templates/form/participantsForm.html",link:function(n){n.emailRegex=e.emailRegexString}}}]).directive("settingsForm",["Event","ConfirmModal",function(e,n){return{scope:{event:"=",form:"="},templateUrl:"templates/form/settingsForm.html",link:function(t){t.deleteEvent=function(){t.deleteRequestSent||e.delete({id:t.event._id},function(){t.deleteRequestSent=!0;new n({title:"Delete Request Sent",message:"An email has been sent to the creator of this event with instructions to delete it.",cancelText:"OK"})})}}}}]).directive("switchToggle",function(){return{scope:{model:"=ngModel"},require:"ngModel",link:function(e,n,t,i){n.addClass("switch-toggle");var a=function(){e.model^"undefined"!=typeof t.invert?n.addClass("active"):n.removeClass("active")};e.$watch("model",a),n.bind("click",function(n){e.model=!e.model,i.$setViewValue(e.model,n)})}}}).directive("timeForm",["DatePickerService",function(e){return{scope:{event:"=",form:"="},templateUrl:"templates/form/timeForm.html",link:function(n){var t,i=!1,a=n.$watch("event.dates",function(s){s&&!i&&a(),i=!0,t=new e(n.event.dates),n.unsetDate=function(e){t.removeDate(e)}})}}}]).directive("timePicker",["$timeout",function(){return{scope:{model:"=ngModel"},require:"ngModel",link:function(e,n,t,i){i.$viewChangeListeners.push(function(){e.model=i.$modelValue}),i.$parsers.push(function(e){return e?Date.parse(e):void 0}),i.$validators.time=function(e){if(i.$isEmpty(e))return!0;var n=Date.parse(e);return n?(i.$setViewValue(n.toString("hh:mm tt")),i.$render(),!0):!1}}}}]),angular.module("rallly").directive("poll",["$timeout","Participant","ConfirmModal",function(e,n,t){return{restrict:"A",templateUrl:"templates/directives/poll.html",scope:{event:"="},link:function(e){e.defaults=[],e.participant={};var i=[];e.event.$promise.then(function(n){for(var t=["John Example","Jane Specimen","Mark Instance","Mary Case"],i=[],a=0;a<t.length;a++){var s={name:t[a]};s.dates=[];for(var o=0;o<n.dates.length;o++){var l=Math.random()<.5;s.dates[o]=l}i.push(s)}e.examples=i}),e.delete=function(i){new t({title:"Delete "+i.name+"?",message:"Are you sure you want to remove "+i.name+" from the poll?",confirmText:"Yes - delete",cancelText:"No - nevermind",isDestructive:!0,confirm:function(){n.remove({id:e.event._id,pid:i._id},function(n){e.event=n})}})},e.isTopDate=function(e){for(var n=i[e],t=0;t<i.length;t++)if(i[t]>n)return!1;return!0},e.selectedDate=function(n){i[n]=0;for(var t=0;t<e.event.participants.length;t++)e.event.participants[t].votes[n]&&i[n]++;return i[n]},e.update=function(t){n.update({id:e.event._id,pid:t._id},t)},e.edit=function(n){e.defaults[e.event.participants.indexOf(n)]=angular.copy(n)},e.cancel=function(n){e.event.participants[n]=e.defaults[n]},e.save=function(){if(e.formnew.$valid){var t=new n(e.participant);t.$save({id:e.event._id},function(n){e.event=n,e.participant={}}),e.formnew.$setPristine()}}}}}]),angular.module("rallly").filter("elapsed",["$filter",function(e){return function(n){if(n){var t=Date.parse(n),i=(new Date).getTime(),a=i-t,s=Math.floor(a/1e3),o=Math.floor(s/60),l=Math.floor(o/60),d=Math.floor(l/24);return d>30?"on "+e("date")(n,"MMMM d"):d>1?d+" days ago":1==d?"1 day ago":l>1?l+" hours ago":1==l?"an hour ago":o>1?o+" minutes ago":1==o?"a minute ago":"a few seconds ago"}}}]),angular.module("rallly").factory("ConfirmModal",["btfModal",function(e){return function(n){var t;t=e({templateUrl:"templates/confirmmodal.html",controllerAs:"modal",controller:function(){this.title=n.title,this.message=n.message,this.confirm=n.confirm?function(){n.confirm(),t.deactivate()}:!1,this.cancel=t.deactivate,this.confirmText=n.confirmText||"Confirm",this.cancelText=n.cancelText||"Cancel",this.isDestructive=n.isDestructive}}),t.activate(),this.destroy=function(){t.deactivate()}}}]),angular.module("rallly").factory("Notification",["$timeout","btfModal",function(e,n){return function(t){var i;i=n({templateUrl:"templates/notification.html",controllerAs:"notification",controller:function(){this.title=t.title,this.message=t.message,this.close=i.deactivate,this.type=t.type;var n=t.timeout||5e3;e(i.deactivate,n)}}),i.activate(),this.destroy=function(){i.deactivate()}}}]);
|
||
//# sourceMappingURL=app.js.map
|