uptate svg-edit to r2059

skala
Juan Carlos Raña 14 years ago
parent b22fe72778
commit 6d1f0aadc4
  1. 4
      main/inc/lib/svg-edit/browser.js
  2. 67
      main/inc/lib/svg-edit/contextmenu.js
  3. 54
      main/inc/lib/svg-edit/jquery-ui/jquery-ui-1.8.17.custom.min.js
  4. 84
      main/inc/lib/svg-edit/jquery-ui/jquery-ui-1.8.custom.min.js
  5. 170
      main/inc/lib/svg-edit/jquery.js
  6. 54
      main/inc/lib/svg-edit/svg-editor.js
  7. 3
      main/inc/lib/svg-edit/svg-editor.php
  8. 52
      main/inc/lib/svg-edit/svgcanvas.js
  9. 4
      main/inc/lib/svg-edit/svgicons/jquery.svgicons.js

@ -35,6 +35,8 @@ var isOpera_ = !!window.opera;
var isWebkit_ = userAgent.indexOf("AppleWebKit") >= 0;
var isGecko_ = userAgent.indexOf('Gecko/') >= 0;
var isIE_ = userAgent.indexOf('MSIE') >= 0;
var isChrome_ = userAgent.indexOf('Chrome/') >= 0;
var isWindows_ = userAgent.indexOf('Windows') >= 0;
var supportsSelectors_ = (function() {
return !!svg.querySelector;
@ -153,6 +155,8 @@ svgedit.browser.isOpera = function() { return isOpera_; }
svgedit.browser.isWebkit = function() { return isWebkit_; }
svgedit.browser.isGecko = function() { return isGecko_; }
svgedit.browser.isIE = function() { return isIE_; }
svgedit.browser.isChrome = function() { return isChrome_; }
svgedit.browser.isWindows = function() { return isWindows_; }
svgedit.browser.supportsSelectors = function() { return supportsSelectors_; }
svgedit.browser.supportsXpath = function() { return supportsXpath_; }

@ -0,0 +1,67 @@
/**
* Package: svgedit.contextmenu
*
* Licensed under the Apache License, Version 2
*
* Author: Adam Bender
*/
// Dependencies:
// 1) jQuery (for dom injection of context menus)
var svgedit = svgedit || {};
(function() {
var self = this;
if (!svgedit.contextmenu) {
svgedit.contextmenu = {};
}
self.contextMenuExtensions = {}
var addContextMenuItem = function(menuItem) {
// menuItem: {id, label, shortcut, action}
if (!menuItemIsValid(menuItem)) {
console
.error("Menu items must be defined and have at least properties: id, label, action, where action must be a function");
return;
}
if (menuItem.id in self.contextMenuExtensions) {
console.error('Cannot add extension "' + menuItem.id
+ '", an extension by that name already exists"');
return;
}
// Register menuItem action, see below for deferred menu dom injection
console.log("Registed contextmenu item: {id:"+ menuItem.id+", label:"+menuItem.label+"}");
self.contextMenuExtensions[menuItem.id] = menuItem;
//TODO: Need to consider how to handle custom enable/disable behavior
}
var hasCustomHandler = function(handlerKey) {
return self.contextMenuExtensions[handlerKey] && true;
}
var getCustomHandler = function(handlerKey) {
return self.contextMenuExtensions[handlerKey].action;
}
var injectExtendedContextMenuItemIntoDom = function(menuItem) {
if (Object.keys(self.contextMenuExtensions).length == 0) {
// all menuItems appear at the bottom of the menu in their own container.
// if this is the first extension menu we need to add the separator.
$("#cmenu_canvas").append("<li class='separator'>");
}
var shortcut = menuItem.shortcut || "";
$("#cmenu_canvas").append("<li class='disabled'><a href='#" + menuItem.id + "'>"
+ menuItem.label + "<span class='shortcut'>"
+ shortcut + "</span></a></li>");
}
var menuItemIsValid = function(menuItem) {
return menuItem && menuItem.id && menuItem.label && menuItem.action && typeof menuItem.action == 'function';
}
// Defer injection to wait out initial menu processing. This probably goes away once all context
// menu behavior is brought here.
svgEditor.ready(function() {
for (menuItem in contextMenuExtensions) {
injectExtendedContextMenuItemIntoDom(contextMenuExtensions[menuItem]);
}
});
svgedit.contextmenu.resetCustomMenus = function(){self.contextMenuExtensions = {}}
svgedit.contextmenu.add = addContextMenuItem;
svgedit.contextmenu.hasCustomHandler = hasCustomHandler;
svgedit.contextmenu.getCustomHandler = getCustomHandler;
})();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -7,10 +7,11 @@
* Copyright(c) 2010 Pavol Rusnak
* Copyright(c) 2010 Jeff Schiller
* Copyright(c) 2010 Narendra Sisodiya
*
*
* Integrate with Chamilo
* Author Juan Carlos Raña Trabado
* Since 25/september/2010
*
*/
// Dependencies:
@ -37,7 +38,8 @@
// Note: Difference between Prefs and Config is that Prefs can be
// changed in the UI and are stored in the browser, config can not
// added 'ext-server_opensave.js','ext-arrows.js','ext-foreignobject.js'(MathML) extensions for Chamilo
// Chamilo added 'ext-server_opensave.js','ext-arrows.js','ext-foreignobject.js'(MathML) extensions
curConfig = {
canvas_expansion: 3,
dimensions: [640,480],
@ -56,11 +58,11 @@
extPath: 'extensions/',
jGraduatePath: 'jgraduate/images/',
extensions: ['ext-markers.js','ext-connector.js', 'ext-eyedropper.js', 'ext-shapes.js', 'ext-imagelib.js','ext-grid.js','ext-server_opensave.js','ext-arrows.js','ext-foreignobject.js'],
initTool: 'select',
wireframe: false,
colorPickerCSS: null,
gridSnapping: false,
gridColor: "#000",
baseUnit: 'px',
snappingStep: 10,
showRulers: true
@ -183,7 +185,7 @@
svgCanvas.open = opts.open;
}
if(opts.save) {
show_save_warning = false;
Editor.show_save_warning = false;
svgCanvas.bind("saved", opts.save);
}
if(opts.pngsave) {
@ -484,7 +486,7 @@
});
Editor.canvas = svgCanvas = new $.SvgCanvas(document.getElementById("svgcanvas"), curConfig);
Editor.show_save_warning = false;
var palette = ["#000000", "#3f3f3f", "#7f7f7f", "#bfbfbf", "#ffffff",
"#ff0000", "#ff7f00", "#ffff00", "#7fff00",
"#00ff00", "#00ff7f", "#00ffff", "#007fff",
@ -506,7 +508,6 @@
workarea = $("#workarea"),
canv_menu = $("#cmenu_canvas"),
layer_menu = $("#cmenu_layers"),
show_save_warning = false,
exportWindow = null,
tool_scale = 1,
zoomInIcon = 'crosshair',
@ -604,7 +605,7 @@
var orig_title = $('title:first').text();
var saveHandler = function(window,svg) {
show_save_warning = false;
Editor.show_save_warning = false;
// by default, we add the XML prolog back, systems integrating SVG-edit (wikis, CMSs)
// can just provide their own custom save handler and might not want the XML prolog
@ -759,8 +760,8 @@
}
}
show_save_warning = false; //Hack for Chamilo, change true by false
Editor.show_save_warning = false; //Hack for Chamilo, change true by false
// we update the contextual panel with potentially new
// positional/sizing information (we DON'T want to update the
// toolbar here as that creates an infinite loop)
@ -2144,6 +2145,7 @@
Editor.addDropDown = function(elem, callback, dropUp) {
if ($(elem).length == 0) return; // Quit if called on non-existant element
var button = $(elem).find('button');
var list = $(elem).find('ul').attr('id', $(elem)[0].id + '-list');
if(!dropUp) {
@ -3283,15 +3285,13 @@
(function() {
workarea.scroll(function() {
// TODO: jQuery's scrollLeft/Top() wouldn't require a null check
if ($('#ruler_x').length != 0) {
$('#ruler_x')[0].scrollLeft = workarea[0].scrollLeft;
}
if ($('#ruler_y').length != 0) {
$('#ruler_y')[0].scrollTop = workarea[0].scrollTop;
}
if ($('#ruler_x').length != 0) {
$('#ruler_x')[0].scrollLeft = workarea[0].scrollLeft;
}
if ($('#ruler_y').length != 0) {
$('#ruler_y')[0].scrollTop = workarea[0].scrollTop;
}
});
}());
@ -4139,7 +4139,7 @@
});
// Put shortcut in title
if(opts.sel && !opts.hidekey) {
if(opts.sel && !opts.hidekey && btn.attr('title')) {
var new_title = btn.attr('title').split('[')[0] + ' (' + keyval + ')';
key_assocs[keyval] = opts.sel;
// Disregard for menu items
@ -4240,9 +4240,11 @@
}
$('#rulers').toggle(!!curConfig.showRulers);
if(curConfig.showRulers) {
$('#show_rulers')[0].checked = true;
if (curConfig.showRulers) {
$('#show_rulers')[0].checked = true;
}
if(curConfig.gridSnapping) {
$('#grid_snapping_on')[0].checked = true;
}
@ -4305,7 +4307,11 @@
case 'move_back':
moveToBottomSelected();
break;
default:
if(svgedit.contextmenu && svgedit.contextmenu.hasCustomHandler(action)){
svgedit.contextmenu.getCustomHandler(action).call();
}
break;
}
if(svgCanvas.clipBoard.length) {
@ -4357,11 +4363,11 @@
window.onbeforeunload = function() {
// Suppress warning if page is empty
if(undoMgr.getUndoStackSize() === 0) {
show_save_warning = false;
Editor.show_save_warning = false;
}
// show_save_warning is set to "false" when the page is saved.
if(!curConfig.no_save_warning && show_save_warning) {
if(!curConfig.no_save_warning && Editor.show_save_warning) {
// Browser already asks question about closing the page
return uiStrings.notification.unsavedChanges;
}
@ -4651,7 +4657,7 @@
updateCanvas(true);
// });
// var revnums = "svg-editor.js ($Rev: 2028 $) ";
// var revnums = "svg-editor.js ($Rev: 2056 $) ";
// revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute("title", revnums);

@ -54,13 +54,14 @@ if(!isset($_SESSION['draw_dir'])){
<script type="text/javascript" src="svgcanvas.js"></script>
<script type="text/javascript" src="svg-editor.js"></script>
<script type="text/javascript" src="locale/locale.js"></script>
<script type="text/javascript" src="contextmenu.js"></script>
<!--{endif}-->
<!-- you can load extensions here -->
<!-- <script type="text/javascript" src="extensions/ext-helloworld.js"></script> -->
<!-- always minified scripts -->
<script type="text/javascript" src="jquery-ui/jquery-ui-1.8.custom.min.js"></script>
<script type="text/javascript" src="jquery-ui/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="jgraduate/jpicker.min.js"></script>
<!-- feeds -->

@ -1,4 +1,4 @@
/*
/*
* svgcanvas.js
*
* Licensed under the Apache License, Version 2
@ -2516,10 +2516,25 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
tlist.appendItem(svgroot.createSVGTransform());
if(svgedit.browser.supportsNonScalingStroke()) {
//Handle crash for newer Chrome + Windows: https://code.google.com/p/svg-edit/issues/detail?id=904
// TODO: Remove this workaround (all isChromeWindows blocks) once vendor fixes the issue
var isChromeWindows = svgedit.browser.isChrome() && svgedit.browser.isWindows();
if(isChromeWindows) {
var delayedStroke = function(ele) {
var _stroke = ele.getAttributeNS(null, 'stroke');
ele.removeAttributeNS(null, 'stroke');
//Re-apply stroke after delay. Anything higher than 1 seems to cause flicker
setTimeout(function() { ele.setAttributeNS(null, 'stroke', _stroke) }, 1);
}
}
mouse_target.style.vectorEffect = 'non-scaling-stroke';
var all = mouse_target.getElementsByTagName('*'), len = all.length;
for(var i = 0; i < all.length; i++) {
if(isChromeWindows) delayedStroke(mouse_target);
var all = mouse_target.getElementsByTagName('*'),
len = all.length;
for(var i = 0; i < len; i++) {
all[i].style.vectorEffect = 'non-scaling-stroke';
if(isChromeWindows) delayedStroke(all[i]);
}
}
}
@ -5239,6 +5254,13 @@ this.svgToString = function(elem, indent) {
out.push(toXml(str) + "");
}
break;
case 4: // cdata node
out.push("\n");
out.push(new Array(indent+1).join(" "));
out.push("<![CDATA[");
out.push(child.nodeValue);
out.push("]]>");
break;
case 8: // comment
out.push("\n");
out.push(new Array(indent+1).join(" "));
@ -5719,8 +5741,15 @@ this.setSvgString = function(xmlString) {
batchCmd.addSubCommand(new RemoveElementCommand(oldzoom, nextSibling, svgroot));
// set new svg document
svgcontent = svgroot.appendChild(svgdoc.importNode(newDoc.documentElement, true));
// If DOM3 adoptNode() available, use it. Otherwise fall back to DOM2 importNode()
if(svgdoc.adoptNode) {
svgcontent = svgdoc.adoptNode(newDoc.documentElement);
}
else {
svgcontent = svgdoc.importNode(newDoc.documentElement, true);
}
svgroot.appendChild(svgcontent);
var content = $(svgcontent);
canvas.current_drawing_ = new svgedit.draw.Drawing(svgcontent, idprefix);
@ -5907,7 +5936,14 @@ this.importSvgString = function(xmlString) {
this.prepareSvg(newDoc);
// import new svg document into our document
var svg = svgdoc.importNode(newDoc.documentElement, true);
var svg;
// If DOM3 adoptNode() available, use it. Otherwise fall back to DOM2 importNode()
if(svgdoc.adoptNode) {
svg = svgdoc.adoptNode(newDoc.documentElement);
}
else {
svg = svgdoc.importNode(newDoc.documentElement, true);
}
uniquifyElems(svg);
@ -6423,7 +6459,7 @@ this.getZoom = function(){return current_zoom;};
// Function: getVersion
// Returns a string which describes the revision number of SvgCanvas.
this.getVersion = function() {
return "svgcanvas.js ($Rev: 2028 $)";
return "svgcanvas.js ($Rev: 2059 $)";
};
// Function: setUiStrings
@ -8601,7 +8637,7 @@ this.updateCanvas = function(w, h) {
x: x,
y: y
});
var bg_img = getElem('background_image');
if (bg_img) {
assignAttributes(bg_img, {
@ -8609,7 +8645,7 @@ this.updateCanvas = function(w, h) {
'height': '100%'
});
}
selectorManager.selectorParentGroup.setAttribute("transform","translate(" + x + "," + y + ")");
return {x:x, y:y, old_x:old_x, old_y:old_y, d_x:x - old_x, d_y:y - old_y};

@ -171,8 +171,8 @@ $(function() {
useFallback();
});
} else {
if(err.responseXML) {
svgdoc = parser.parseFromString(err.responseXML, "text/xml");
if(err.responseText) {
svgdoc = parser.parseFromString(err.responseText, "text/xml");
if(!svgdoc.childNodes.length) {
$(useFallback);

Loading…
Cancel
Save