client/js/paper-renderer.js
changeset 267 bec6bba21c2b
parent 266 19f87d783168
child 268 a9f9257cfcef
equal deleted inserted replaced
266:19f87d783168 267:bec6bba21c2b
  1792     };
  1792     };
  1793     
  1793     
  1794     bindClick(".Rk-ZoomOut", "zoomOut");
  1794     bindClick(".Rk-ZoomOut", "zoomOut");
  1795     bindClick(".Rk-ZoomIn", "zoomIn");
  1795     bindClick(".Rk-ZoomIn", "zoomIn");
  1796     bindClick(".Rk-ZoomFit", "autoScale");
  1796     bindClick(".Rk-ZoomFit", "autoScale");
  1797     this.$.find(".Rk-ZoomSet").click( function() { _this.$.find(".Rk-ZoomSetContainer").toggle(); } );
  1797     this.$.find(".Rk-ZoomSave").click( function() {
  1798     this.$.find(".Rk-ZoomSlider").slider({
       
  1799     	orientation: "vertical",
       
  1800     	value:8,
       
  1801     	min: 1,
       
  1802     	max: 16,
       
  1803     	step: 1,
       
  1804     	slide: function( event, ui ) {
       
  1805     		_this.$.find(".Rk-ZoomSetValue").val( ui.value );
       
  1806     	},
       
  1807     	change: function( event, ui ) {
       
  1808     		_this.$.find(".Rk-ZoomSetValue").val( ui.value );
       
  1809     	},
       
  1810     	stop: function( event, ui ) {
       
  1811     		_this.$.find(".Rk-ZoomSetValue").val( ui.value );
       
  1812         	// Get value 
       
  1813         	var current_zoom = parseInt(_this.$.find(".Rk-ZoomSetValue").val()),
       
  1814         		nb_step = 0,
       
  1815         		mid_step = (_SCALE_STEPS/2),
       
  1816         		scale_factor = 1;
       
  1817         	if(current_zoom < mid_step){
       
  1818         		nb_step = mid_step - current_zoom;
       
  1819         		scale_factor = Math.SQRT1_2;
       
  1820         	}
       
  1821         	else if(current_zoom > mid_step){
       
  1822         		nb_step = current_zoom - mid_step;
       
  1823         		scale_factor = Math.SQRT2;
       
  1824         	}
       
  1825         	var _newScale = _this.initialScale;
       
  1826         	for(var i=0;i<nb_step;i++){
       
  1827         		_newScale = _newScale * scale_factor;
       
  1828         	}
       
  1829     		var _offset = new paper.Point([
       
  1830     		                           _this.canvas_$.width(),
       
  1831     		                           _this.canvas_$.height()
       
  1832     		                       ]).multiply( .5 * ( 1 - _newScale ) ).add(_this.offset.multiply( _newScale ));
       
  1833         	_this.setScale( _newScale, _offset );
       
  1834     	}
       
  1835     });
       
  1836     this.$.find(".Rk-ZoomSetButton").click( function() {
       
  1837     	console.log("SAVE ZOOM FOR REAL", _this, _this.scale);
  1798     	console.log("SAVE ZOOM FOR REAL", _this, _this.scale);
  1838     	_this.renkan.project.set("zoom_level", _this.scale); // Save scale
  1799     	_this.renkan.project.set("zoom_level", _this.scale); // Save scale
  1839     	//_this.$.find(".Rk-ZoomSetContainer").toggle();
  1800     	_this.$.find(".Rk-ZoomSetSaved").show();
       
  1801     });
       
  1802     this.$.find(".Rk-ZoomSetSaved").click( function() {
       
  1803     	_this.setScale(_this.renkan.project.get("zoom_level"));
  1840     });
  1804     });
  1841     this.$.find(".Rk-CurrentUser").mouseenter(
  1805     this.$.find(".Rk-CurrentUser").mouseenter(
  1842         function() { _this.$.find(".Rk-UserList").slideDown(); }
  1806         function() { _this.$.find(".Rk-UserList").slideDown(); }
  1843     );
  1807     );
  1844     this.$.find(".Rk-Users").mouseleave(
  1808     this.$.find(".Rk-Users").mouseleave(
  2046     + '<form action="#" class="Rk-GraphSearch-Form"><input type="search" class="Rk-GraphSearch-Field" placeholder="<%- translate("Search in graph") %>" /></form><div class="Rk-TopBar-Separator"></div><% } %></div><% } %>'
  2010     + '<form action="#" class="Rk-GraphSearch-Form"><input type="search" class="Rk-GraphSearch-Field" placeholder="<%- translate("Search in graph") %>" /></form><div class="Rk-TopBar-Separator"></div><% } %></div><% } %>'
  2047     + '<div class="Rk-Editing-Space<% if (!options.show_top_bar) { %> Rk-Editing-Space-Full<% } %>">'
  2011     + '<div class="Rk-Editing-Space<% if (!options.show_top_bar) { %> Rk-Editing-Space-Full<% } %>">'
  2048     + '<div class="Rk-Labels"></div><canvas class="Rk-Canvas" resize></canvas><div class="Rk-Notifications"></div><div class="Rk-Editor">'
  2012     + '<div class="Rk-Labels"></div><canvas class="Rk-Canvas" resize></canvas><div class="Rk-Notifications"></div><div class="Rk-Editor">'
  2049     + '<% if (options.show_bins) { %><div class="Rk-Fold-Bins">&laquo;</div><% } %>'
  2013     + '<% if (options.show_bins) { %><div class="Rk-Fold-Bins">&laquo;</div><% } %>'
  2050     + '<div class="Rk-ZoomButtons"><div class="Rk-ZoomIn" title="<%-translate("Zoom In")%>"></div><div class="Rk-ZoomFit" title="<%-translate("Zoom Fit")%>"></div><div class="Rk-ZoomOut" title="<%-translate("Zoom Out")%>"></div>'
  2014     + '<div class="Rk-ZoomButtons"><div class="Rk-ZoomIn" title="<%-translate("Zoom In")%>"></div><div class="Rk-ZoomFit" title="<%-translate("Zoom Fit")%>"></div><div class="Rk-ZoomOut" title="<%-translate("Zoom Out")%>"></div>'
  2051     + '<div class="Rk-ZoomSet" title="<%-translate("Zoom Set")%>"></div><div class="Rk-ZoomSetContainer"><div class="Rk-ZoomSlider"></div>'
  2015     + '<div class="Rk-ZoomSave" title="<%-translate("Zoom Save")%>"></div><div class="Rk-ZoomSetSaved" title="<%-translate("View saved zoom")%>"></div></div>'
  2052     + '<p><input type="text" class="Rk-ZoomSetValue" value="8" /><span class="Rk-ZoomSetButton ui-icon ui-icon-disk large" title="<%-translate("Save")%>"></span></p></div>'
       
  2053     + '</div></div>'
  2016     + '</div></div>'
  2054 ),
  2017 ),
  2055 fixSize: function(_autoscale) {
  2018 fixSize: function(_autoscale) {
  2056 	console.log("fixSize", _autoscale, this.renkan.project.get("zoom_level"));
  2019 	console.log("fixSize", _autoscale, this.renkan.project.get("zoom_level"));
  2057     var w = this.$.width(),
  2020     var w = this.$.width(),