planit-rails 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 639bec399a0b8d7beaae2b2e693ce26823e14126
4
- data.tar.gz: 7e65e0839abaac96d79021e493470f897628841d
3
+ metadata.gz: 85d62ca544c161bac5763f1bf6b429edc30ac5cb
4
+ data.tar.gz: 08e092d1b46bda133a9e81a699abd995c34803a7
5
5
  SHA512:
6
- metadata.gz: 2df62e44c5bfb6729e2a545314783e52f557444ad6e75a7de27e25ab40d7c32611e6ecb89ad53cd77c1fce4e73f7bfc11f2b7613b43911796ecbf56782a5b416
7
- data.tar.gz: 17fdd4c3c3f730ae210f5f93be4297c31b77954070a701b797524d8a93d8c03b8fc03d11c3918eddf40e735e6e3819379d85b6de9c273c74ccd672b7308a23ff
6
+ metadata.gz: e84c0a1e0213525d20d6d177e21755ad9f238fe744bf1f31a7c4d7980cf8fe0cf4dac02a7e7b616774dcc0d394df7dddb1da6e9ad0aa5cc96ced073987871065
7
+ data.tar.gz: f848c4ed57d23d6b2acc682b16f95a6eadacd417490a927044030de32ca41496724755af5957562e7c463d9bdc3d59bf960314567867e6f18ea0d652e0286e84
@@ -1,5 +1,5 @@
1
1
  module Planit
2
2
  module Rails
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -1 +1 @@
1
- var Planit,__bind=function(t,n){return function(){return t.apply(n,arguments)}};Planit=function(){function t(){this.initMarkers=__bind(this.initMarkers,this)}return t.prototype["new"]=function(t){return this.options=t,this.options||(this.options={}),this.setOptions(),this.initPlan(),$(window).load(this.initMarkers)},t.prototype.setOptions=function(){return this.setDefaultOptions(),this.options.container&&(this.planOptions.container=$("#"+this.options.container)),this.options.backgroundImage?this.planOptions.backgroundImage=this.options.backgroundImage:void 0},t.prototype.setDefaultOptions=function(){return this.planOptions={container:$("#planit")}},t.prototype.initPlan=function(){return this.plan=new t.Plan(this.planOptions)},t.prototype.initMarkers=function(){var n,i,r,o,a;for(this.markers=new t.Marker({plan:this.planOptions.container}),o=this.options.markers,a=[],i=0,r=o.length;r>i;i++)n=o[i],a.push(this.markers.add(n));return a},t}(),window.planit=new Planit,Planit.Plan=function(){function t(t){this.options=t,this.initContainers(),this.options.backgroundImage&&this.addBackgroundImage()}return t.prototype.initContainers=function(){return this.options.container.addClass("planit-container"),this.options.container.append('<div class="planit-markers-container"></div>')},t.prototype.addBackgroundImage=function(){return this.options.container.append('<img src="'+this.options.backgroundImage+'">'),this.options.container.find(".planit-markers-container").css({backgroundImage:"url('"+this.options.backgroundImage+"')"}),$(window).load(function(t){return function(){return t.options.container.css({height:t.options.container.find("img").first().height()}),t.options.container.find("img").first().remove()}}(this))},t}(),Planit.Marker=function(){function t(t){this.options=t,this.mousemove=__bind(this.mousemove,this),this.mouseup=__bind(this.mouseup,this),this.mousedown=__bind(this.mousedown,this),this.setOptions(),this.bindDraggable()}return t.prototype.setOptions=function(){return this.plan=this.options.plan,this.markersContainer=this.plan.find(".planit-markers-container")},t.prototype.add=function(t){var n,i;return this.markersContainer.append($('<div><div class="planit-marker-content"></div></div>').addClass("planit-marker").css({left:t.coords[0]+"%",top:t.coords[1]+"%"})),t.draggable&&(this.lastMarker().addClass("draggable"),this.lastMarker().on("mousedown",this.mousedown)),t.infobox?(n=this.randomString(16),this.lastMarker().find(".planit-marker-content").append('<div class="planit-infobox" id="info-'+n+'">'+t.infobox+"</div>"),this.lastMarker().attr("data-infobox","info-"+n),i=$("#"+this.lastMarker().attr("data-infobox")),i.css({left:-(i.width()/2),bottom:i.outerHeight()+5}),this.lastMarker().on("mouseleave",function(){return function(t){var n;return n=$(t.target).closest(".planit-marker"),i=$("#"+n.attr("data-infobox")),i.removeClass("active")}}(this)),this.lastMarker().on("mouseover",function(t){return function(n){var r;return r=$(n.target).closest(".planit-marker"),i=$("#"+r.attr("data-infobox")),r.hasClass("is-dragging")||t.draggingMarker().length>0?i.removeClass("active"):i.addClass("active")}}(this))):void 0},t.prototype.mousedown=function(t){var n,i;return i=$(t.target).closest(".planit-marker"),i.addClass("is-dragging"),n=$(t.target).closest(".planit-marker").attr("data-infobox"),$("#"+n).removeClass("active")},t.prototype.mouseup=function(t){var n;return $(t.target).hasClass("planit-marker-content")&&(n=$(t.target).closest(".planit-marker"),$("#"+n.attr("data-infobox")).addClass("active")),this.draggingMarker().removeClass("is-dragging")},t.prototype.mousemove=function(t){var n,i,r,o,a,s,e,p,u,d,h,l,c,g;return d=this.markersContainer.find(".planit-marker.is-dragging"),d.length>0?(n=d.first(),h=t.pageX-this.plan.offset().left,l=t.pageY-this.plan.offset().top,g=this.plan.width(),c=this.plan.height(),o=h-n.outerWidth()/2,s=l-n.outerHeight()/2,a=h+n.outerWidth()/2,i=l+n.outerHeight()/2,e=n.outerWidth(),r=n.outerHeight(),p=0>=o?0:g>a?o:g-e,u=0>=s?0:c>i?s:c-r,n.css({left:p,top:u})):void 0},t.prototype.bindDraggable=function(){return $(document).on("mousemove",this.mousemove),$(document).on("mouseup",this.mouseup)},t.prototype.markers=function(){return this.markersContainer.find(".planit-marker")},t.prototype.draggingMarker=function(){return this.markersContainer.find(".planit-marker.is-dragging")},t.prototype.lastMarker=function(){return this.markers().last()},t.prototype.randomString=function(t){var n;return null==t&&(t=16),n=Math.random().toString(36).slice(2),n+=Math.random().toString(36).slice(2),n.substring(0,t-1)},t}();
1
+ var Planit,__bind=function(t,r){return function(){return t.apply(r,arguments)}};Planit=function(){function t(){this.dragEnd=__bind(this.dragEnd,this),this.getAllMarkers=__bind(this.getAllMarkers,this),this.getMarker=__bind(this.getMarker,this),this.addMarker=__bind(this.addMarker,this)}return t.containerClass="planit-container",t.markerContainerClass="planit-markers-container",t.markerClass="planit-marker",t.markerContentClass="planit-marker-content",t.prototype["new"]=function(r){return this.options=null!=r?r:{},this.options.container=$(this.options.container?"#"+this.options.container:"#planit"),this.options.container.addClass("planit-container"),this.options.container.append('<div class="'+t.markerContainerClass+'"></div>'),this.container=this.options.container,this.markersContainer=this.container.find("."+t.markerContainerClass).first(),this.options.backgroundImage&&(this.container.append('<img src="'+this.options.backgroundImage+'">'),this.markersContainer.css({backgroundImage:"url('"+this.options.backgroundImage+"')"}),$(window).load(function(t){return function(){return t.container.css({height:t.container.find("img").first().height()}),t.container.find("img").first().remove()}}(this))),this.options.markers&&$(window).load(function(t){return function(){var r,i,n,a,o;for(a=t.options.markers,o=[],i=0,n=a.length;n>i;i++)r=a[i],o.push(t.addMarker(r));return o}}(this)),new t.Plan.Events({container:this.container,planit:this}),this},t.prototype.addMarker=function(r){return r.container=this.container,new t.Marker.Creator(r)},t.prototype.getMarker=function(r){return new t.Marker(this.container,r)},t.prototype.getAllMarkers=function(){var r;return r=new t.Plan(this.container),r.getAllMarkers()},t.prototype.dragEnd=function(t,r){return this.options.dragEnd?this.options.dragEnd(t,r):void 0},t.randomString=function(t){var r;return null==t&&(t=16),r=Math.random().toString(36).slice(2),r+=Math.random().toString(36).slice(2),r.substring(0,t-1)},t}(),window.planit=new Planit,Planit.Plan=function(){function t(t){this.container=t,this.getAllMarkers=__bind(this.getAllMarkers,this),this.markersContainer=this.container.find("."+Planit.markerContainerClass).first()}return t.prototype.getAllMarkers=function(){var t,r,i,n,a,o;for(i=[],o=this.markersContainer.find(".planit-marker"),n=0,a=o.length;a>n;n++)r=o[n],t=new Planit.Marker(this.container,$(r).attr("data-marker")),r={coords:t.position(),draggable:t.isDraggable(),color:t.color()},t.infoboxHTML()&&(r.infobox=t.infoboxHTML()),i.push(r);return i},t}(),Planit.Plan.Events=function(){function t(t){this.options=t,this.mousemove=__bind(this.mousemove,this),this.mouseup=__bind(this.mouseup,this),this.lastMarker=__bind(this.lastMarker,this),this.draggingMarker=__bind(this.draggingMarker,this),this.markers=__bind(this.markers,this),this.container=this.options.container,this.markersContainer=this.container.find("."+Planit.markerContainerClass),$(document).on("mousemove",this.mousemove),$(document).on("mouseup",this.mouseup)}return t.prototype.markers=function(){return this.markersContainer.find(".planit-marker")},t.prototype.draggingMarker=function(){return this.markersContainer.find(".planit-marker.is-dragging")},t.prototype.lastMarker=function(){return this.markers().last()},t.prototype.mouseup=function(t){var r,i;return $(t.target).hasClass("planit-marker-content")&&(i=$(t.target).closest(".planit-marker"),$("#"+i.attr("data-infobox")).addClass("active")),i=this.markersContainer.find(".is-dragging").first(),this.draggingMarker().length>0?(r=new Planit.Marker(this.container,i.attr("data-marker")),this.options.planit.dragEnd(t,r),this.draggingMarker().removeClass("is-dragging")):void 0},t.prototype.mousemove=function(t){var r,i,n,a,o,e,s,h,l,d,c,p,u,g;return d=this.markersContainer.find(".planit-marker.is-dragging"),d.length>0?(r=d.first(),c=t.pageX-this.container.offset().left,p=t.pageY-this.container.offset().top,g=this.container.width(),u=this.container.height(),a=c-r.outerWidth()/2,e=p-r.outerHeight()/2,o=c+r.outerWidth()/2,i=p+r.outerHeight()/2,s=r.outerWidth(),n=r.outerHeight(),h=0>=a?0:g>o?a:g-s,l=0>=e?0:u>i?e:u-n,r.css({left:h,top:l})):void 0},t}(),Planit.Marker=function(){function t(t,r){this.container=t,this.remove=__bind(this.remove,this),this.update=__bind(this.update,this),this.isDraggable=__bind(this.isDraggable,this),this.infoboxHTML=__bind(this.infoboxHTML,this),this.id=__bind(this.id,this),this.color=__bind(this.color,this),this.position=__bind(this.position,this),this.markersContainer=this.container.find("."+Planit.markerContainerClass),this.marker=this.markersContainer.find("."+Planit.markerClass+"[data-marker='"+r+"']").first()}return t.prototype.position=function(){var t,r,i,n;return r=this.marker.position().left+this.marker.outerWidth()/2,n=this.marker.position().top+this.marker.outerHeight()/2,t=r/this.container.width()*100,i=n/this.container.height()*100,[t,i]},t.prototype.color=function(){return this.marker.css("backgroundColor")},t.prototype.id=function(){return this.marker.attr("data-marker")},t.prototype.infoboxHTML=function(){var t;return t=this.marker.find(".planit-infobox"),t.length>0?t.html():null},t.prototype.isDraggable=function(){return this.marker.hasClass("draggable")},t.prototype.update=function(t){var r,i;return t.color&&this.marker.css({backgroundColor:t.color}),t.infobox&&this.marker.find(".planit-infobox").html(t.infobox),t.draggable&&(this.marker.removeClass("draggable"),t.draggable===!0&&this.marker.addClass("draggable")),t.coords?(r=parseFloat(t.coords[0])/100*this.container.width()-15,i=parseFloat(t.coords[1])/100*this.container.height()-15,this.marker.css({left:r+"px",top:i+"px"})):void 0},t.prototype.remove=function(){return this.marker.remove()},t}(),Planit.Marker.Events=function(){function t(t){var r,i;this.options=t,this.container=this.options.container,this.markersContainer=this.container.find("."+Planit.markerContainerClass),this.marker=this.markersContainer.find("."+Planit.markerClass+"[data-marker='"+this.options.id+"']").first(),this.options.draggable&&(this.lastMarker().addClass("draggable"),this.lastMarker().on("mousedown",function(){return function(t){var r,i;return"planit-marker-content"===$(t.target).attr("class")?(i=$(t.target).closest(".planit-marker"),i.addClass("is-dragging"),r=$(t.target).closest(".planit-marker").attr("data-infobox"),$("#"+r).removeClass("active")):void 0}}(this))),this.options.infobox&&(r=Planit.randomString(16),this.lastMarker().find(".planit-marker-content").append('<div class="planit-infobox" id="info-'+r+'">'+this.options.infobox+"</div>"),this.lastMarker().attr("data-infobox","info-"+r),i=$("#"+this.lastMarker().attr("data-infobox")),i.css({left:-(i.width()/2),bottom:i.outerHeight()+5}),this.lastMarker().on("mouseleave",function(){return function(t){var r;return r=$(t.target).closest(".planit-marker"),i=$("#"+r.attr("data-infobox")),i.removeClass("active")}}(this)),this.lastMarker().on("mouseover",function(t){return function(r){var n;return n=$(r.target).closest(".planit-marker"),i=$("#"+n.attr("data-infobox")),n.hasClass("is-dragging")||t.draggingMarker().length>0?i.removeClass("active"):i.addClass("active")}}(this)))}return t.prototype.markers=function(){return this.markersContainer.find(".planit-marker")},t.prototype.draggingMarker=function(){return this.markersContainer.find(".planit-marker.is-dragging")},t.prototype.lastMarker=function(){return this.markers().last()},t}(),Planit.Marker.Creator=function(){function t(t){var r,i,n;this.options=t,this.container=this.options.container,this.markersContainer=this.container.find("."+Planit.markerContainerClass).first(),this.options.id||(this.options.id=Planit.randomString(20)),r=this.options.color?this.options.color:"#FC5B3F",i=parseFloat(this.options.coords[0])/100*this.container.width()-15,n=parseFloat(this.options.coords[1])/100*this.container.height()-15,this.markersContainer.append($('<div><div class="planit-marker-content"></div></div>').addClass("planit-marker").attr("data-marker",this.options.id).css({left:i+"px",top:n+"px",backgroundColor:r})),new Planit.Marker.Events(this.options),new Planit.Marker(this.container,this.options.id)}return t}();
@@ -1 +1 @@
1
- .planit-container{position:relative;display:block;width:600px;height:600px;margin:25px auto;background:rgba(239,239,239,.8)}.planit-container img{position:absolute;top:0;left:0;width:100%}.planit-container .planit-markers-container{position:relative;width:100%;height:100%;background-size:100%;background-repeat:no-repeat;background-position:top left}.planit-container .planit-markers-container .planit-marker{position:absolute;width:30px;height:30px;z-index:999;border-radius:50%;background:#abc123}.planit-container .planit-markers-container .planit-marker.draggable:hover{cursor:move;opacity:.8}.planit-container .planit-markers-container .planit-marker.draggable.is-dragging{background:#00f}.planit-container .planit-markers-container .planit-marker .planit-marker-content{position:relative;width:100%;height:100%}.planit-container .planit-markers-container .planit-marker .planit-marker-content .planit-infobox{min-width:200px;display:none;position:relative;padding:5px 15px;background:#fff;border-radius:3px}.planit-container .planit-markers-container .planit-marker .planit-marker-content .planit-infobox.active{display:inline-block}.planit-container .planit-markers-container .planit-marker .planit-marker-content .planit-infobox:after{content:'';position:absolute;top:100%;left:50%;margin-left:-10px;width:0;height:0;border-top:solid 10px #fff;border-left:solid 10px transparent;border-right:solid 10px transparent}
1
+ .planit-container{position:relative;display:block;width:600px;height:600px;margin:25px auto;background:rgba(239,239,239,.8)}.planit-container img{position:absolute;top:0;left:0;width:100%}.planit-container .planit-markers-container{position:relative;width:100%;height:100%;background-size:100%;background-repeat:no-repeat;background-position:top left}.planit-container .planit-markers-container .planit-marker{position:absolute;width:30px;height:30px;z-index:999;border-radius:50%;background:#FC5B3F}.planit-container .planit-markers-container .planit-marker.draggable:hover{opacity:.8}.planit-container .planit-markers-container .planit-marker .planit-marker-content{position:relative;width:100%;height:100%}.planit-container .planit-markers-container .planit-marker .planit-marker-content:hover{cursor:move}.planit-container .planit-markers-container .planit-marker .planit-marker-content .planit-infobox{min-width:200px;display:none;position:relative;padding:5px 15px;cursor:initial;background:#fff;border-radius:3px}.planit-container .planit-markers-container .planit-marker .planit-marker-content .planit-infobox.active{display:inline-block}.planit-container .planit-markers-container .planit-marker .planit-marker-content .planit-infobox:after{content:'';position:absolute;top:100%;left:50%;margin-left:-10px;width:0;height:0;border-top:solid 10px #fff;border-left:solid 10px transparent;border-right:solid 10px transparent}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: planit-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean C Davis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-06 00:00:00.000000000 Z
11
+ date: 2015-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jquery-rails