(function(a){a(document).ready(function(){var n,i=function(s,e,t){var l=a(".notification-popup ");l.find(".task").text(s),l.find(".notification-text").text(e),l.removeClass("hide success"),t&&l.addClass(t),n&&clearTimeout(n),n=setTimeout(function(){l.addClass("hide")},3e3)},o=function(){var s=a("#new-task").val();if(s==="")a("#new-task").addClass("error"),a(".new-task-wrapper .error-message").removeClass("hidden");else{var e=a(".task-list-body").prop("scrollHeight"),t=a(c).clone();t.find(".task-label").text(s),t.addClass("new"),t.removeClass("completed"),a("#task-list").append(t),a("#new-task").val(""),a("#mark-all-finished").removeClass("move-up"),a("#mark-all-incomplete").addClass("move-down"),i(s,"added to list"),a(".task-list-body").animate({scrollTop:e},1e3)}},r=function(){a(".add-task-btn").toggleClass("visible"),a(".new-task-wrapper").toggleClass("visible"),a("#new-task").hasClass("error")&&(a("#new-task").removeClass("error"),a(".new-task-wrapper .error-message").addClass("hidden"))},c='<li class="task"><div class="task-container"><span class="task-action-btn task-check"><span class="action-circle large complete-btn" title="Mark Complete"><i class="material-icons">check</i></span></span><span class="task-label" contenteditable="true"></span><span class="task-action-btn task-btn-right"><span class="action-circle large" title="Assign"><i class="material-icons">person_add</i></span> <span class="action-circle large delete-btn" title="Delete Task"><i class="material-icons">delete</i></span></span></div></li>';a(".add-task-btn").click(function(){var s=a(".new-task-wrapper").offset().top;a(this).toggleClass("visible"),a(".new-task-wrapper").toggleClass("visible"),a("#new-task").focus(),a("body").animate({scrollTop:s},1e3)}),a("#task-list").on("click",".task-action-btn .delete-btn",function(){var s=a(this).closest(".task"),e=s.find(".task-label").text();s.remove(),i(e," has been deleted.")}),a("#task-list").on("click",".task-action-btn .complete-btn",function(){var s=a(this).closest(".task"),e=s.find(".task-label").text(),t=s.hasClass("completed")?"Mark Complete":"Mark Incomplete";a(this).attr("title",t),s.hasClass("completed")?i(e,"marked as Incomplete."):i(e," marked as complete.","success"),s.toggleClass("completed")}),a("#new-task").keydown(function(s){var e=s.keyCode,t=13,l=27;a("#new-task").hasClass("error")&&(a("#new-task").removeClass("error"),a(".new-task-wrapper .error-message").addClass("hidden")),e==t?(s.preventDefault(),o()):e==l&&r()}),a("#add-task").click(o),a("#close-task-panel").click(r),a("#mark-all-finished").click(function(){a("#task-list .task").addClass("completed"),a("#mark-all-incomplete").removeClass("move-down"),a(this).addClass("move-up"),i("All tasks","marked as complete.","success")}),a("#mark-all-incomplete").click(function(){a("#task-list .task").removeClass("completed"),a(this).addClass("move-down"),a("#mark-all-finished").removeClass("move-up"),i("All tasks","marked as Incomplete.")})})})(jQuery);
