infractores 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/.env.sample +8 -0
  3. data/.gitignore +22 -0
  4. data/.travis.yml +14 -0
  5. data/CODE_OF_CONDUCT.md +49 -0
  6. data/Gemfile +67 -0
  7. data/Gemfile.lock +417 -0
  8. data/Guardfile +8 -0
  9. data/LICENSE +21 -0
  10. data/Procfile +2 -0
  11. data/README.md +48 -0
  12. data/Rakefile +6 -0
  13. data/app/assets/images/.keep +0 -0
  14. data/app/assets/images/gallery-buttons.png +0 -0
  15. data/app/assets/images/logo-infractores.svg +10 -0
  16. data/app/assets/javascripts/application.js +18 -0
  17. data/app/assets/javascripts/bootstrap.js +4 -0
  18. data/app/assets/javascripts/index.js +82 -0
  19. data/app/assets/javascripts/twitter.js +18 -0
  20. data/app/assets/stylesheets/1-utilities/_variables.scss +12 -0
  21. data/app/assets/stylesheets/2-quarks/_typography.scss +32 -0
  22. data/app/assets/stylesheets/3-atoms/_buttons.scss +3 -0
  23. data/app/assets/stylesheets/4-molecules/_footer.scss +32 -0
  24. data/app/assets/stylesheets/4-molecules/_infraction-gallery.scss +101 -0
  25. data/app/assets/stylesheets/4-molecules/_navbar.scss +71 -0
  26. data/app/assets/stylesheets/5-pages/index.scss +165 -0
  27. data/app/assets/stylesheets/5-pages/show.scss +29 -0
  28. data/app/assets/stylesheets/application.css +18 -0
  29. data/app/assets/stylesheets/bootstrap_and_overrides.css +7 -0
  30. data/app/controllers/application_controller.rb +5 -0
  31. data/app/controllers/concerns/.keep +0 -0
  32. data/app/controllers/infractions_controller.rb +23 -0
  33. data/app/controllers/users_controller.rb +7 -0
  34. data/app/helpers/application_helper.rb +19 -0
  35. data/app/helpers/infractions_helper.rb +6 -0
  36. data/app/mailers/.keep +0 -0
  37. data/app/models/.keep +0 -0
  38. data/app/models/concerns/.keep +0 -0
  39. data/app/models/evidence.rb +23 -0
  40. data/app/models/infraction.rb +43 -0
  41. data/app/models/tweet.rb +54 -0
  42. data/app/models/user.rb +34 -0
  43. data/app/services/twitter_service.rb +51 -0
  44. data/app/uploaders/evidence_uploader.rb +62 -0
  45. data/app/views/infractions/_map.html.erb +17 -0
  46. data/app/views/infractions/_reported_by.html.erb +4 -0
  47. data/app/views/infractions/_summary.html.erb +23 -0
  48. data/app/views/infractions/index.html.erb +18 -0
  49. data/app/views/infractions/show.html.erb +24 -0
  50. data/app/views/layouts/application.html.erb +90 -0
  51. data/app/views/shared/_google_analytics.html.erb +12 -0
  52. data/app/views/users/index.html.erb +21 -0
  53. data/app/workers/tweet_inspector.rb +18 -0
  54. data/bin/bundle +3 -0
  55. data/bin/rails +8 -0
  56. data/bin/rake +8 -0
  57. data/bin/setup +29 -0
  58. data/bin/spring +15 -0
  59. data/config.ru +4 -0
  60. data/config/application.rb +27 -0
  61. data/config/boot.rb +3 -0
  62. data/config/database.yml.sample +85 -0
  63. data/config/environment.rb +5 -0
  64. data/config/environments/development.rb +50 -0
  65. data/config/environments/production.rb +79 -0
  66. data/config/environments/test.rb +42 -0
  67. data/config/initializers/assets.rb +15 -0
  68. data/config/initializers/backtrace_silencers.rb +7 -0
  69. data/config/initializers/carrierwave.rb +17 -0
  70. data/config/initializers/cookies_serializer.rb +3 -0
  71. data/config/initializers/filter_parameter_logging.rb +4 -0
  72. data/config/initializers/inflections.rb +16 -0
  73. data/config/initializers/mime_types.rb +4 -0
  74. data/config/initializers/session_store.rb +3 -0
  75. data/config/initializers/twitter.rb +1 -0
  76. data/config/initializers/wrap_parameters.rb +14 -0
  77. data/config/locales/en.bootstrap.yml +23 -0
  78. data/config/locales/en.yml +23 -0
  79. data/config/locales/es.yml +263 -0
  80. data/config/routes.rb +6 -0
  81. data/config/secrets.yml +22 -0
  82. data/db/migrate/20150824210535_add_tweets_table.rb +8 -0
  83. data/db/migrate/20150829133406_create_infractions.rb +11 -0
  84. data/db/migrate/20150829134520_create_users.rb +12 -0
  85. data/db/migrate/20150829141909_add_user_id_to_tweets.rb +5 -0
  86. data/db/migrate/20150829154430_create_locations.rb +10 -0
  87. data/db/migrate/20150830224603_create_evidences_table.rb +8 -0
  88. data/db/migrate/20150911020838_add_valid_column_to_infractions.rb +6 -0
  89. data/db/migrate/20150911025204_add_index_to_users_username.rb +5 -0
  90. data/db/migrate/20151102220702_add_lat_lon_to_infractions.rb +6 -0
  91. data/db/migrate/20151102221811_remove_locations.rb +5 -0
  92. data/db/migrate/20151117194703_add_reported_at_to_infractions.rb +5 -0
  93. data/db/migrate/20160229023500_change_lat_lon_precision.rb +6 -0
  94. data/db/seeds.rb +7 -0
  95. data/infractores.gemspec +25 -0
  96. data/lib/assets/.keep +0 -0
  97. data/lib/infractores.rb +1 -0
  98. data/lib/infractores/version.rb +3 -0
  99. data/lib/tasks/.keep +0 -0
  100. data/lib/tasks/twitter.rake +16 -0
  101. data/lib/tasks/users.rake +9 -0
  102. data/log/.keep +0 -0
  103. data/public/404.html +67 -0
  104. data/public/422.html +67 -0
  105. data/public/500.html +66 -0
  106. data/public/favicon.ico +0 -0
  107. data/public/robots.txt +5 -0
  108. data/vendor/assets/images/blank.gif +0 -0
  109. data/vendor/assets/images/fancybox_loading.gif +0 -0
  110. data/vendor/assets/images/fancybox_loading@2x.gif +0 -0
  111. data/vendor/assets/images/fancybox_overlay.png +0 -0
  112. data/vendor/assets/images/fancybox_sprite.png +0 -0
  113. data/vendor/assets/images/fancybox_sprite@2x.png +0 -0
  114. data/vendor/assets/images/glyphicons-halflings-white.png +0 -0
  115. data/vendor/assets/images/glyphicons-halflings.png +0 -0
  116. data/vendor/assets/javascripts/.keep +0 -0
  117. data/vendor/assets/javascripts/jquery.fancybox-buttons.js +122 -0
  118. data/vendor/assets/javascripts/jquery.fancybox.pack.js +46 -0
  119. data/vendor/assets/javascripts/livereload.js +1183 -0
  120. data/vendor/assets/stylesheets/.keep +0 -0
  121. data/vendor/assets/stylesheets/jquery.fancybox-buttons.css +97 -0
  122. data/vendor/assets/stylesheets/jquery.fancybox.css +274 -0
  123. metadata +215 -0
File without changes
@@ -0,0 +1,122 @@
1
+ /*!
2
+ * Buttons helper for fancyBox
3
+ * version: 1.0.5 (Mon, 15 Oct 2012)
4
+ * @requires fancyBox v2.0 or later
5
+ *
6
+ * Usage:
7
+ * $(".fancybox").fancybox({
8
+ * helpers : {
9
+ * buttons: {
10
+ * position : 'top'
11
+ * }
12
+ * }
13
+ * });
14
+ *
15
+ */
16
+ (function ($) {
17
+ //Shortcut for fancyBox object
18
+ var F = $.fancybox;
19
+
20
+ //Add helper object
21
+ F.helpers.buttons = {
22
+ defaults : {
23
+ skipSingle : false, // disables if gallery contains single image
24
+ position : 'top', // 'top' or 'bottom'
25
+ tpl : '<div id="fancybox-buttons"><ul><li><a class="btnPrev" title="Previous" href="javascript:;"></a></li><li><a class="btnPlay" title="Start slideshow" href="javascript:;"></a></li><li><a class="btnNext" title="Next" href="javascript:;"></a></li><li><a class="btnToggle" title="Toggle size" href="javascript:;"></a></li><li><a class="btnClose" title="Close" href="javascript:;"></a></li></ul></div>'
26
+ },
27
+
28
+ list : null,
29
+ buttons: null,
30
+
31
+ beforeLoad: function (opts, obj) {
32
+ //Remove self if gallery do not have at least two items
33
+
34
+ if (opts.skipSingle && obj.group.length < 2) {
35
+ obj.helpers.buttons = false;
36
+ obj.closeBtn = true;
37
+
38
+ return;
39
+ }
40
+
41
+ //Increase top margin to give space for buttons
42
+ obj.margin[ opts.position === 'bottom' ? 2 : 0 ] += 30;
43
+ },
44
+
45
+ onPlayStart: function () {
46
+ if (this.buttons) {
47
+ this.buttons.play.attr('title', 'Pause slideshow').addClass('btnPlayOn');
48
+ }
49
+ },
50
+
51
+ onPlayEnd: function () {
52
+ if (this.buttons) {
53
+ this.buttons.play.attr('title', 'Start slideshow').removeClass('btnPlayOn');
54
+ }
55
+ },
56
+
57
+ afterShow: function (opts, obj) {
58
+ var buttons = this.buttons;
59
+
60
+ if (!buttons) {
61
+ this.list = $(opts.tpl).addClass(opts.position).appendTo('body');
62
+
63
+ buttons = {
64
+ prev : this.list.find('.btnPrev').click( F.prev ),
65
+ next : this.list.find('.btnNext').click( F.next ),
66
+ play : this.list.find('.btnPlay').click( F.play ),
67
+ toggle : this.list.find('.btnToggle').click( F.toggle ),
68
+ close : this.list.find('.btnClose').click( F.close )
69
+ }
70
+ }
71
+
72
+ //Prev
73
+ if (obj.index > 0 || obj.loop) {
74
+ buttons.prev.removeClass('btnDisabled');
75
+ } else {
76
+ buttons.prev.addClass('btnDisabled');
77
+ }
78
+
79
+ //Next / Play
80
+ if (obj.loop || obj.index < obj.group.length - 1) {
81
+ buttons.next.removeClass('btnDisabled');
82
+ buttons.play.removeClass('btnDisabled');
83
+
84
+ } else {
85
+ buttons.next.addClass('btnDisabled');
86
+ buttons.play.addClass('btnDisabled');
87
+ }
88
+
89
+ this.buttons = buttons;
90
+
91
+ this.onUpdate(opts, obj);
92
+ },
93
+
94
+ onUpdate: function (opts, obj) {
95
+ var toggle;
96
+
97
+ if (!this.buttons) {
98
+ return;
99
+ }
100
+
101
+ toggle = this.buttons.toggle.removeClass('btnDisabled btnToggleOn');
102
+
103
+ //Size toggle button
104
+ if (obj.canShrink) {
105
+ toggle.addClass('btnToggleOn');
106
+
107
+ } else if (!obj.canExpand) {
108
+ toggle.addClass('btnDisabled');
109
+ }
110
+ },
111
+
112
+ beforeClose: function () {
113
+ if (this.list) {
114
+ this.list.remove();
115
+ }
116
+
117
+ this.list = null;
118
+ this.buttons = null;
119
+ }
120
+ };
121
+
122
+ }(jQuery));
@@ -0,0 +1,46 @@
1
+ /*! fancyBox v2.1.5 fancyapps.com | fancyapps.com/fancybox/#license */
2
+ (function(r,G,f,v){var J=f("html"),n=f(r),p=f(G),b=f.fancybox=function(){b.open.apply(this,arguments)},I=navigator.userAgent.match(/msie/i),B=null,s=G.createTouch!==v,t=function(a){return a&&a.hasOwnProperty&&a instanceof f},q=function(a){return a&&"string"===f.type(a)},E=function(a){return q(a)&&0<a.indexOf("%")},l=function(a,d){var e=parseInt(a,10)||0;d&&E(a)&&(e*=b.getViewport()[d]/100);return Math.ceil(e)},w=function(a,b){return l(a,b)+"px"};f.extend(b,{version:"2.1.5",defaults:{padding:15,margin:20,
3
+ width:800,height:600,minWidth:100,minHeight:100,maxWidth:9999,maxHeight:9999,pixelRatio:1,autoSize:!0,autoHeight:!1,autoWidth:!1,autoResize:!0,autoCenter:!s,fitToView:!0,aspectRatio:!1,topRatio:0.5,leftRatio:0.5,scrolling:"auto",wrapCSS:"",arrows:!0,closeBtn:!0,closeClick:!1,nextClick:!1,mouseWheel:!0,autoPlay:!1,playSpeed:3E3,preload:3,modal:!1,loop:!0,ajax:{dataType:"html",headers:{"X-fancyBox":!0}},iframe:{scrolling:"auto",preload:!0},swf:{wmode:"transparent",allowfullscreen:"true",allowscriptaccess:"always"},
4
+ keys:{next:{13:"left",34:"up",39:"left",40:"up"},prev:{8:"right",33:"down",37:"right",38:"down"},close:[27],play:[32],toggle:[70]},direction:{next:"left",prev:"right"},scrollOutside:!0,index:0,type:null,href:null,content:null,title:null,tpl:{wrap:'<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',image:'<img class="fancybox-image" src="{href}" alt="" />',iframe:'<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen'+
5
+ (I?' allowtransparency="true"':"")+"></iframe>",error:'<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',closeBtn:'<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',next:'<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',prev:'<a title="Previous" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'},openEffect:"fade",openSpeed:250,openEasing:"swing",openOpacity:!0,
6
+ openMethod:"zoomIn",closeEffect:"fade",closeSpeed:250,closeEasing:"swing",closeOpacity:!0,closeMethod:"zoomOut",nextEffect:"elastic",nextSpeed:250,nextEasing:"swing",nextMethod:"changeIn",prevEffect:"elastic",prevSpeed:250,prevEasing:"swing",prevMethod:"changeOut",helpers:{overlay:!0,title:!0},onCancel:f.noop,beforeLoad:f.noop,afterLoad:f.noop,beforeShow:f.noop,afterShow:f.noop,beforeChange:f.noop,beforeClose:f.noop,afterClose:f.noop},group:{},opts:{},previous:null,coming:null,current:null,isActive:!1,
7
+ isOpen:!1,isOpened:!1,wrap:null,skin:null,outer:null,inner:null,player:{timer:null,isActive:!1},ajaxLoad:null,imgPreload:null,transitions:{},helpers:{},open:function(a,d){if(a&&(f.isPlainObject(d)||(d={}),!1!==b.close(!0)))return f.isArray(a)||(a=t(a)?f(a).get():[a]),f.each(a,function(e,c){var k={},g,h,j,m,l;"object"===f.type(c)&&(c.nodeType&&(c=f(c)),t(c)?(k={href:c.data("fancybox-href")||c.attr("href"),title:c.data("fancybox-title")||c.attr("title"),isDom:!0,element:c},f.metadata&&f.extend(!0,k,
8
+ c.metadata())):k=c);g=d.href||k.href||(q(c)?c:null);h=d.title!==v?d.title:k.title||"";m=(j=d.content||k.content)?"html":d.type||k.type;!m&&k.isDom&&(m=c.data("fancybox-type"),m||(m=(m=c.prop("class").match(/fancybox\.(\w+)/))?m[1]:null));q(g)&&(m||(b.isImage(g)?m="image":b.isSWF(g)?m="swf":"#"===g.charAt(0)?m="inline":q(c)&&(m="html",j=c)),"ajax"===m&&(l=g.split(/\s+/,2),g=l.shift(),l=l.shift()));j||("inline"===m?g?j=f(q(g)?g.replace(/.*(?=#[^\s]+$)/,""):g):k.isDom&&(j=c):"html"===m?j=g:!m&&(!g&&
9
+ k.isDom)&&(m="inline",j=c));f.extend(k,{href:g,type:m,content:j,title:h,selector:l});a[e]=k}),b.opts=f.extend(!0,{},b.defaults,d),d.keys!==v&&(b.opts.keys=d.keys?f.extend({},b.defaults.keys,d.keys):!1),b.group=a,b._start(b.opts.index)},cancel:function(){var a=b.coming;a&&!1!==b.trigger("onCancel")&&(b.hideLoading(),b.ajaxLoad&&b.ajaxLoad.abort(),b.ajaxLoad=null,b.imgPreload&&(b.imgPreload.onload=b.imgPreload.onerror=null),a.wrap&&a.wrap.stop(!0,!0).trigger("onReset").remove(),b.coming=null,b.current||
10
+ b._afterZoomOut(a))},close:function(a){b.cancel();!1!==b.trigger("beforeClose")&&(b.unbindEvents(),b.isActive&&(!b.isOpen||!0===a?(f(".fancybox-wrap").stop(!0).trigger("onReset").remove(),b._afterZoomOut()):(b.isOpen=b.isOpened=!1,b.isClosing=!0,f(".fancybox-item, .fancybox-nav").remove(),b.wrap.stop(!0,!0).removeClass("fancybox-opened"),b.transitions[b.current.closeMethod]())))},play:function(a){var d=function(){clearTimeout(b.player.timer)},e=function(){d();b.current&&b.player.isActive&&(b.player.timer=
11
+ setTimeout(b.next,b.current.playSpeed))},c=function(){d();p.unbind(".player");b.player.isActive=!1;b.trigger("onPlayEnd")};if(!0===a||!b.player.isActive&&!1!==a){if(b.current&&(b.current.loop||b.current.index<b.group.length-1))b.player.isActive=!0,p.bind({"onCancel.player beforeClose.player":c,"onUpdate.player":e,"beforeLoad.player":d}),e(),b.trigger("onPlayStart")}else c()},next:function(a){var d=b.current;d&&(q(a)||(a=d.direction.next),b.jumpto(d.index+1,a,"next"))},prev:function(a){var d=b.current;
12
+ d&&(q(a)||(a=d.direction.prev),b.jumpto(d.index-1,a,"prev"))},jumpto:function(a,d,e){var c=b.current;c&&(a=l(a),b.direction=d||c.direction[a>=c.index?"next":"prev"],b.router=e||"jumpto",c.loop&&(0>a&&(a=c.group.length+a%c.group.length),a%=c.group.length),c.group[a]!==v&&(b.cancel(),b._start(a)))},reposition:function(a,d){var e=b.current,c=e?e.wrap:null,k;c&&(k=b._getPosition(d),a&&"scroll"===a.type?(delete k.position,c.stop(!0,!0).animate(k,200)):(c.css(k),e.pos=f.extend({},e.dim,k)))},update:function(a){var d=
13
+ a&&a.type,e=!d||"orientationchange"===d;e&&(clearTimeout(B),B=null);b.isOpen&&!B&&(B=setTimeout(function(){var c=b.current;c&&!b.isClosing&&(b.wrap.removeClass("fancybox-tmp"),(e||"load"===d||"resize"===d&&c.autoResize)&&b._setDimension(),"scroll"===d&&c.canShrink||b.reposition(a),b.trigger("onUpdate"),B=null)},e&&!s?0:300))},toggle:function(a){b.isOpen&&(b.current.fitToView="boolean"===f.type(a)?a:!b.current.fitToView,s&&(b.wrap.removeAttr("style").addClass("fancybox-tmp"),b.trigger("onUpdate")),
14
+ b.update())},hideLoading:function(){p.unbind(".loading");f("#fancybox-loading").remove()},showLoading:function(){var a,d;b.hideLoading();a=f('<div id="fancybox-loading"><div></div></div>').click(b.cancel).appendTo("body");p.bind("keydown.loading",function(a){if(27===(a.which||a.keyCode))a.preventDefault(),b.cancel()});b.defaults.fixed||(d=b.getViewport(),a.css({position:"absolute",top:0.5*d.h+d.y,left:0.5*d.w+d.x}))},getViewport:function(){var a=b.current&&b.current.locked||!1,d={x:n.scrollLeft(),
15
+ y:n.scrollTop()};a?(d.w=a[0].clientWidth,d.h=a[0].clientHeight):(d.w=s&&r.innerWidth?r.innerWidth:n.width(),d.h=s&&r.innerHeight?r.innerHeight:n.height());return d},unbindEvents:function(){b.wrap&&t(b.wrap)&&b.wrap.unbind(".fb");p.unbind(".fb");n.unbind(".fb")},bindEvents:function(){var a=b.current,d;a&&(n.bind("orientationchange.fb"+(s?"":" resize.fb")+(a.autoCenter&&!a.locked?" scroll.fb":""),b.update),(d=a.keys)&&p.bind("keydown.fb",function(e){var c=e.which||e.keyCode,k=e.target||e.srcElement;
16
+ if(27===c&&b.coming)return!1;!e.ctrlKey&&(!e.altKey&&!e.shiftKey&&!e.metaKey&&(!k||!k.type&&!f(k).is("[contenteditable]")))&&f.each(d,function(d,k){if(1<a.group.length&&k[c]!==v)return b[d](k[c]),e.preventDefault(),!1;if(-1<f.inArray(c,k))return b[d](),e.preventDefault(),!1})}),f.fn.mousewheel&&a.mouseWheel&&b.wrap.bind("mousewheel.fb",function(d,c,k,g){for(var h=f(d.target||null),j=!1;h.length&&!j&&!h.is(".fancybox-skin")&&!h.is(".fancybox-wrap");)j=h[0]&&!(h[0].style.overflow&&"hidden"===h[0].style.overflow)&&
17
+ (h[0].clientWidth&&h[0].scrollWidth>h[0].clientWidth||h[0].clientHeight&&h[0].scrollHeight>h[0].clientHeight),h=f(h).parent();if(0!==c&&!j&&1<b.group.length&&!a.canShrink){if(0<g||0<k)b.prev(0<g?"down":"left");else if(0>g||0>k)b.next(0>g?"up":"right");d.preventDefault()}}))},trigger:function(a,d){var e,c=d||b.coming||b.current;if(c){f.isFunction(c[a])&&(e=c[a].apply(c,Array.prototype.slice.call(arguments,1)));if(!1===e)return!1;c.helpers&&f.each(c.helpers,function(d,e){if(e&&b.helpers[d]&&f.isFunction(b.helpers[d][a]))b.helpers[d][a](f.extend(!0,
18
+ {},b.helpers[d].defaults,e),c)});p.trigger(a)}},isImage:function(a){return q(a)&&a.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i)},isSWF:function(a){return q(a)&&a.match(/\.(swf)((\?|#).*)?$/i)},_start:function(a){var d={},e,c;a=l(a);e=b.group[a]||null;if(!e)return!1;d=f.extend(!0,{},b.opts,e);e=d.margin;c=d.padding;"number"===f.type(e)&&(d.margin=[e,e,e,e]);"number"===f.type(c)&&(d.padding=[c,c,c,c]);d.modal&&f.extend(!0,d,{closeBtn:!1,closeClick:!1,nextClick:!1,arrows:!1,
19
+ mouseWheel:!1,keys:null,helpers:{overlay:{closeClick:!1}}});d.autoSize&&(d.autoWidth=d.autoHeight=!0);"auto"===d.width&&(d.autoWidth=!0);"auto"===d.height&&(d.autoHeight=!0);d.group=b.group;d.index=a;b.coming=d;if(!1===b.trigger("beforeLoad"))b.coming=null;else{c=d.type;e=d.href;if(!c)return b.coming=null,b.current&&b.router&&"jumpto"!==b.router?(b.current.index=a,b[b.router](b.direction)):!1;b.isActive=!0;if("image"===c||"swf"===c)d.autoHeight=d.autoWidth=!1,d.scrolling="visible";"image"===c&&(d.aspectRatio=
20
+ !0);"iframe"===c&&s&&(d.scrolling="scroll");d.wrap=f(d.tpl.wrap).addClass("fancybox-"+(s?"mobile":"desktop")+" fancybox-type-"+c+" fancybox-tmp "+d.wrapCSS).appendTo(d.parent||"body");f.extend(d,{skin:f(".fancybox-skin",d.wrap),outer:f(".fancybox-outer",d.wrap),inner:f(".fancybox-inner",d.wrap)});f.each(["Top","Right","Bottom","Left"],function(a,b){d.skin.css("padding"+b,w(d.padding[a]))});b.trigger("onReady");if("inline"===c||"html"===c){if(!d.content||!d.content.length)return b._error("content")}else if(!e)return b._error("href");
21
+ "image"===c?b._loadImage():"ajax"===c?b._loadAjax():"iframe"===c?b._loadIframe():b._afterLoad()}},_error:function(a){f.extend(b.coming,{type:"html",autoWidth:!0,autoHeight:!0,minWidth:0,minHeight:0,scrolling:"no",hasError:a,content:b.coming.tpl.error});b._afterLoad()},_loadImage:function(){var a=b.imgPreload=new Image;a.onload=function(){this.onload=this.onerror=null;b.coming.width=this.width/b.opts.pixelRatio;b.coming.height=this.height/b.opts.pixelRatio;b._afterLoad()};a.onerror=function(){this.onload=
22
+ this.onerror=null;b._error("image")};a.src=b.coming.href;!0!==a.complete&&b.showLoading()},_loadAjax:function(){var a=b.coming;b.showLoading();b.ajaxLoad=f.ajax(f.extend({},a.ajax,{url:a.href,error:function(a,e){b.coming&&"abort"!==e?b._error("ajax",a):b.hideLoading()},success:function(d,e){"success"===e&&(a.content=d,b._afterLoad())}}))},_loadIframe:function(){var a=b.coming,d=f(a.tpl.iframe.replace(/\{rnd\}/g,(new Date).getTime())).attr("scrolling",s?"auto":a.iframe.scrolling).attr("src",a.href);
23
+ f(a.wrap).bind("onReset",function(){try{f(this).find("iframe").hide().attr("src","//about:blank").end().empty()}catch(a){}});a.iframe.preload&&(b.showLoading(),d.one("load",function(){f(this).data("ready",1);s||f(this).bind("load.fb",b.update);f(this).parents(".fancybox-wrap").width("100%").removeClass("fancybox-tmp").show();b._afterLoad()}));a.content=d.appendTo(a.inner);a.iframe.preload||b._afterLoad()},_preloadImages:function(){var a=b.group,d=b.current,e=a.length,c=d.preload?Math.min(d.preload,
24
+ e-1):0,f,g;for(g=1;g<=c;g+=1)f=a[(d.index+g)%e],"image"===f.type&&f.href&&((new Image).src=f.href)},_afterLoad:function(){var a=b.coming,d=b.current,e,c,k,g,h;b.hideLoading();if(a&&!1!==b.isActive)if(!1===b.trigger("afterLoad",a,d))a.wrap.stop(!0).trigger("onReset").remove(),b.coming=null;else{d&&(b.trigger("beforeChange",d),d.wrap.stop(!0).removeClass("fancybox-opened").find(".fancybox-item, .fancybox-nav").remove());b.unbindEvents();e=a.content;c=a.type;k=a.scrolling;f.extend(b,{wrap:a.wrap,skin:a.skin,
25
+ outer:a.outer,inner:a.inner,current:a,previous:d});g=a.href;switch(c){case "inline":case "ajax":case "html":a.selector?e=f("<div>").html(e).find(a.selector):t(e)&&(e.data("fancybox-placeholder")||e.data("fancybox-placeholder",f('<div class="fancybox-placeholder"></div>').insertAfter(e).hide()),e=e.show().detach(),a.wrap.bind("onReset",function(){f(this).find(e).length&&e.hide().replaceAll(e.data("fancybox-placeholder")).data("fancybox-placeholder",!1)}));break;case "image":e=a.tpl.image.replace("{href}",
26
+ g);break;case "swf":e='<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="'+g+'"></param>',h="",f.each(a.swf,function(a,b){e+='<param name="'+a+'" value="'+b+'"></param>';h+=" "+a+'="'+b+'"'}),e+='<embed src="'+g+'" type="application/x-shockwave-flash" width="100%" height="100%"'+h+"></embed></object>"}(!t(e)||!e.parent().is(a.inner))&&a.inner.append(e);b.trigger("beforeShow");a.inner.css("overflow","yes"===k?"scroll":
27
+ "no"===k?"hidden":k);b._setDimension();b.reposition();b.isOpen=!1;b.coming=null;b.bindEvents();if(b.isOpened){if(d.prevMethod)b.transitions[d.prevMethod]()}else f(".fancybox-wrap").not(a.wrap).stop(!0).trigger("onReset").remove();b.transitions[b.isOpened?a.nextMethod:a.openMethod]();b._preloadImages()}},_setDimension:function(){var a=b.getViewport(),d=0,e=!1,c=!1,e=b.wrap,k=b.skin,g=b.inner,h=b.current,c=h.width,j=h.height,m=h.minWidth,u=h.minHeight,n=h.maxWidth,p=h.maxHeight,s=h.scrolling,q=h.scrollOutside?
28
+ h.scrollbarWidth:0,x=h.margin,y=l(x[1]+x[3]),r=l(x[0]+x[2]),v,z,t,C,A,F,B,D,H;e.add(k).add(g).width("auto").height("auto").removeClass("fancybox-tmp");x=l(k.outerWidth(!0)-k.width());v=l(k.outerHeight(!0)-k.height());z=y+x;t=r+v;C=E(c)?(a.w-z)*l(c)/100:c;A=E(j)?(a.h-t)*l(j)/100:j;if("iframe"===h.type){if(H=h.content,h.autoHeight&&1===H.data("ready"))try{H[0].contentWindow.document.location&&(g.width(C).height(9999),F=H.contents().find("body"),q&&F.css("overflow-x","hidden"),A=F.outerHeight(!0))}catch(G){}}else if(h.autoWidth||
29
+ h.autoHeight)g.addClass("fancybox-tmp"),h.autoWidth||g.width(C),h.autoHeight||g.height(A),h.autoWidth&&(C=g.width()),h.autoHeight&&(A=g.height()),g.removeClass("fancybox-tmp");c=l(C);j=l(A);D=C/A;m=l(E(m)?l(m,"w")-z:m);n=l(E(n)?l(n,"w")-z:n);u=l(E(u)?l(u,"h")-t:u);p=l(E(p)?l(p,"h")-t:p);F=n;B=p;h.fitToView&&(n=Math.min(a.w-z,n),p=Math.min(a.h-t,p));z=a.w-y;r=a.h-r;h.aspectRatio?(c>n&&(c=n,j=l(c/D)),j>p&&(j=p,c=l(j*D)),c<m&&(c=m,j=l(c/D)),j<u&&(j=u,c=l(j*D))):(c=Math.max(m,Math.min(c,n)),h.autoHeight&&
30
+ "iframe"!==h.type&&(g.width(c),j=g.height()),j=Math.max(u,Math.min(j,p)));if(h.fitToView)if(g.width(c).height(j),e.width(c+x),a=e.width(),y=e.height(),h.aspectRatio)for(;(a>z||y>r)&&(c>m&&j>u)&&!(19<d++);)j=Math.max(u,Math.min(p,j-10)),c=l(j*D),c<m&&(c=m,j=l(c/D)),c>n&&(c=n,j=l(c/D)),g.width(c).height(j),e.width(c+x),a=e.width(),y=e.height();else c=Math.max(m,Math.min(c,c-(a-z))),j=Math.max(u,Math.min(j,j-(y-r)));q&&("auto"===s&&j<A&&c+x+q<z)&&(c+=q);g.width(c).height(j);e.width(c+x);a=e.width();
31
+ y=e.height();e=(a>z||y>r)&&c>m&&j>u;c=h.aspectRatio?c<F&&j<B&&c<C&&j<A:(c<F||j<B)&&(c<C||j<A);f.extend(h,{dim:{width:w(a),height:w(y)},origWidth:C,origHeight:A,canShrink:e,canExpand:c,wPadding:x,hPadding:v,wrapSpace:y-k.outerHeight(!0),skinSpace:k.height()-j});!H&&(h.autoHeight&&j>u&&j<p&&!c)&&g.height("auto")},_getPosition:function(a){var d=b.current,e=b.getViewport(),c=d.margin,f=b.wrap.width()+c[1]+c[3],g=b.wrap.height()+c[0]+c[2],c={position:"absolute",top:c[0],left:c[3]};d.autoCenter&&d.fixed&&
32
+ !a&&g<=e.h&&f<=e.w?c.position="fixed":d.locked||(c.top+=e.y,c.left+=e.x);c.top=w(Math.max(c.top,c.top+(e.h-g)*d.topRatio));c.left=w(Math.max(c.left,c.left+(e.w-f)*d.leftRatio));return c},_afterZoomIn:function(){var a=b.current;a&&(b.isOpen=b.isOpened=!0,b.wrap.css("overflow","visible").addClass("fancybox-opened"),b.update(),(a.closeClick||a.nextClick&&1<b.group.length)&&b.inner.css("cursor","pointer").bind("click.fb",function(d){!f(d.target).is("a")&&!f(d.target).parent().is("a")&&(d.preventDefault(),
33
+ b[a.closeClick?"close":"next"]())}),a.closeBtn&&f(a.tpl.closeBtn).appendTo(b.skin).bind("click.fb",function(a){a.preventDefault();b.close()}),a.arrows&&1<b.group.length&&((a.loop||0<a.index)&&f(a.tpl.prev).appendTo(b.outer).bind("click.fb",b.prev),(a.loop||a.index<b.group.length-1)&&f(a.tpl.next).appendTo(b.outer).bind("click.fb",b.next)),b.trigger("afterShow"),!a.loop&&a.index===a.group.length-1?b.play(!1):b.opts.autoPlay&&!b.player.isActive&&(b.opts.autoPlay=!1,b.play()))},_afterZoomOut:function(a){a=
34
+ a||b.current;f(".fancybox-wrap").trigger("onReset").remove();f.extend(b,{group:{},opts:{},router:!1,current:null,isActive:!1,isOpened:!1,isOpen:!1,isClosing:!1,wrap:null,skin:null,outer:null,inner:null});b.trigger("afterClose",a)}});b.transitions={getOrigPosition:function(){var a=b.current,d=a.element,e=a.orig,c={},f=50,g=50,h=a.hPadding,j=a.wPadding,m=b.getViewport();!e&&(a.isDom&&d.is(":visible"))&&(e=d.find("img:first"),e.length||(e=d));t(e)?(c=e.offset(),e.is("img")&&(f=e.outerWidth(),g=e.outerHeight())):
35
+ (c.top=m.y+(m.h-g)*a.topRatio,c.left=m.x+(m.w-f)*a.leftRatio);if("fixed"===b.wrap.css("position")||a.locked)c.top-=m.y,c.left-=m.x;return c={top:w(c.top-h*a.topRatio),left:w(c.left-j*a.leftRatio),width:w(f+j),height:w(g+h)}},step:function(a,d){var e,c,f=d.prop;c=b.current;var g=c.wrapSpace,h=c.skinSpace;if("width"===f||"height"===f)e=d.end===d.start?1:(a-d.start)/(d.end-d.start),b.isClosing&&(e=1-e),c="width"===f?c.wPadding:c.hPadding,c=a-c,b.skin[f](l("width"===f?c:c-g*e)),b.inner[f](l("width"===
36
+ f?c:c-g*e-h*e))},zoomIn:function(){var a=b.current,d=a.pos,e=a.openEffect,c="elastic"===e,k=f.extend({opacity:1},d);delete k.position;c?(d=this.getOrigPosition(),a.openOpacity&&(d.opacity=0.1)):"fade"===e&&(d.opacity=0.1);b.wrap.css(d).animate(k,{duration:"none"===e?0:a.openSpeed,easing:a.openEasing,step:c?this.step:null,complete:b._afterZoomIn})},zoomOut:function(){var a=b.current,d=a.closeEffect,e="elastic"===d,c={opacity:0.1};e&&(c=this.getOrigPosition(),a.closeOpacity&&(c.opacity=0.1));b.wrap.animate(c,
37
+ {duration:"none"===d?0:a.closeSpeed,easing:a.closeEasing,step:e?this.step:null,complete:b._afterZoomOut})},changeIn:function(){var a=b.current,d=a.nextEffect,e=a.pos,c={opacity:1},f=b.direction,g;e.opacity=0.1;"elastic"===d&&(g="down"===f||"up"===f?"top":"left","down"===f||"right"===f?(e[g]=w(l(e[g])-200),c[g]="+=200px"):(e[g]=w(l(e[g])+200),c[g]="-=200px"));"none"===d?b._afterZoomIn():b.wrap.css(e).animate(c,{duration:a.nextSpeed,easing:a.nextEasing,complete:b._afterZoomIn})},changeOut:function(){var a=
38
+ b.previous,d=a.prevEffect,e={opacity:0.1},c=b.direction;"elastic"===d&&(e["down"===c||"up"===c?"top":"left"]=("up"===c||"left"===c?"-":"+")+"=200px");a.wrap.animate(e,{duration:"none"===d?0:a.prevSpeed,easing:a.prevEasing,complete:function(){f(this).trigger("onReset").remove()}})}};b.helpers.overlay={defaults:{closeClick:!0,speedOut:200,showEarly:!0,css:{},locked:!s,fixed:!0},overlay:null,fixed:!1,el:f("html"),create:function(a){a=f.extend({},this.defaults,a);this.overlay&&this.close();this.overlay=
39
+ f('<div class="fancybox-overlay"></div>').appendTo(b.coming?b.coming.parent:a.parent);this.fixed=!1;a.fixed&&b.defaults.fixed&&(this.overlay.addClass("fancybox-overlay-fixed"),this.fixed=!0)},open:function(a){var d=this;a=f.extend({},this.defaults,a);this.overlay?this.overlay.unbind(".overlay").width("auto").height("auto"):this.create(a);this.fixed||(n.bind("resize.overlay",f.proxy(this.update,this)),this.update());a.closeClick&&this.overlay.bind("click.overlay",function(a){if(f(a.target).hasClass("fancybox-overlay"))return b.isActive?
40
+ b.close():d.close(),!1});this.overlay.css(a.css).show()},close:function(){var a,b;n.unbind("resize.overlay");this.el.hasClass("fancybox-lock")&&(f(".fancybox-margin").removeClass("fancybox-margin"),a=n.scrollTop(),b=n.scrollLeft(),this.el.removeClass("fancybox-lock"),n.scrollTop(a).scrollLeft(b));f(".fancybox-overlay").remove().hide();f.extend(this,{overlay:null,fixed:!1})},update:function(){var a="100%",b;this.overlay.width(a).height("100%");I?(b=Math.max(G.documentElement.offsetWidth,G.body.offsetWidth),
41
+ p.width()>b&&(a=p.width())):p.width()>n.width()&&(a=p.width());this.overlay.width(a).height(p.height())},onReady:function(a,b){var e=this.overlay;f(".fancybox-overlay").stop(!0,!0);e||this.create(a);a.locked&&(this.fixed&&b.fixed)&&(e||(this.margin=p.height()>n.height()?f("html").css("margin-right").replace("px",""):!1),b.locked=this.overlay.append(b.wrap),b.fixed=!1);!0===a.showEarly&&this.beforeShow.apply(this,arguments)},beforeShow:function(a,b){var e,c;b.locked&&(!1!==this.margin&&(f("*").filter(function(){return"fixed"===
42
+ f(this).css("position")&&!f(this).hasClass("fancybox-overlay")&&!f(this).hasClass("fancybox-wrap")}).addClass("fancybox-margin"),this.el.addClass("fancybox-margin")),e=n.scrollTop(),c=n.scrollLeft(),this.el.addClass("fancybox-lock"),n.scrollTop(e).scrollLeft(c));this.open(a)},onUpdate:function(){this.fixed||this.update()},afterClose:function(a){this.overlay&&!b.coming&&this.overlay.fadeOut(a.speedOut,f.proxy(this.close,this))}};b.helpers.title={defaults:{type:"float",position:"bottom"},beforeShow:function(a){var d=
43
+ b.current,e=d.title,c=a.type;f.isFunction(e)&&(e=e.call(d.element,d));if(q(e)&&""!==f.trim(e)){d=f('<div class="fancybox-title fancybox-title-'+c+'-wrap">'+e+"</div>");switch(c){case "inside":c=b.skin;break;case "outside":c=b.wrap;break;case "over":c=b.inner;break;default:c=b.skin,d.appendTo("body"),I&&d.width(d.width()),d.wrapInner('<span class="child"></span>'),b.current.margin[2]+=Math.abs(l(d.css("margin-bottom")))}d["top"===a.position?"prependTo":"appendTo"](c)}}};f.fn.fancybox=function(a){var d,
44
+ e=f(this),c=this.selector||"",k=function(g){var h=f(this).blur(),j=d,k,l;!g.ctrlKey&&(!g.altKey&&!g.shiftKey&&!g.metaKey)&&!h.is(".fancybox-wrap")&&(k=a.groupAttr||"data-fancybox-group",l=h.attr(k),l||(k="rel",l=h.get(0)[k]),l&&(""!==l&&"nofollow"!==l)&&(h=c.length?f(c):e,h=h.filter("["+k+'="'+l+'"]'),j=h.index(this)),a.index=j,!1!==b.open(h,a)&&g.preventDefault())};a=a||{};d=a.index||0;!c||!1===a.live?e.unbind("click.fb-start").bind("click.fb-start",k):p.undelegate(c,"click.fb-start").delegate(c+
45
+ ":not('.fancybox-item, .fancybox-nav')","click.fb-start",k);this.filter("[data-fancybox-start=1]").trigger("click");return this};p.ready(function(){var a,d;f.scrollbarWidth===v&&(f.scrollbarWidth=function(){var a=f('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo("body"),b=a.children(),b=b.innerWidth()-b.height(99).innerWidth();a.remove();return b});if(f.support.fixedPosition===v){a=f.support;d=f('<div style="position:fixed;top:20px;"></div>').appendTo("body");var e=20===
46
+ d[0].offsetTop||15===d[0].offsetTop;d.remove();a.fixedPosition=e}f.extend(b.defaults,{scrollbarWidth:f.scrollbarWidth(),fixed:f.support.fixedPosition,parent:f("body")});a=f(r).width();J.addClass("fancybox-lock-test");d=f(r).width();J.removeClass("fancybox-lock-test");f("<style type='text/css'>.fancybox-margin{margin-right:"+(d-a)+"px;}</style>").appendTo("head")})})(window,document,jQuery);
@@ -0,0 +1,1183 @@
1
+ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
+ (function() {
3
+ var Connector, PROTOCOL_6, PROTOCOL_7, Parser, Version, _ref;
4
+
5
+ _ref = require('./protocol'), Parser = _ref.Parser, PROTOCOL_6 = _ref.PROTOCOL_6, PROTOCOL_7 = _ref.PROTOCOL_7;
6
+
7
+ Version = '2.2.2';
8
+
9
+ exports.Connector = Connector = (function() {
10
+ function Connector(options, WebSocket, Timer, handlers) {
11
+ this.options = options;
12
+ this.WebSocket = WebSocket;
13
+ this.Timer = Timer;
14
+ this.handlers = handlers;
15
+ this._uri = "ws" + (this.options.https ? "s" : "") + "://" + this.options.host + ":" + this.options.port + "/livereload";
16
+ this._nextDelay = this.options.mindelay;
17
+ this._connectionDesired = false;
18
+ this.protocol = 0;
19
+ this.protocolParser = new Parser({
20
+ connected: (function(_this) {
21
+ return function(protocol) {
22
+ _this.protocol = protocol;
23
+ _this._handshakeTimeout.stop();
24
+ _this._nextDelay = _this.options.mindelay;
25
+ _this._disconnectionReason = 'broken';
26
+ return _this.handlers.connected(protocol);
27
+ };
28
+ })(this),
29
+ error: (function(_this) {
30
+ return function(e) {
31
+ _this.handlers.error(e);
32
+ return _this._closeOnError();
33
+ };
34
+ })(this),
35
+ message: (function(_this) {
36
+ return function(message) {
37
+ return _this.handlers.message(message);
38
+ };
39
+ })(this)
40
+ });
41
+ this._handshakeTimeout = new Timer((function(_this) {
42
+ return function() {
43
+ if (!_this._isSocketConnected()) {
44
+ return;
45
+ }
46
+ _this._disconnectionReason = 'handshake-timeout';
47
+ return _this.socket.close();
48
+ };
49
+ })(this));
50
+ this._reconnectTimer = new Timer((function(_this) {
51
+ return function() {
52
+ if (!_this._connectionDesired) {
53
+ return;
54
+ }
55
+ return _this.connect();
56
+ };
57
+ })(this));
58
+ this.connect();
59
+ }
60
+
61
+ Connector.prototype._isSocketConnected = function() {
62
+ return this.socket && this.socket.readyState === this.WebSocket.OPEN;
63
+ };
64
+
65
+ Connector.prototype.connect = function() {
66
+ this._connectionDesired = true;
67
+ if (this._isSocketConnected()) {
68
+ return;
69
+ }
70
+ this._reconnectTimer.stop();
71
+ this._disconnectionReason = 'cannot-connect';
72
+ this.protocolParser.reset();
73
+ this.handlers.connecting();
74
+ this.socket = new this.WebSocket(this._uri);
75
+ this.socket.onopen = (function(_this) {
76
+ return function(e) {
77
+ return _this._onopen(e);
78
+ };
79
+ })(this);
80
+ this.socket.onclose = (function(_this) {
81
+ return function(e) {
82
+ return _this._onclose(e);
83
+ };
84
+ })(this);
85
+ this.socket.onmessage = (function(_this) {
86
+ return function(e) {
87
+ return _this._onmessage(e);
88
+ };
89
+ })(this);
90
+ return this.socket.onerror = (function(_this) {
91
+ return function(e) {
92
+ return _this._onerror(e);
93
+ };
94
+ })(this);
95
+ };
96
+
97
+ Connector.prototype.disconnect = function() {
98
+ this._connectionDesired = false;
99
+ this._reconnectTimer.stop();
100
+ if (!this._isSocketConnected()) {
101
+ return;
102
+ }
103
+ this._disconnectionReason = 'manual';
104
+ return this.socket.close();
105
+ };
106
+
107
+ Connector.prototype._scheduleReconnection = function() {
108
+ if (!this._connectionDesired) {
109
+ return;
110
+ }
111
+ if (!this._reconnectTimer.running) {
112
+ this._reconnectTimer.start(this._nextDelay);
113
+ return this._nextDelay = Math.min(this.options.maxdelay, this._nextDelay * 2);
114
+ }
115
+ };
116
+
117
+ Connector.prototype.sendCommand = function(command) {
118
+ if (this.protocol == null) {
119
+ return;
120
+ }
121
+ return this._sendCommand(command);
122
+ };
123
+
124
+ Connector.prototype._sendCommand = function(command) {
125
+ return this.socket.send(JSON.stringify(command));
126
+ };
127
+
128
+ Connector.prototype._closeOnError = function() {
129
+ this._handshakeTimeout.stop();
130
+ this._disconnectionReason = 'error';
131
+ return this.socket.close();
132
+ };
133
+
134
+ Connector.prototype._onopen = function(e) {
135
+ var hello;
136
+ this.handlers.socketConnected();
137
+ this._disconnectionReason = 'handshake-failed';
138
+ hello = {
139
+ command: 'hello',
140
+ protocols: [PROTOCOL_6, PROTOCOL_7]
141
+ };
142
+ hello.ver = Version;
143
+ if (this.options.ext) {
144
+ hello.ext = this.options.ext;
145
+ }
146
+ if (this.options.extver) {
147
+ hello.extver = this.options.extver;
148
+ }
149
+ if (this.options.snipver) {
150
+ hello.snipver = this.options.snipver;
151
+ }
152
+ this._sendCommand(hello);
153
+ return this._handshakeTimeout.start(this.options.handshake_timeout);
154
+ };
155
+
156
+ Connector.prototype._onclose = function(e) {
157
+ this.protocol = 0;
158
+ this.handlers.disconnected(this._disconnectionReason, this._nextDelay);
159
+ return this._scheduleReconnection();
160
+ };
161
+
162
+ Connector.prototype._onerror = function(e) {};
163
+
164
+ Connector.prototype._onmessage = function(e) {
165
+ return this.protocolParser.process(e.data);
166
+ };
167
+
168
+ return Connector;
169
+
170
+ })();
171
+
172
+ }).call(this);
173
+
174
+ },{"./protocol":6}],2:[function(require,module,exports){
175
+ (function() {
176
+ var CustomEvents;
177
+
178
+ CustomEvents = {
179
+ bind: function(element, eventName, handler) {
180
+ if (element.addEventListener) {
181
+ return element.addEventListener(eventName, handler, false);
182
+ } else if (element.attachEvent) {
183
+ element[eventName] = 1;
184
+ return element.attachEvent('onpropertychange', function(event) {
185
+ if (event.propertyName === eventName) {
186
+ return handler();
187
+ }
188
+ });
189
+ } else {
190
+ throw new Error("Attempt to attach custom event " + eventName + " to something which isn't a DOMElement");
191
+ }
192
+ },
193
+ fire: function(element, eventName) {
194
+ var event;
195
+ if (element.addEventListener) {
196
+ event = document.createEvent('HTMLEvents');
197
+ event.initEvent(eventName, true, true);
198
+ return document.dispatchEvent(event);
199
+ } else if (element.attachEvent) {
200
+ if (element[eventName]) {
201
+ return element[eventName]++;
202
+ }
203
+ } else {
204
+ throw new Error("Attempt to fire custom event " + eventName + " on something which isn't a DOMElement");
205
+ }
206
+ }
207
+ };
208
+
209
+ exports.bind = CustomEvents.bind;
210
+
211
+ exports.fire = CustomEvents.fire;
212
+
213
+ }).call(this);
214
+
215
+ },{}],3:[function(require,module,exports){
216
+ (function() {
217
+ var LessPlugin;
218
+
219
+ module.exports = LessPlugin = (function() {
220
+ LessPlugin.identifier = 'less';
221
+
222
+ LessPlugin.version = '1.0';
223
+
224
+ function LessPlugin(window, host) {
225
+ this.window = window;
226
+ this.host = host;
227
+ }
228
+
229
+ LessPlugin.prototype.reload = function(path, options) {
230
+ if (this.window.less && this.window.less.refresh) {
231
+ if (path.match(/\.less$/i)) {
232
+ return this.reloadLess(path);
233
+ }
234
+ if (options.originalPath.match(/\.less$/i)) {
235
+ return this.reloadLess(options.originalPath);
236
+ }
237
+ }
238
+ return false;
239
+ };
240
+
241
+ LessPlugin.prototype.reloadLess = function(path) {
242
+ var link, links, _i, _len;
243
+ links = (function() {
244
+ var _i, _len, _ref, _results;
245
+ _ref = document.getElementsByTagName('link');
246
+ _results = [];
247
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
248
+ link = _ref[_i];
249
+ if (link.href && link.rel.match(/^stylesheet\/less$/i) || (link.rel.match(/stylesheet/i) && link.type.match(/^text\/(x-)?less$/i))) {
250
+ _results.push(link);
251
+ }
252
+ }
253
+ return _results;
254
+ })();
255
+ if (links.length === 0) {
256
+ return false;
257
+ }
258
+ for (_i = 0, _len = links.length; _i < _len; _i++) {
259
+ link = links[_i];
260
+ link.href = this.host.generateCacheBustUrl(link.href);
261
+ }
262
+ this.host.console.log("LiveReload is asking LESS to recompile all stylesheets");
263
+ this.window.less.refresh(true);
264
+ return true;
265
+ };
266
+
267
+ LessPlugin.prototype.analyze = function() {
268
+ return {
269
+ disable: !!(this.window.less && this.window.less.refresh)
270
+ };
271
+ };
272
+
273
+ return LessPlugin;
274
+
275
+ })();
276
+
277
+ }).call(this);
278
+
279
+ },{}],4:[function(require,module,exports){
280
+ (function() {
281
+ var Connector, LiveReload, Options, Reloader, Timer,
282
+ __hasProp = {}.hasOwnProperty;
283
+
284
+ Connector = require('./connector').Connector;
285
+
286
+ Timer = require('./timer').Timer;
287
+
288
+ Options = require('./options').Options;
289
+
290
+ Reloader = require('./reloader').Reloader;
291
+
292
+ exports.LiveReload = LiveReload = (function() {
293
+ function LiveReload(window) {
294
+ var k, v, _ref;
295
+ this.window = window;
296
+ this.listeners = {};
297
+ this.plugins = [];
298
+ this.pluginIdentifiers = {};
299
+ this.console = this.window.console && this.window.console.log && this.window.console.error ? this.window.location.href.match(/LR-verbose/) ? this.window.console : {
300
+ log: function() {},
301
+ error: this.window.console.error.bind(this.window.console)
302
+ } : {
303
+ log: function() {},
304
+ error: function() {}
305
+ };
306
+ if (!(this.WebSocket = this.window.WebSocket || this.window.MozWebSocket)) {
307
+ this.console.error("LiveReload disabled because the browser does not seem to support web sockets");
308
+ return;
309
+ }
310
+ if ('LiveReloadOptions' in window) {
311
+ this.options = new Options();
312
+ _ref = window['LiveReloadOptions'];
313
+ for (k in _ref) {
314
+ if (!__hasProp.call(_ref, k)) continue;
315
+ v = _ref[k];
316
+ this.options.set(k, v);
317
+ }
318
+ } else {
319
+ this.options = Options.extract(this.window.document);
320
+ if (!this.options) {
321
+ this.console.error("LiveReload disabled because it could not find its own <SCRIPT> tag");
322
+ return;
323
+ }
324
+ }
325
+ this.reloader = new Reloader(this.window, this.console, Timer);
326
+ this.connector = new Connector(this.options, this.WebSocket, Timer, {
327
+ connecting: (function(_this) {
328
+ return function() {};
329
+ })(this),
330
+ socketConnected: (function(_this) {
331
+ return function() {};
332
+ })(this),
333
+ connected: (function(_this) {
334
+ return function(protocol) {
335
+ var _base;
336
+ if (typeof (_base = _this.listeners).connect === "function") {
337
+ _base.connect();
338
+ }
339
+ _this.log("LiveReload is connected to " + _this.options.host + ":" + _this.options.port + " (protocol v" + protocol + ").");
340
+ return _this.analyze();
341
+ };
342
+ })(this),
343
+ error: (function(_this) {
344
+ return function(e) {
345
+ if (e instanceof ProtocolError) {
346
+ if (typeof console !== "undefined" && console !== null) {
347
+ return console.log("" + e.message + ".");
348
+ }
349
+ } else {
350
+ if (typeof console !== "undefined" && console !== null) {
351
+ return console.log("LiveReload internal error: " + e.message);
352
+ }
353
+ }
354
+ };
355
+ })(this),
356
+ disconnected: (function(_this) {
357
+ return function(reason, nextDelay) {
358
+ var _base;
359
+ if (typeof (_base = _this.listeners).disconnect === "function") {
360
+ _base.disconnect();
361
+ }
362
+ switch (reason) {
363
+ case 'cannot-connect':
364
+ return _this.log("LiveReload cannot connect to " + _this.options.host + ":" + _this.options.port + ", will retry in " + nextDelay + " sec.");
365
+ case 'broken':
366
+ return _this.log("LiveReload disconnected from " + _this.options.host + ":" + _this.options.port + ", reconnecting in " + nextDelay + " sec.");
367
+ case 'handshake-timeout':
368
+ return _this.log("LiveReload cannot connect to " + _this.options.host + ":" + _this.options.port + " (handshake timeout), will retry in " + nextDelay + " sec.");
369
+ case 'handshake-failed':
370
+ return _this.log("LiveReload cannot connect to " + _this.options.host + ":" + _this.options.port + " (handshake failed), will retry in " + nextDelay + " sec.");
371
+ case 'manual':
372
+ break;
373
+ case 'error':
374
+ break;
375
+ default:
376
+ return _this.log("LiveReload disconnected from " + _this.options.host + ":" + _this.options.port + " (" + reason + "), reconnecting in " + nextDelay + " sec.");
377
+ }
378
+ };
379
+ })(this),
380
+ message: (function(_this) {
381
+ return function(message) {
382
+ switch (message.command) {
383
+ case 'reload':
384
+ return _this.performReload(message);
385
+ case 'alert':
386
+ return _this.performAlert(message);
387
+ }
388
+ };
389
+ })(this)
390
+ });
391
+ this.initialized = true;
392
+ }
393
+
394
+ LiveReload.prototype.on = function(eventName, handler) {
395
+ return this.listeners[eventName] = handler;
396
+ };
397
+
398
+ LiveReload.prototype.log = function(message) {
399
+ return this.console.log("" + message);
400
+ };
401
+
402
+ LiveReload.prototype.performReload = function(message) {
403
+ var _ref, _ref1;
404
+ this.log("LiveReload received reload request: " + (JSON.stringify(message, null, 2)));
405
+ return this.reloader.reload(message.path, {
406
+ liveCSS: (_ref = message.liveCSS) != null ? _ref : true,
407
+ liveImg: (_ref1 = message.liveImg) != null ? _ref1 : true,
408
+ originalPath: message.originalPath || '',
409
+ overrideURL: message.overrideURL || '',
410
+ serverURL: "http://" + this.options.host + ":" + this.options.port
411
+ });
412
+ };
413
+
414
+ LiveReload.prototype.performAlert = function(message) {
415
+ return alert(message.message);
416
+ };
417
+
418
+ LiveReload.prototype.shutDown = function() {
419
+ var _base;
420
+ if (!this.initialized) {
421
+ return;
422
+ }
423
+ this.connector.disconnect();
424
+ this.log("LiveReload disconnected.");
425
+ return typeof (_base = this.listeners).shutdown === "function" ? _base.shutdown() : void 0;
426
+ };
427
+
428
+ LiveReload.prototype.hasPlugin = function(identifier) {
429
+ return !!this.pluginIdentifiers[identifier];
430
+ };
431
+
432
+ LiveReload.prototype.addPlugin = function(pluginClass) {
433
+ var plugin;
434
+ if (!this.initialized) {
435
+ return;
436
+ }
437
+ if (this.hasPlugin(pluginClass.identifier)) {
438
+ return;
439
+ }
440
+ this.pluginIdentifiers[pluginClass.identifier] = true;
441
+ plugin = new pluginClass(this.window, {
442
+ _livereload: this,
443
+ _reloader: this.reloader,
444
+ _connector: this.connector,
445
+ console: this.console,
446
+ Timer: Timer,
447
+ generateCacheBustUrl: (function(_this) {
448
+ return function(url) {
449
+ return _this.reloader.generateCacheBustUrl(url);
450
+ };
451
+ })(this)
452
+ });
453
+ this.plugins.push(plugin);
454
+ this.reloader.addPlugin(plugin);
455
+ };
456
+
457
+ LiveReload.prototype.analyze = function() {
458
+ var plugin, pluginData, pluginsData, _i, _len, _ref;
459
+ if (!this.initialized) {
460
+ return;
461
+ }
462
+ if (!(this.connector.protocol >= 7)) {
463
+ return;
464
+ }
465
+ pluginsData = {};
466
+ _ref = this.plugins;
467
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
468
+ plugin = _ref[_i];
469
+ pluginsData[plugin.constructor.identifier] = pluginData = (typeof plugin.analyze === "function" ? plugin.analyze() : void 0) || {};
470
+ pluginData.version = plugin.constructor.version;
471
+ }
472
+ this.connector.sendCommand({
473
+ command: 'info',
474
+ plugins: pluginsData,
475
+ url: this.window.location.href
476
+ });
477
+ };
478
+
479
+ return LiveReload;
480
+
481
+ })();
482
+
483
+ }).call(this);
484
+
485
+ },{"./connector":1,"./options":5,"./reloader":7,"./timer":9}],5:[function(require,module,exports){
486
+ (function() {
487
+ var Options;
488
+
489
+ exports.Options = Options = (function() {
490
+ function Options() {
491
+ this.https = false;
492
+ this.host = null;
493
+ this.port = 35729;
494
+ this.snipver = null;
495
+ this.ext = null;
496
+ this.extver = null;
497
+ this.mindelay = 1000;
498
+ this.maxdelay = 60000;
499
+ this.handshake_timeout = 5000;
500
+ }
501
+
502
+ Options.prototype.set = function(name, value) {
503
+ if (typeof value === 'undefined') {
504
+ return;
505
+ }
506
+ if (!isNaN(+value)) {
507
+ value = +value;
508
+ }
509
+ return this[name] = value;
510
+ };
511
+
512
+ return Options;
513
+
514
+ })();
515
+
516
+ Options.extract = function(document) {
517
+ var element, keyAndValue, m, mm, options, pair, src, _i, _j, _len, _len1, _ref, _ref1;
518
+ _ref = document.getElementsByTagName('script');
519
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
520
+ element = _ref[_i];
521
+ if ((src = element.src) && (m = src.match(/^[^:]+:\/\/(.*)\/z?livereload\.js(?:\?(.*))?$/))) {
522
+ options = new Options();
523
+ options.https = src.indexOf("https") === 0;
524
+ if (mm = m[1].match(/^([^\/:]+)(?::(\d+))?$/)) {
525
+ options.host = mm[1];
526
+ if (mm[2]) {
527
+ options.port = parseInt(mm[2], 10);
528
+ }
529
+ }
530
+ if (m[2]) {
531
+ _ref1 = m[2].split('&');
532
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
533
+ pair = _ref1[_j];
534
+ if ((keyAndValue = pair.split('=')).length > 1) {
535
+ options.set(keyAndValue[0].replace(/-/g, '_'), keyAndValue.slice(1).join('='));
536
+ }
537
+ }
538
+ }
539
+ return options;
540
+ }
541
+ }
542
+ return null;
543
+ };
544
+
545
+ }).call(this);
546
+
547
+ },{}],6:[function(require,module,exports){
548
+ (function() {
549
+ var PROTOCOL_6, PROTOCOL_7, Parser, ProtocolError,
550
+ __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
551
+
552
+ exports.PROTOCOL_6 = PROTOCOL_6 = 'http://livereload.com/protocols/official-6';
553
+
554
+ exports.PROTOCOL_7 = PROTOCOL_7 = 'http://livereload.com/protocols/official-7';
555
+
556
+ exports.ProtocolError = ProtocolError = (function() {
557
+ function ProtocolError(reason, data) {
558
+ this.message = "LiveReload protocol error (" + reason + ") after receiving data: \"" + data + "\".";
559
+ }
560
+
561
+ return ProtocolError;
562
+
563
+ })();
564
+
565
+ exports.Parser = Parser = (function() {
566
+ function Parser(handlers) {
567
+ this.handlers = handlers;
568
+ this.reset();
569
+ }
570
+
571
+ Parser.prototype.reset = function() {
572
+ return this.protocol = null;
573
+ };
574
+
575
+ Parser.prototype.process = function(data) {
576
+ var command, e, message, options, _ref;
577
+ try {
578
+ if (this.protocol == null) {
579
+ if (data.match(/^!!ver:([\d.]+)$/)) {
580
+ this.protocol = 6;
581
+ } else if (message = this._parseMessage(data, ['hello'])) {
582
+ if (!message.protocols.length) {
583
+ throw new ProtocolError("no protocols specified in handshake message");
584
+ } else if (__indexOf.call(message.protocols, PROTOCOL_7) >= 0) {
585
+ this.protocol = 7;
586
+ } else if (__indexOf.call(message.protocols, PROTOCOL_6) >= 0) {
587
+ this.protocol = 6;
588
+ } else {
589
+ throw new ProtocolError("no supported protocols found");
590
+ }
591
+ }
592
+ return this.handlers.connected(this.protocol);
593
+ } else if (this.protocol === 6) {
594
+ message = JSON.parse(data);
595
+ if (!message.length) {
596
+ throw new ProtocolError("protocol 6 messages must be arrays");
597
+ }
598
+ command = message[0], options = message[1];
599
+ if (command !== 'refresh') {
600
+ throw new ProtocolError("unknown protocol 6 command");
601
+ }
602
+ return this.handlers.message({
603
+ command: 'reload',
604
+ path: options.path,
605
+ liveCSS: (_ref = options.apply_css_live) != null ? _ref : true
606
+ });
607
+ } else {
608
+ message = this._parseMessage(data, ['reload', 'alert']);
609
+ return this.handlers.message(message);
610
+ }
611
+ } catch (_error) {
612
+ e = _error;
613
+ if (e instanceof ProtocolError) {
614
+ return this.handlers.error(e);
615
+ } else {
616
+ throw e;
617
+ }
618
+ }
619
+ };
620
+
621
+ Parser.prototype._parseMessage = function(data, validCommands) {
622
+ var e, message, _ref;
623
+ try {
624
+ message = JSON.parse(data);
625
+ } catch (_error) {
626
+ e = _error;
627
+ throw new ProtocolError('unparsable JSON', data);
628
+ }
629
+ if (!message.command) {
630
+ throw new ProtocolError('missing "command" key', data);
631
+ }
632
+ if (_ref = message.command, __indexOf.call(validCommands, _ref) < 0) {
633
+ throw new ProtocolError("invalid command '" + message.command + "', only valid commands are: " + (validCommands.join(', ')) + ")", data);
634
+ }
635
+ return message;
636
+ };
637
+
638
+ return Parser;
639
+
640
+ })();
641
+
642
+ }).call(this);
643
+
644
+ },{}],7:[function(require,module,exports){
645
+ (function() {
646
+ var IMAGE_STYLES, Reloader, numberOfMatchingSegments, pathFromUrl, pathsMatch, pickBestMatch, splitUrl;
647
+
648
+ splitUrl = function(url) {
649
+ var hash, index, params;
650
+ if ((index = url.indexOf('#')) >= 0) {
651
+ hash = url.slice(index);
652
+ url = url.slice(0, index);
653
+ } else {
654
+ hash = '';
655
+ }
656
+ if ((index = url.indexOf('?')) >= 0) {
657
+ params = url.slice(index);
658
+ url = url.slice(0, index);
659
+ } else {
660
+ params = '';
661
+ }
662
+ return {
663
+ url: url,
664
+ params: params,
665
+ hash: hash
666
+ };
667
+ };
668
+
669
+ pathFromUrl = function(url) {
670
+ var path;
671
+ url = splitUrl(url).url;
672
+ if (url.indexOf('file://') === 0) {
673
+ path = url.replace(/^file:\/\/(localhost)?/, '');
674
+ } else {
675
+ path = url.replace(/^([^:]+:)?\/\/([^:\/]+)(:\d*)?\//, '/');
676
+ }
677
+ return decodeURIComponent(path);
678
+ };
679
+
680
+ pickBestMatch = function(path, objects, pathFunc) {
681
+ var bestMatch, object, score, _i, _len;
682
+ bestMatch = {
683
+ score: 0
684
+ };
685
+ for (_i = 0, _len = objects.length; _i < _len; _i++) {
686
+ object = objects[_i];
687
+ score = numberOfMatchingSegments(path, pathFunc(object));
688
+ if (score > bestMatch.score) {
689
+ bestMatch = {
690
+ object: object,
691
+ score: score
692
+ };
693
+ }
694
+ }
695
+ if (bestMatch.score > 0) {
696
+ return bestMatch;
697
+ } else {
698
+ return null;
699
+ }
700
+ };
701
+
702
+ numberOfMatchingSegments = function(path1, path2) {
703
+ var comps1, comps2, eqCount, len;
704
+ path1 = path1.replace(/^\/+/, '').toLowerCase();
705
+ path2 = path2.replace(/^\/+/, '').toLowerCase();
706
+ if (path1 === path2) {
707
+ return 10000;
708
+ }
709
+ comps1 = path1.split('/').reverse();
710
+ comps2 = path2.split('/').reverse();
711
+ len = Math.min(comps1.length, comps2.length);
712
+ eqCount = 0;
713
+ while (eqCount < len && comps1[eqCount] === comps2[eqCount]) {
714
+ ++eqCount;
715
+ }
716
+ return eqCount;
717
+ };
718
+
719
+ pathsMatch = function(path1, path2) {
720
+ return numberOfMatchingSegments(path1, path2) > 0;
721
+ };
722
+
723
+ IMAGE_STYLES = [
724
+ {
725
+ selector: 'background',
726
+ styleNames: ['backgroundImage']
727
+ }, {
728
+ selector: 'border',
729
+ styleNames: ['borderImage', 'webkitBorderImage', 'MozBorderImage']
730
+ }
731
+ ];
732
+
733
+ exports.Reloader = Reloader = (function() {
734
+ function Reloader(window, console, Timer) {
735
+ this.window = window;
736
+ this.console = console;
737
+ this.Timer = Timer;
738
+ this.document = this.window.document;
739
+ this.importCacheWaitPeriod = 200;
740
+ this.plugins = [];
741
+ }
742
+
743
+ Reloader.prototype.addPlugin = function(plugin) {
744
+ return this.plugins.push(plugin);
745
+ };
746
+
747
+ Reloader.prototype.analyze = function(callback) {
748
+ return results;
749
+ };
750
+
751
+ Reloader.prototype.reload = function(path, options) {
752
+ var plugin, _base, _i, _len, _ref;
753
+ this.options = options;
754
+ if ((_base = this.options).stylesheetReloadTimeout == null) {
755
+ _base.stylesheetReloadTimeout = 15000;
756
+ }
757
+ _ref = this.plugins;
758
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
759
+ plugin = _ref[_i];
760
+ if (plugin.reload && plugin.reload(path, options)) {
761
+ return;
762
+ }
763
+ }
764
+ if (options.liveCSS) {
765
+ if (path.match(/\.css$/i)) {
766
+ if (this.reloadStylesheet(path)) {
767
+ return;
768
+ }
769
+ }
770
+ }
771
+ if (options.liveImg) {
772
+ if (path.match(/\.(jpe?g|png|gif)$/i)) {
773
+ this.reloadImages(path);
774
+ return;
775
+ }
776
+ }
777
+ return this.reloadPage();
778
+ };
779
+
780
+ Reloader.prototype.reloadPage = function() {
781
+ return this.window.document.location.reload();
782
+ };
783
+
784
+ Reloader.prototype.reloadImages = function(path) {
785
+ var expando, img, selector, styleNames, styleSheet, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3, _results;
786
+ expando = this.generateUniqueString();
787
+ _ref = this.document.images;
788
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
789
+ img = _ref[_i];
790
+ if (pathsMatch(path, pathFromUrl(img.src))) {
791
+ img.src = this.generateCacheBustUrl(img.src, expando);
792
+ }
793
+ }
794
+ if (this.document.querySelectorAll) {
795
+ for (_j = 0, _len1 = IMAGE_STYLES.length; _j < _len1; _j++) {
796
+ _ref1 = IMAGE_STYLES[_j], selector = _ref1.selector, styleNames = _ref1.styleNames;
797
+ _ref2 = this.document.querySelectorAll("[style*=" + selector + "]");
798
+ for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
799
+ img = _ref2[_k];
800
+ this.reloadStyleImages(img.style, styleNames, path, expando);
801
+ }
802
+ }
803
+ }
804
+ if (this.document.styleSheets) {
805
+ _ref3 = this.document.styleSheets;
806
+ _results = [];
807
+ for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
808
+ styleSheet = _ref3[_l];
809
+ _results.push(this.reloadStylesheetImages(styleSheet, path, expando));
810
+ }
811
+ return _results;
812
+ }
813
+ };
814
+
815
+ Reloader.prototype.reloadStylesheetImages = function(styleSheet, path, expando) {
816
+ var e, rule, rules, styleNames, _i, _j, _len, _len1;
817
+ try {
818
+ rules = styleSheet != null ? styleSheet.cssRules : void 0;
819
+ } catch (_error) {
820
+ e = _error;
821
+ }
822
+ if (!rules) {
823
+ return;
824
+ }
825
+ for (_i = 0, _len = rules.length; _i < _len; _i++) {
826
+ rule = rules[_i];
827
+ switch (rule.type) {
828
+ case CSSRule.IMPORT_RULE:
829
+ this.reloadStylesheetImages(rule.styleSheet, path, expando);
830
+ break;
831
+ case CSSRule.STYLE_RULE:
832
+ for (_j = 0, _len1 = IMAGE_STYLES.length; _j < _len1; _j++) {
833
+ styleNames = IMAGE_STYLES[_j].styleNames;
834
+ this.reloadStyleImages(rule.style, styleNames, path, expando);
835
+ }
836
+ break;
837
+ case CSSRule.MEDIA_RULE:
838
+ this.reloadStylesheetImages(rule, path, expando);
839
+ }
840
+ }
841
+ };
842
+
843
+ Reloader.prototype.reloadStyleImages = function(style, styleNames, path, expando) {
844
+ var newValue, styleName, value, _i, _len;
845
+ for (_i = 0, _len = styleNames.length; _i < _len; _i++) {
846
+ styleName = styleNames[_i];
847
+ value = style[styleName];
848
+ if (typeof value === 'string') {
849
+ newValue = value.replace(/\burl\s*\(([^)]*)\)/, (function(_this) {
850
+ return function(match, src) {
851
+ if (pathsMatch(path, pathFromUrl(src))) {
852
+ return "url(" + (_this.generateCacheBustUrl(src, expando)) + ")";
853
+ } else {
854
+ return match;
855
+ }
856
+ };
857
+ })(this));
858
+ if (newValue !== value) {
859
+ style[styleName] = newValue;
860
+ }
861
+ }
862
+ }
863
+ };
864
+
865
+ Reloader.prototype.reloadStylesheet = function(path) {
866
+ var imported, link, links, match, style, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1;
867
+ links = (function() {
868
+ var _i, _len, _ref, _results;
869
+ _ref = this.document.getElementsByTagName('link');
870
+ _results = [];
871
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
872
+ link = _ref[_i];
873
+ if (link.rel.match(/^stylesheet$/i) && !link.__LiveReload_pendingRemoval) {
874
+ _results.push(link);
875
+ }
876
+ }
877
+ return _results;
878
+ }).call(this);
879
+ imported = [];
880
+ _ref = this.document.getElementsByTagName('style');
881
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
882
+ style = _ref[_i];
883
+ if (style.sheet) {
884
+ this.collectImportedStylesheets(style, style.sheet, imported);
885
+ }
886
+ }
887
+ for (_j = 0, _len1 = links.length; _j < _len1; _j++) {
888
+ link = links[_j];
889
+ this.collectImportedStylesheets(link, link.sheet, imported);
890
+ }
891
+ if (this.window.StyleFix && this.document.querySelectorAll) {
892
+ _ref1 = this.document.querySelectorAll('style[data-href]');
893
+ for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
894
+ style = _ref1[_k];
895
+ links.push(style);
896
+ }
897
+ }
898
+ this.console.log("LiveReload found " + links.length + " LINKed stylesheets, " + imported.length + " @imported stylesheets");
899
+ match = pickBestMatch(path, links.concat(imported), (function(_this) {
900
+ return function(l) {
901
+ return pathFromUrl(_this.linkHref(l));
902
+ };
903
+ })(this));
904
+ if (match) {
905
+ if (match.object.rule) {
906
+ this.console.log("LiveReload is reloading imported stylesheet: " + match.object.href);
907
+ this.reattachImportedRule(match.object);
908
+ } else {
909
+ this.console.log("LiveReload is reloading stylesheet: " + (this.linkHref(match.object)));
910
+ this.reattachStylesheetLink(match.object);
911
+ }
912
+ } else {
913
+ this.console.log("LiveReload will reload all stylesheets because path '" + path + "' did not match any specific one");
914
+ for (_l = 0, _len3 = links.length; _l < _len3; _l++) {
915
+ link = links[_l];
916
+ this.reattachStylesheetLink(link);
917
+ }
918
+ }
919
+ return true;
920
+ };
921
+
922
+ Reloader.prototype.collectImportedStylesheets = function(link, styleSheet, result) {
923
+ var e, index, rule, rules, _i, _len;
924
+ try {
925
+ rules = styleSheet != null ? styleSheet.cssRules : void 0;
926
+ } catch (_error) {
927
+ e = _error;
928
+ }
929
+ if (rules && rules.length) {
930
+ for (index = _i = 0, _len = rules.length; _i < _len; index = ++_i) {
931
+ rule = rules[index];
932
+ switch (rule.type) {
933
+ case CSSRule.CHARSET_RULE:
934
+ continue;
935
+ case CSSRule.IMPORT_RULE:
936
+ result.push({
937
+ link: link,
938
+ rule: rule,
939
+ index: index,
940
+ href: rule.href
941
+ });
942
+ this.collectImportedStylesheets(link, rule.styleSheet, result);
943
+ break;
944
+ default:
945
+ break;
946
+ }
947
+ }
948
+ }
949
+ };
950
+
951
+ Reloader.prototype.waitUntilCssLoads = function(clone, func) {
952
+ var callbackExecuted, executeCallback, poll;
953
+ callbackExecuted = false;
954
+ executeCallback = (function(_this) {
955
+ return function() {
956
+ if (callbackExecuted) {
957
+ return;
958
+ }
959
+ callbackExecuted = true;
960
+ return func();
961
+ };
962
+ })(this);
963
+ clone.onload = (function(_this) {
964
+ return function() {
965
+ _this.console.log("LiveReload: the new stylesheet has finished loading");
966
+ _this.knownToSupportCssOnLoad = true;
967
+ return executeCallback();
968
+ };
969
+ })(this);
970
+ if (!this.knownToSupportCssOnLoad) {
971
+ (poll = (function(_this) {
972
+ return function() {
973
+ if (clone.sheet) {
974
+ _this.console.log("LiveReload is polling until the new CSS finishes loading...");
975
+ return executeCallback();
976
+ } else {
977
+ return _this.Timer.start(50, poll);
978
+ }
979
+ };
980
+ })(this))();
981
+ }
982
+ return this.Timer.start(this.options.stylesheetReloadTimeout, executeCallback);
983
+ };
984
+
985
+ Reloader.prototype.linkHref = function(link) {
986
+ return link.href || link.getAttribute('data-href');
987
+ };
988
+
989
+ Reloader.prototype.reattachStylesheetLink = function(link) {
990
+ var clone, parent;
991
+ if (link.__LiveReload_pendingRemoval) {
992
+ return;
993
+ }
994
+ link.__LiveReload_pendingRemoval = true;
995
+ if (link.tagName === 'STYLE') {
996
+ clone = this.document.createElement('link');
997
+ clone.rel = 'stylesheet';
998
+ clone.media = link.media;
999
+ clone.disabled = link.disabled;
1000
+ } else {
1001
+ clone = link.cloneNode(false);
1002
+ }
1003
+ clone.href = this.generateCacheBustUrl(this.linkHref(link));
1004
+ parent = link.parentNode;
1005
+ if (parent.lastChild === link) {
1006
+ parent.appendChild(clone);
1007
+ } else {
1008
+ parent.insertBefore(clone, link.nextSibling);
1009
+ }
1010
+ return this.waitUntilCssLoads(clone, (function(_this) {
1011
+ return function() {
1012
+ var additionalWaitingTime;
1013
+ if (/AppleWebKit/.test(navigator.userAgent)) {
1014
+ additionalWaitingTime = 5;
1015
+ } else {
1016
+ additionalWaitingTime = 200;
1017
+ }
1018
+ return _this.Timer.start(additionalWaitingTime, function() {
1019
+ var _ref;
1020
+ if (!link.parentNode) {
1021
+ return;
1022
+ }
1023
+ link.parentNode.removeChild(link);
1024
+ clone.onreadystatechange = null;
1025
+ return (_ref = _this.window.StyleFix) != null ? _ref.link(clone) : void 0;
1026
+ });
1027
+ };
1028
+ })(this));
1029
+ };
1030
+
1031
+ Reloader.prototype.reattachImportedRule = function(_arg) {
1032
+ var href, index, link, media, newRule, parent, rule, tempLink;
1033
+ rule = _arg.rule, index = _arg.index, link = _arg.link;
1034
+ parent = rule.parentStyleSheet;
1035
+ href = this.generateCacheBustUrl(rule.href);
1036
+ media = rule.media.length ? [].join.call(rule.media, ', ') : '';
1037
+ newRule = "@import url(\"" + href + "\") " + media + ";";
1038
+ rule.__LiveReload_newHref = href;
1039
+ tempLink = this.document.createElement("link");
1040
+ tempLink.rel = 'stylesheet';
1041
+ tempLink.href = href;
1042
+ tempLink.__LiveReload_pendingRemoval = true;
1043
+ if (link.parentNode) {
1044
+ link.parentNode.insertBefore(tempLink, link);
1045
+ }
1046
+ return this.Timer.start(this.importCacheWaitPeriod, (function(_this) {
1047
+ return function() {
1048
+ if (tempLink.parentNode) {
1049
+ tempLink.parentNode.removeChild(tempLink);
1050
+ }
1051
+ if (rule.__LiveReload_newHref !== href) {
1052
+ return;
1053
+ }
1054
+ parent.insertRule(newRule, index);
1055
+ parent.deleteRule(index + 1);
1056
+ rule = parent.cssRules[index];
1057
+ rule.__LiveReload_newHref = href;
1058
+ return _this.Timer.start(_this.importCacheWaitPeriod, function() {
1059
+ if (rule.__LiveReload_newHref !== href) {
1060
+ return;
1061
+ }
1062
+ parent.insertRule(newRule, index);
1063
+ return parent.deleteRule(index + 1);
1064
+ });
1065
+ };
1066
+ })(this));
1067
+ };
1068
+
1069
+ Reloader.prototype.generateUniqueString = function() {
1070
+ return 'livereload=' + Date.now();
1071
+ };
1072
+
1073
+ Reloader.prototype.generateCacheBustUrl = function(url, expando) {
1074
+ var hash, oldParams, originalUrl, params, _ref;
1075
+ if (expando == null) {
1076
+ expando = this.generateUniqueString();
1077
+ }
1078
+ _ref = splitUrl(url), url = _ref.url, hash = _ref.hash, oldParams = _ref.params;
1079
+ if (this.options.overrideURL) {
1080
+ if (url.indexOf(this.options.serverURL) < 0) {
1081
+ originalUrl = url;
1082
+ url = this.options.serverURL + this.options.overrideURL + "?url=" + encodeURIComponent(url);
1083
+ this.console.log("LiveReload is overriding source URL " + originalUrl + " with " + url);
1084
+ }
1085
+ }
1086
+ params = oldParams.replace(/(\?|&)livereload=(\d+)/, function(match, sep) {
1087
+ return "" + sep + expando;
1088
+ });
1089
+ if (params === oldParams) {
1090
+ if (oldParams.length === 0) {
1091
+ params = "?" + expando;
1092
+ } else {
1093
+ params = "" + oldParams + "&" + expando;
1094
+ }
1095
+ }
1096
+ return url + params + hash;
1097
+ };
1098
+
1099
+ return Reloader;
1100
+
1101
+ })();
1102
+
1103
+ }).call(this);
1104
+
1105
+ },{}],8:[function(require,module,exports){
1106
+ (function() {
1107
+ var CustomEvents, LiveReload, k;
1108
+
1109
+ CustomEvents = require('./customevents');
1110
+
1111
+ LiveReload = window.LiveReload = new (require('./livereload').LiveReload)(window);
1112
+
1113
+ for (k in window) {
1114
+ if (k.match(/^LiveReloadPlugin/)) {
1115
+ LiveReload.addPlugin(window[k]);
1116
+ }
1117
+ }
1118
+
1119
+ LiveReload.addPlugin(require('./less'));
1120
+
1121
+ LiveReload.on('shutdown', function() {
1122
+ return delete window.LiveReload;
1123
+ });
1124
+
1125
+ LiveReload.on('connect', function() {
1126
+ return CustomEvents.fire(document, 'LiveReloadConnect');
1127
+ });
1128
+
1129
+ LiveReload.on('disconnect', function() {
1130
+ return CustomEvents.fire(document, 'LiveReloadDisconnect');
1131
+ });
1132
+
1133
+ CustomEvents.bind(document, 'LiveReloadShutDown', function() {
1134
+ return LiveReload.shutDown();
1135
+ });
1136
+
1137
+ }).call(this);
1138
+
1139
+ },{"./customevents":2,"./less":3,"./livereload":4}],9:[function(require,module,exports){
1140
+ (function() {
1141
+ var Timer;
1142
+
1143
+ exports.Timer = Timer = (function() {
1144
+ function Timer(func) {
1145
+ this.func = func;
1146
+ this.running = false;
1147
+ this.id = null;
1148
+ this._handler = (function(_this) {
1149
+ return function() {
1150
+ _this.running = false;
1151
+ _this.id = null;
1152
+ return _this.func();
1153
+ };
1154
+ })(this);
1155
+ }
1156
+
1157
+ Timer.prototype.start = function(timeout) {
1158
+ if (this.running) {
1159
+ clearTimeout(this.id);
1160
+ }
1161
+ this.id = setTimeout(this._handler, timeout);
1162
+ return this.running = true;
1163
+ };
1164
+
1165
+ Timer.prototype.stop = function() {
1166
+ if (this.running) {
1167
+ clearTimeout(this.id);
1168
+ this.running = false;
1169
+ return this.id = null;
1170
+ }
1171
+ };
1172
+
1173
+ return Timer;
1174
+
1175
+ })();
1176
+
1177
+ Timer.start = function(timeout, func) {
1178
+ return setTimeout(func, timeout);
1179
+ };
1180
+
1181
+ }).call(this);
1182
+
1183
+ },{}]},{},[8]);