Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ga('send', 'pageview', '/index.html');
- $(document).ready(function() {
- $('#new-task').on('click', function(e) {
- return ga('send', 'event', 'New task focused', 'click');
- });
- $('#add-link').on('click', function(e) {
- return ga('send', 'event', 'Add link button', 'click');
- });
- $('#task-submit').on('click', function(e) {
- return ga('send', 'event', 'Add task button', 'click');
- });
- $('#clear-completed').on('click', function(e) {
- return ga('send', 'event', 'Clear completed', 'click');
- });
- return $('#export-tasks').on('click', function(e) {
- return ga('send', 'event', 'Export tasks', 'click');
- });
- });
- document.querySelector('#task-list').addEventListener('slip:reorder', function(e) {
- return ga('send', 'event', 'Reorder', 'click');
- });
- $(document).on('click', '.drag-handle', function() {
- return ga('send', 'event', 'Reorder with handle', 'click');
- });
- $(document).on('click', '.priority', function() {
- return ga('send', 'event', 'Priority', 'click');
- });
- $(document).on('mousedown', '.task > label', function() {
- return ga('send', 'event', 'Complete task', 'click');
- });
- $(document).on('click', '.task-link', function() {
- return ga('send', 'event', 'Task link', 'click');
- });
- $(document).on('click', '#whats-new-close', function() {
- return ga('send', 'event', 'Close Whats New', 'click');
- });
- $(document).on('click', '#tour-bus-1', function() {
- return ga('send', 'event', 'Onboarding', 'click', 'Step 1', 33);
- });
- $(document).on('click', '#tour-bus-2', function() {
- return ga('send', 'event', 'Onboarding', 'click', 'Step 2', 33);
- });
- $(document).on('click', '#tour-bus-3', function() {
- return ga('send', 'event', 'Onboarding', 'click', 'Step 3', 33);
- });
- var checkOnline, checkStorageMethod, setPopupClass, standardLog;
- setPopupClass = function() {
- var isPopup;
- isPopup = Utils.getUrlParameter('popup') === 'true';
- if (isPopup) {
- $('body').addClass('popup');
- return $('#expand').show();
- }
- };
- checkStorageMethod = function() {
- if (!!window.chrome && chrome.storage) {
- console.log('Using chrome.storage.sync to save');
- return window.storageType = ChromeStorage;
- } else {
- console.log('Using localStorage to save');
- return window.storageType = LocalStorage;
- }
- };
- checkOnline = function() {
- var online;
- online = navigator.onLine;
- if (online === true) {
- console.log('Connected to the internet');
- return setTimeout((function() {
- return $('#empty-state-image').css('background-image', 'url("https://unsplash.it/680/440/?random")');
- }), 0);
- } else {
- return console.log('Disconnected from the internet');
- }
- };
- standardLog = function() {
- console.log('Super Simple Tasks v2.0.5');
- return console.log('Like looking under the hood? Feel free to help make Super Simple Tasks better at https://github.com/humphreybc/super-simple-tasks');
- };
- $(document).ready(function() {
- var $link_input, $new_task_input, KeyPress, addLinkTriggered, addTaskTriggered, initialize, nextTourBus, tour;
- setPopupClass();
- standardLog();
- checkStorageMethod();
- checkOnline();
- $new_task_input = $('#new-task');
- $link_input = $('#add-link-input');
- window.tourRunning = false;
- tour = $('#tour').tourbus({
- onStop: Views.finishTour,
- onLegStart: function(leg, bus) {
- window.tourRunning = bus.running;
- return leg.$el.addClass('animated fadeInDown');
- }
- });
- initialize = function() {
- return window.storageType.get(DB.db_key, function(allTasks) {
- if (allTasks === null) {
- allTasks = Arrays.default_data;
- window.storageType.set(DB.db_key, allTasks);
- }
- ga('send', {
- 'hitType': 'event',
- 'eventCategory': 'Data',
- 'eventAction': 'Task count',
- 'eventValue': allTasks.length
- });
- Migrations.run(allTasks);
- Views.showTasks(allTasks);
- $new_task_input.focus();
- Views.checkOnboarding(allTasks, tour);
- Views.checkWhatsNew();
- return setTimeout((function() {
- return $('#main-content').addClass('content-show');
- }), 150);
- });
- };
- nextTourBus = function() {
- if (window.tourRunning) {
- return tour.trigger('next.tourbus');
- }
- };
- $('#whats-new-close').click(function(e) {
- $('.whats-new').hide();
- return Views.closeWhatsNew();
- });
- addTaskTriggered = function() {
- var link, name;
- nextTourBus();
- name = $new_task_input.val();
- if (name !== '') {
- $('#task-submit').removeClass('task-submit-button');
- $('#task-submit').addClass('task-submitted');
- setTimeout((function() {
- $('#task-submit').removeClass('task-submitted');
- return $('#task-submit').addClass('task-submit-button');
- }), 1000);
- link = $link_input.val();
- Task.setNewTask(name, link);
- $new_task_input.val('');
- $link_input.val('');
- }
- return $new_task_input.focus();
- };
- addLinkTriggered = function() {
- if ($('#add-link').hasClass('link-active')) {
- $('#add-link').removeClass('link-active');
- $('#add-link-input-wrapper').css('opacity', '0');
- setTimeout((function() {
- return $('#task-list').css('margin-top', '-40px');
- }), 150);
- return $new_task_input.focus();
- } else {
- $('#add-link').addClass('link-active');
- $('#task-list').css('margin-top', '0px');
- setTimeout((function() {
- return $('#add-link-input-wrapper').css('opacity', '1');
- }), 150);
- return $link_input.focus();
- }
- };
- $('#task-submit').click(addTaskTriggered);
- $('#add-link').click(addLinkTriggered);
- KeyPress = function(e) {
- var evtobj;
- evtobj = window.event ? event : e;
- if (evtobj.keyCode === 13) {
- addTaskTriggered();
- ga('send', 'event', 'Add task shortcut', 'shortcut');
- }
- if (evtobj.ctrlKey && evtobj.keyCode === 76) {
- addLinkTriggered();
- return ga('send', 'event', 'Add link shortcut', 'shortcut');
- }
- };
- document.onkeydown = KeyPress;
- $(document).on('click', '.task > label', function(e) {
- return e.preventDefault();
- });
- $(document).on('mousedown', '.task > label', function() {
- var holding;
- holding = false;
- setTimeout((function() {
- return holding = true;
- }), 250);
- return $(this).one('mouseup', function() {
- var checkbox, li;
- checkbox = void 0;
- if (!holding) {
- li = $(this).closest('li');
- checkbox = $('input', this);
- if (checkbox.prop('checked')) {
- Task.updateAttr(Views.getId(li), 'isDone', false);
- } else {
- Task.updateAttr(Views.getId(li), 'isDone', true);
- }
- checkbox.prop('checked', !checkbox.prop('checked'));
- return nextTourBus();
- }
- });
- });
- $(document).on('click', '.priority', function(e) {
- var li, type_attr, value;
- e.preventDefault();
- nextTourBus();
- type_attr = $(e.currentTarget).attr('type');
- value = $(this).attr(type_attr);
- li = $(this).closest('li');
- return Task.cycleAttr(li, type_attr, value);
- });
- $('#clear-completed').click(function(e) {
- e.preventDefault();
- return window.storageType.get(DB.db_key, function(allTasks) {
- if (allTasks.length !== 0) {
- return Task.clearCompleted();
- }
- });
- });
- $('#export-tasks').click(function(e) {
- e.preventDefault();
- return window.storageType.get(DB.db_key, function(allTasks) {
- return Exporter(allTasks, 'super simple tasks backup');
- });
- });
- $(document).on({
- mouseenter: function() {
- return $new_task_input.blur();
- }
- }, '.drag-handle');
- return initialize();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement