client/js/paper-renderer.js
changeset 271 b2cc6f238b0d
parent 270 aaef418cdf8d
child 273 3f4094a5c826
equal deleted inserted replaced
270:aaef418cdf8d 271:b2cc6f238b0d
   385             this.node_image.remove();
   385             this.node_image.remove();
   386         }
   386         }
   387         this.renderer.node_layer.activate();
   387         this.renderer.node_layer.activate();
   388         var width = _image.width,
   388         var width = _image.width,
   389             height = _image.height,
   389             height = _image.height,
   390             clipPath = this.model.get("clip-path"),
   390             clipPath = this.model.get("clip_path"),
   391             hasClipPath = (typeof clipPath !== "undefined" && clipPath);
   391             hasClipPath = (typeof clipPath !== "undefined" && clipPath);
   392         if (hasClipPath) {
   392         if (hasClipPath) {
   393             var _clip = new paper.Path(),
   393             var _clip = new paper.Path(),
   394                 instructions = clipPath.match(/[a-z][^a-z]+/gi) || [],
   394                 instructions = clipPath.match(/[a-z][^a-z]+/gi) || [],
   395                 lastCoords = [0,0],
   395                 lastCoords = [0,0],
   998                 short_uri:  shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
   998                 short_uri:  shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
   999                 description: _model.get("description"),
   999                 description: _model.get("description"),
  1000                 image: _model.get("image") || "",
  1000                 image: _model.get("image") || "",
  1001                 image_placeholder: _image_placeholder,
  1001                 image_placeholder: _image_placeholder,
  1002                 color: _model.get("color") || _created_by.get("color"),
  1002                 color: _model.get("color") || _created_by.get("color"),
  1003                 clip_path: _model.get("clip-path") || false,
  1003                 clip_path: _model.get("clip_path") || false,
  1004                 created_by_color: _created_by.get("color"),
  1004                 created_by_color: _created_by.get("color"),
  1005                 created_by_title: _created_by.get("title"),
  1005                 created_by_title: _created_by.get("title"),
  1006                 size: (_size > 0 ? "+" : "") + _size
  1006                 size: (_size > 0 ? "+" : "") + _size
  1007             },
  1007             },
  1008             renkan: this.renkan,
  1008             renkan: this.renkan,
  1792     
  1792     
  1793     bindClick(".Rk-ZoomOut", "zoomOut");
  1793     bindClick(".Rk-ZoomOut", "zoomOut");
  1794     bindClick(".Rk-ZoomIn", "zoomIn");
  1794     bindClick(".Rk-ZoomIn", "zoomIn");
  1795     bindClick(".Rk-ZoomFit", "autoScale");
  1795     bindClick(".Rk-ZoomFit", "autoScale");
  1796     this.$.find(".Rk-ZoomSave").click( function() {
  1796     this.$.find(".Rk-ZoomSave").click( function() {
  1797     	console.log("SAVE ZOOM FOR REAL", _this.scale, _this.offset);
       
  1798     	console.log("_this.renkan.project", _this.renkan.project);
       
  1799     	_this.renkan.project.set("views", [{id:Rkns.Utils.getUID('view'), zoom_level:_this.scale, offset_x:_this.offset.x, offset_y:_this.offset.y}]); // Save scale
  1797     	_this.renkan.project.set("views", [{id:Rkns.Utils.getUID('view'), zoom_level:_this.scale, offset_x:_this.offset.x, offset_y:_this.offset.y}]); // Save scale
  1800     	_this.$.find(".Rk-ZoomSetSaved").show();
  1798     	_this.$.find(".Rk-ZoomSetSaved").show();
  1801     });
  1799     });
  1802     this.$.find(".Rk-ZoomSetSaved").click( function() {
  1800     this.$.find(".Rk-ZoomSetSaved").click( function() {
  1803     	var view = _this.renkan.project.get("views")[0];
  1801     	var view = _this.renkan.project.get("views")[0];
  2019     + '<% if (options.editor_mode) { %><div class="Rk-ZoomSave" title="<%-translate("Zoom Save")%>"></div><% } %>'
  2017     + '<% if (options.editor_mode) { %><div class="Rk-ZoomSave" title="<%-translate("Zoom Save")%>"></div><% } %>'
  2020     + '<% if (options.editor_mode || !isNaN(parseInt(options.default_view))) { %><div class="Rk-ZoomSetSaved" title="<%-translate("View saved zoom")%>"></div><% } %></div>'
  2018     + '<% if (options.editor_mode || !isNaN(parseInt(options.default_view))) { %><div class="Rk-ZoomSetSaved" title="<%-translate("View saved zoom")%>"></div><% } %></div>'
  2021     + '</div></div>'
  2019     + '</div></div>'
  2022 ),
  2020 ),
  2023 fixSize: function(_autoscale) {
  2021 fixSize: function(_autoscale) {
  2024 	console.log("fixSize", _autoscale, this.renkan.project.get("zoom_level"));
       
  2025     var w = this.$.width(),
  2022     var w = this.$.width(),
  2026         h = this.$.height();
  2023         h = this.$.height();
  2027     if (this.renkan.options.show_top_bar) {
  2024     if (this.renkan.options.show_top_bar) {
  2028         h -= this.$.find(".Rk-TopBar").height();
  2025         h -= this.$.find(".Rk-TopBar").height();
  2029     }
  2026     }
  2199         }
  2196         }
  2200         this.redraw();
  2197         this.redraw();
  2201     }
  2198     }
  2202 },
  2199 },
  2203 autoScale: function(force_view) {
  2200 autoScale: function(force_view) {
  2204 	console.log("autoScale", force_view);
       
  2205     var nodes = this.renkan.project.get("nodes");
  2201     var nodes = this.renkan.project.get("nodes");
  2206     if (nodes.length > 1) {
  2202     if (nodes.length > 1) {
  2207         var _xx = nodes.map(function(_node) { return _node.get("position").x; }),
  2203         var _xx = nodes.map(function(_node) { return _node.get("position").x; }),
  2208             _yy = nodes.map(function(_node) { return _node.get("position").y; }),
  2204             _yy = nodes.map(function(_node) { return _node.get("position").y; }),
  2209             _minx = Math.min.apply(Math, _xx),
  2205             _minx = Math.min.apply(Math, _xx),
  2619 		            if (_data["text/html"] || _data["text/x-iri-selected-html"]) {
  2615 		            if (_data["text/html"] || _data["text/x-iri-selected-html"]) {
  2620 		                newNode.image = snippet.find("[data-image]").attr("data-image") || newNode.image;
  2616 		                newNode.image = snippet.find("[data-image]").attr("data-image") || newNode.image;
  2621 		                newNode.uri = snippet.find("[data-uri]").attr("data-uri") || newNode.uri;
  2617 		                newNode.uri = snippet.find("[data-uri]").attr("data-uri") || newNode.uri;
  2622 		                newNode.title = snippet.find("[data-title]").attr("data-title") || newNode.title;
  2618 		                newNode.title = snippet.find("[data-title]").attr("data-title") || newNode.title;
  2623 		                newNode.description = snippet.find("[data-description]").attr("data-description") || newNode.description;
  2619 		                newNode.description = snippet.find("[data-description]").attr("data-description") || newNode.description;
  2624 		                newNode.description = snippet.find("[data-clip-path]").attr("data-clip-path") || newNode.description;
  2620 		                newNode.clipPath = snippet.find("[data-clip-path]").attr("data-clip-path") || newNode.clipPath;
  2625 		            }
  2621 		            }
  2626 		    }
  2622 		    }
  2627 	    	if(typeof _renkan.options.drop_enhancer === "function"){
  2623 	    	if(typeof _renkan.options.drop_enhancer === "function"){
  2628 	    		newNode = _renkan.options.drop_enhancer(newNode, _data);
  2624 	    		newNode = _renkan.options.drop_enhancer(newNode, _data);
  2629 	    	}
  2625 	    	}
  2658             uri: newNode.uri || "",
  2654             uri: newNode.uri || "",
  2659             title: newNode.title || "",
  2655             title: newNode.title || "",
  2660             description: newNode.description || "",
  2656             description: newNode.description || "",
  2661             image: newNode.image || "",
  2657             image: newNode.image || "",
  2662             color: newNode.color || undefined,
  2658             color: newNode.color || undefined,
  2663             "clip-path": newNode.clipPath || undefined,
  2659             clip_path: newNode.clipPath || undefined,
  2664             position: {
  2660             position: {
  2665                 x: _coords.x,
  2661                 x: _coords.x,
  2666                 y: _coords.y
  2662                 y: _coords.y
  2667             }
  2663             }
  2668         };
  2664         };