[
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2015 Matt Bradley\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "[Livestamp.js](http://mattbradley.github.com/livestampjs)\n=====================================================\n\nA simple, unobtrusive jQuery plugin that provides auto-updating timeago text to\nyour timestamped HTML elements using [Moment.js](http://momentjs.com).\n\nUsage\n-----\n\nSee the [livestamp documentation](http://mattbradley.github.com/livestampjs).\n\nDependencies\n------------\n\n* [jQuery](http://jquery.com): you already know what this is\n* [Moment.js](http://momentjs.com): a great JavaScript library for parsing\n  and displaying dates and times\n\nLicense\n-------\n\nCopyright (c) 2015 Matt Bradley\n\nThis software is freely distributable under the terms of the\n[MIT License](http://www.opensource.org/licenses/MIT).\n"
  },
  {
    "path": "bower.json",
    "content": "{\n  \"name\": \"livestamp\",\n  \"version\": \"2.0.0\",\n  \"keywords\": [\"livestamp\", \"timestamp\", \"timeago\"],\n  \"ignore\": [],\n  \"main\": \"livestamp.js\",\n  \"dependencies\": {\n    \"jquery\": \"*\",\n    \"moment\": \"*\"\n  }\n}\n"
  },
  {
    "path": "component.json",
    "content": "{\n  \"name\": \"livestamp\",\n  \"repository\": \"mattbradley/livestampjs\",\n  \"description\": \"A simple, unobtrusive jQuery plugin that provides auto-updating timeago text to your timestamped HTML elements using Moment.js.\",\n  \"version\": \"2.0.0\",\n  \"keywords\": [\"livestamp\", \"timestamp\", \"timeago\"],\n  \"dependencies\": {},\n  \"development\": {},\n  \"license\": \"MIT\",\n  \"main\": \"livestamp.js\",\n  \"scripts\": [\"livestamp.js\", \"livestamp.min.js\"]\n}\n"
  },
  {
    "path": "livestamp.js",
    "content": "// Livestamp.js / v2.0.0 / (c) 2015 Matt Bradley / MIT License\n(function (plugin) {\n  if (typeof define === 'function' && define.amd) {\n    // AMD. Register as an anonymous module.\n    define(['jquery', 'moment'], plugin);\n  } else {\n    // Browser globals\n    plugin(jQuery, moment);\n  }\n}(function($, moment) {\n  var updateInterval = 1e3,\n      paused = false,\n      $livestamps = $([]),\n\n  init = function() {\n    livestampGlobal.resume();\n  },\n\n  prep = function($el, timestamp) {\n    var oldData = $el.data('livestampdata');\n    if (typeof timestamp == 'number')\n      timestamp *= 1e3;\n\n    $el.removeAttr('data-livestamp')\n      .removeData('livestamp');\n\n    timestamp = moment(timestamp);\n    if (moment.isMoment(timestamp) && !isNaN(+timestamp)) {\n      var newData = $.extend({ }, { 'original': $el.contents() }, oldData);\n      newData.moment = moment(timestamp);\n\n      $el.data('livestampdata', newData).empty();\n      $livestamps.push($el[0]);\n    }\n  },\n\n  run = function() {\n    if (paused) return;\n    livestampGlobal.update();\n    setTimeout(run, updateInterval);\n  },\n\n  livestampGlobal = {\n    update: function() {\n      $('[data-livestamp]').each(function() {\n        var $this = $(this);\n        prep($this, $this.data('livestamp'));\n      });\n\n      var toRemove = [];\n      $livestamps.each(function() {\n        var $this = $(this),\n            data = $this.data('livestampdata');\n\n        if (data === undefined)\n          toRemove.push(this);\n        else if (moment.isMoment(data.moment)) {\n          var from = $this.html(),\n              to = data.moment.fromNow();\n\n          if (from != to) {\n            var e = $.Event('change.livestamp');\n            $this.trigger(e, [from, to]);\n            if (!e.isDefaultPrevented())\n              $this.html(to);\n          }\n        }\n      });\n\n      $livestamps = $livestamps.not(toRemove);\n      delete $livestamps.prevObject\n    },\n\n    pause: function() {\n      paused = true;\n    },\n\n    resume: function() {\n      paused = false;\n      run();\n    },\n\n    interval: function(interval) {\n      if (interval === undefined)\n        return updateInterval;\n      updateInterval = interval;\n    }\n  },\n\n  livestampLocal = {\n    add: function($el, timestamp) {\n      if (typeof timestamp == 'number')\n        timestamp *= 1e3;\n      timestamp = moment(timestamp);\n\n      if (moment.isMoment(timestamp) && !isNaN(+timestamp)) {\n        $el.each(function() {\n          prep($(this), timestamp);\n        });\n        livestampGlobal.update();\n      }\n\n      return $el;\n    },\n\n    destroy: function($el) {\n      $livestamps = $livestamps.not($el);\n      $el.each(function() {\n        var $this = $(this),\n            data = $this.data('livestampdata');\n\n        if (data === undefined)\n          return $el;\n\n        $this\n          .html(data.original ? data.original : '')\n          .removeData('livestampdata');\n      });\n\n      return $el;\n    },\n\n    isLivestamp: function($el) {\n      return $el.data('livestampdata') !== undefined;\n    }\n  };\n\n  $.livestamp = livestampGlobal;\n  $(init);\n  $.fn.livestamp = function(method, options) {\n    if (!livestampLocal[method]) {\n      options = method;\n      method = 'add';\n    }\n\n    return livestampLocal[method](this, options);\n  };\n}));\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"livestamp\",\n  \"version\": \"2.0.0\",\n  \"main\": \"livestamp\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://github.com/mattbradley/livestampjs.git\"\n  },\n  \"description\": \"A simple, unobtrusive jQuery plugin that provides auto-updating timeago text to your timestamped HTML elements using Moment.js.\",\n  \"keywords\": [\"livestamp\", \"timestamp\", \"timeago\"],\n  \"homepage\": \"http://mattbradley.github.com/livestampjs\",\n  \"bugs\": \"https://github.com/mattbradley/livestampjs/issues\",\n  \"license\": \"MIT\",\n  \"author\": {\n      \"name\": \"Matt Bradley\",\n      \"url\": \"https://twitter.com/mattbradley\"\n  },\n  \"devDependencies\": {\n    \"grunt\": \"~0.4.2\",\n    \"grunt-gh-pages\": \"~0.9.0\",\n    \"grunt-contrib-uglify\": \"~0.2.7\",\n    \"grunt-contrib-copy\": \"~0.5.0\",\n    \"grunt-bump\": \"0.0.13\"\n  }\n}\n"
  }
]