diff options
author | Florian Hülsmann <fh@cbix.de> | 2012-03-27 05:36:09 +0400 |
---|---|---|
committer | Florian Hülsmann <fh@cbix.de> | 2012-03-27 05:36:09 +0400 |
commit | 9519a2196562d75101da92de751d1bd40f22d253 (patch) | |
tree | a97cebb0b6657e331f1d3510c93348fdb9090c2f /files_svgedit | |
parent | 3ea42a9e68c6e477e4ec6f8d7acce35c59927582 (diff) |
integrated editor preferences
Diffstat (limited to 'files_svgedit')
-rw-r--r-- | files_svgedit/js/ocsvgEditor.js | 45 | ||||
-rw-r--r-- | files_svgedit/templates/editor.php | 1 |
2 files changed, 45 insertions, 1 deletions
diff --git a/files_svgedit/js/ocsvgEditor.js b/files_svgedit/js/ocsvgEditor.js index d5de42f34..b99e9d7e6 100644 --- a/files_svgedit/js/ocsvgEditor.js +++ b/files_svgedit/js/ocsvgEditor.js @@ -1,6 +1,8 @@ var svgCanvas = null; var ocsvg = { frameDoc: null, + frameWin: null, + prefsShown: false, currentFile: { filecontents: '', path: '', @@ -51,7 +53,36 @@ var ocsvg = { 'json' ); } - } + }/*, + showPreferences: function() { + if (ocsvg.prefsShown) return; + ocsvg.prefsShown = true; + + // Update background color with current one + var blocks = ocsvg.frameDoc.find('#bg_blocks div'); + var cur_bg = 'cur_background'; + var canvas_bg = ocsvg.frameWin.$.pref('bkgd_color'); + var url = ocsvg.frameWin.$.pref('bkgd_url'); +// if(url) url = url[1]; + blocks.each(function() { + var blk = $(this); + var is_bg = blk.css('background-color') == canvas_bg; + blk.toggleClass(cur_bg, is_bg); + if(is_bg) $(ocsvg.frameDoc).find('#canvas_bg_url').removeClass(cur_bg); + }); + if(!canvas_bg) blocks.eq(0).addClass(cur_bg); + if(url) { + ocsvg.frameDoc.find('#canvas_bg_url').val(url); + } + ocsvg.frameDoc.find('grid_snapping_step').attr('value', ocsvg.frameWin.svgEditor.curConfig.snappingStep); + if (ocsvg.frameWin.svgEditor.curConfig.gridSnapping == true) { + ocsvg.frameDoc.find('#grid_snapping_on').attr('checked', 'checked'); + } else { + ocsvg.frameDoc.find('#grid_snapping_on').removeAttr('checked'); + } + + ocsvg.frameDoc.find('#svg_prefs').show(); + }*/ }; $(document).ready(function() { @@ -74,11 +105,23 @@ $(document).ready(function() { var frame = document.getElementById('svgedit'); $(frame).load(function() { ocsvg.frameDoc = $(frame).contents(); + ocsvg.frameWin = frame.contentWindow; svgCanvas = new embedded_svg_edit(frame); + // hide main menu button, then shift the tool bar to the left border: ocsvg.frameDoc.find('#main_button').hide().next().css('left', 0).css('padding-left', 2).css('padding-top', 2); // fix broken color select field ocsvg.frameDoc.find('#fill_color,#stroke_color').find('svg').css('height', '100%'); + // set handler for show preferences button: + //$('#ocsvgBtnPrefs').click(ocsvg.showPreferences); + $('#ocsvgBtnPrefs').click(function() { + ocsvg.frameDoc.find('#svg_prefs').toggle(); + }); + // set handler for preferences cancel button: + ocsvg.frameDoc.find('#tool_prefs_cancel').click(function() { + ocsvg.frameDoc.find('#svg_prefs').hide(); + }); + svgCanvas.setSvgString(ocsvg.currentFile.filecontents)(function(data, error) { if(error) { alert("Could not load file!\n\n" + error); diff --git a/files_svgedit/templates/editor.php b/files_svgedit/templates/editor.php index b0ff8cd6c..7f7c027b4 100644 --- a/files_svgedit/templates/editor.php +++ b/files_svgedit/templates/editor.php @@ -17,6 +17,7 @@ var ocsvgFile = { </script> <div id="controls"> <input type="button" id="ocsvgBtnSave" value="<?php echo $l->t('Save'); ?>" /> + <input type="button" id="ocsvgBtnPrefs" value="<?php echo $l->t('Preferences'); ?>" /> </div> <div id="editor"> <iframe src="<?php echo OC_Helper::linkTo('files_svgedit', 'svg-edit/svg-editor.html'); ?>" id="svgedit"></iframe> |