Răsfoiți Sursa

added "save locally" menu item; fix in init color picker

mjz 10 ani în urmă
părinte
comite
3511052fb8

+ 1 - 1
src/allplatforms/classes/DocumentMenu.js

@@ -27,7 +27,7 @@ SC.loadPackage({ 'DocumentMenu': {
 
                     menuItemsTop  = [],
                     menuItemsLeft = [],
-                    menuItemsClassesTop  = [ 'MenuItemFileManager', 'MenuItemNewPage', 'MenuItemSave', 'MenuItemSaveAs', 'MenuItemSaveRemote', 'MenuItemServerSettings', 'MenuItemOutlines', 'MenuItemPaste', 'MenuItemUndo', 'MenuItemRedo' ],
+                    menuItemsClassesTop  = [ 'MenuItemFileManager', 'MenuItemNewPage', 'MenuItemSave', 'MenuItemSaveAs', 'MenuItemSaveLocal', 'MenuItemSaveRemote', 'MenuItemServerSettings', 'MenuItemOutlines', 'MenuItemPaste', 'MenuItemUndo', 'MenuItemRedo' ],
                     menuItemsClassesLeft = [ 'MenuItemCenter', 'MenuItemPageTitle', 'MenuItemBackgroundColor', 'MenuItemBackgroundImg', 'MenuItemBackgroundRepeat' ],
                     menuItem = null;
 

+ 2 - 0
src/allplatforms/classes/MenuItemBackgroundColor.js

@@ -62,6 +62,8 @@ SC.loadPackage({ 'MenuItemBackgroundColor': {
                 var initialColor = document.body.style.backgroundColor,
                     pickerLoad   = true;
 
+                initialColor = initialColor ? initialColor : 'rgb(100, 100, 100)';
+
                 this.do('initColorPickerWidget', {
 
                     theDocumentMenu: theDocumentMenu,

+ 62 - 0
src/allplatforms/classes/MenuItemSaveLocal.js

@@ -0,0 +1,62 @@
+SC.loadPackage({ 'MenuItemSaveLocal': {
+
+    comment: 'I am the MenuItem for saving the page on the local computer.',
+
+    traits:  ['MenuItem'],
+
+    sharedProperties: {
+
+        menuContainer:  { initValue: '<div class="sg-editing-menu-container"><button id="sg-editing-menu-saveLocal" class="sg-editing-menu-button" title="save page on my computer (download)"></button></div>' }
+
+    },
+
+    methods: {
+
+    	init: { 
+    		comment: 	'I init the MenuItem.',
+    		code: 		function(theDocumentMenu){
+
+                var self = this;
+
+                this.delegate('MenuItem', 'init', theDocumentMenu);
+                this.set({ isActionButton: true });
+
+                this.get('menuContainer').firstChild.addEventListener('mouseup', function(evt){
+                    self.do('action');
+                    theDocumentMenu.do('close');
+                }, false);
+
+
+    		}
+
+    	}, 
+
+        action: {
+            comment: 'I do the job.',
+            code: function(){
+
+                var thisPage = SC.init('Compiler').get('pageAsHTML5'),
+                    link     = document.createElement('a')
+                    filename = document.location.pathname.split('/').slice(-1)[0];
+
+                link.setAttribute('href', 
+                    'data:text/html;charset=utf-8,' + encodeURIComponent(thisPage)
+                );
+
+                link.setAttribute('download',
+                    filename ? filename : 'index.html'
+                );
+
+                document.body.appendChild(link);
+                link.click();
+                document.body.removeChild(link);
+                
+
+            }
+        }
+
+
+    }
+
+
+}});

+ 2 - 0
src/allplatforms/classes/WidgetBackgroundColor.js

@@ -23,6 +23,8 @@ SC.loadPackage({ 'WidgetBackgroundColor': {
                     pickerLoad   = true,
                     self = this;
 
+                initialColor = initialColor ? initialColor : 'rgb(100, 100, 100)';
+
                 this.do('initColorPickerWidget', {
 
                     theSelection: theSelection,

+ 2 - 0
src/allplatforms/classes/WidgetBorderColor.js

@@ -24,6 +24,8 @@ SC.loadPackage({ 'WidgetBorderColor': {
                     pickerLoad   = true,
                     self = this;
 
+                initialColor = initialColor ? initialColor : 'rgb(100, 100, 100)';
+
 
                 this.do('initColorPickerWidget', {
 

+ 1 - 1
src/allplatforms/css/DocumentMenu.css

@@ -8,7 +8,7 @@
 	position:       fixed;
 	top:			25px;
 	left:			15px;
-	width:			350px;
+	width:			390px;
 	height:			30px;
 }
 

+ 3 - 0
src/allplatforms/css/MenuItemSaveLocal.css

@@ -0,0 +1,3 @@
+#sg-editing-menu-saveLocal {
+	background-image: url("icons/saveLocal.svg");;
+}

+ 72 - 0
src/allplatforms/css/icons/saveLocal.svg

@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   version="1.1"
+   id="Layer_1"
+   x="0px"
+   y="0px"
+   width="30px"
+   height="30px"
+   viewBox="0 0 30 30"
+   enable-background="new 0 0 30 30"
+   xml:space="preserve"
+   inkscape:version="0.48.5 r10040"
+   sodipodi:docname="saveLocal.svg"><metadata
+     id="metadata21"><rdf:RDF><cc:Work
+         rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
+     id="defs19" /><sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="861"
+     inkscape:window-height="692"
+     id="namedview17"
+     showgrid="false"
+     inkscape:zoom="7.8666667"
+     inkscape:cx="15"
+     inkscape:cy="15"
+     inkscape:window-x="0"
+     inkscape:window-y="0"
+     inkscape:window-maximized="0"
+     inkscape:current-layer="Layer_1" /><rect
+     style="fill:none"
+     id="rect5"
+     height="2"
+     width="6"
+     y="17"
+     x="10" /><path
+     style="fill:none"
+     inkscape:connector-curvature="0"
+     id="path7"
+     d="m 7,7 v 12 h 1 v -4 h 10 v 4 h 1 V 9.362 L 16.639,7 H 7 z m 9,5 H 9 V 8.333 h 2 V 10 h 3 V 8.333 h 2 V 12 z" /><path
+     d="M 21,8.534 17.467,5 H 5 V 21 H 21 V 8.534 z M 16,19 h -6 v -2 h 6 v 2 z m 3,0 H 18 V 15 H 8 v 4 H 7 V 7 h 9.639 L 19,9.362 V 19 z"
+     id="path13"
+     inkscape:connector-curvature="0"
+     style="fill:#ffffff" /><polygon
+     points="9,12 16,12 16,8.333 14,8.333 14,10 11,10 11,8.333 9,8.333 "
+     id="polygon15"
+     style="fill:#ffffff" /><rect
+     y="18.813559"
+     x="23.423729"
+     height="4.9576273"
+     width="1.3983051"
+     id="rect3015"
+     style="fill:#ffffff" /><rect
+     y="23.516949"
+     x="20.720339"
+     height="1.5254238"
+     width="6.6101694"
+     id="rect3021"
+     style="fill:#ffffff" /></svg>

+ 2 - 0
src/chromium/content_probeForSG.js

@@ -46,6 +46,7 @@
         'classes/MenuItemRedo.js',
         'classes/MenuItemSave.js',
         'classes/MenuItemSaveAs.js',
+        'classes/MenuItemSaveLocal.js',
         'classes/MenuItemSaveRemote.js',
         'classes/MenuItemServerSettings.js',
         'classes/MenuItemUndo.js',
@@ -109,6 +110,7 @@
         'css/MenuItemRedo.css',
         'css/MenuItemSave.css',
         'css/MenuItemSaveAs.css',
+        'css/MenuItemSaveLocal.css',
         'css/MenuItemSaveRemote.css',
         'css/MenuItemServerSettings.css',
         'css/MenuItemUndo.css',

+ 2 - 0
src/firefox/data/content_probeForSG.js

@@ -46,6 +46,7 @@
         'classes/MenuItemRedo.js',
         'classes/MenuItemSave.js',
         'classes/MenuItemSaveAs.js',
+        'classes/MenuItemSaveLocal.js',
         'classes/MenuItemSaveRemote.js',
         'classes/MenuItemServerSettings.js',
         'classes/MenuItemUndo.js',
@@ -109,6 +110,7 @@
         'css/MenuItemRedo.css',
         'css/MenuItemSave.css',
         'css/MenuItemSaveAs.css',
+        'css/MenuItemSaveLocal.css',
         'css/MenuItemSaveRemote.css',
         'css/MenuItemServerSettings.css',
         'css/MenuItemUndo.css',