Skip to content

Commit 88ef35d

Browse files
committed
Chart preview icon on mobile
1 parent 286ee19 commit 88ef35d

5 files changed

Lines changed: 66 additions & 12 deletions

File tree

less/editor.style.less

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@
1515
margin-top:5px;
1616
}
1717

18+
.highed-chart-container-icon {
19+
float:left;
20+
width:40px;
21+
height:40px;
22+
background-repeat: no-repeat;
23+
background-position: center;
24+
background-size: 100%;
25+
.highed-box-size;
26+
//transform:scale();
27+
}
28+
1829
@media (max-width: 700px) {
1930
.highed-chart-preview-bar {
2031
display:none !important;

less/toolbar.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@
2424
}
2525

2626
.highed-toolbar .icon {
27-
line-height:35px;
27+
line-height:40px;
2828
}

src/editors/highed.editor.js

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
198198
dataExpStep = wizbar.addStep({ title: highed.getLocalizedStr('stepExport'), id: 'export' }),
199199
dataExp = highed.Exporter(dataExpStep.body, properties.exporter),
200200

201+
chartIcon = highed.dom.cr('div', 'highed-chart-container-icon'),
202+
201203
cmenu = highed.DefaultContextMenu(chartPreview)
202204

203205
;
@@ -208,6 +210,16 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
208210

209211
///////////////////////////////////////////////////////////////////////////
210212

213+
function updateToolbarIcon() {
214+
if (highed.onPhone()) {
215+
highed.dom.style(chartIcon, {
216+
'background-image': 'url("data:image/svg+xml;utf8,' +
217+
encodeURIComponent(chartPreview.export.svg()) +
218+
'")'
219+
});
220+
}
221+
}
222+
211223
//Hide features that are disabled
212224
function applyFeatures() {
213225
var things = highed.arrToObj(properties.features.split(' '));
@@ -341,7 +353,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
341353
});
342354

343355
//Route preview events
344-
chartPreview.on('ChartChange', function (newData) { events.emit('ChartChange', newData);});
356+
chartPreview.on('ChartChange', function (newData) {
357+
events.emit('ChartChange', newData);
358+
359+
});
345360
chartPreview.on('ChartChangeLately', function (newData) { events.emit('ChartChangeLately', newData);});
346361

347362
///////////////////////////////////////////////////////////////////////////
@@ -359,6 +374,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
359374
highed.log(2, 'on object in editor properties is not a valid object');
360375
}
361376

377+
378+
362379
//Activate plugins
363380
properties.plugins = highed.arrToObj(properties.plugins);
364381
Object.keys(properties.plugins).forEach(function (name) {
@@ -367,6 +384,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
367384

368385
//Dispatch change events to the active plugins
369386
chartPreview.on('ChartChangeLately', function (options) {
387+
388+
updateToolbarIcon();
389+
370390
Object.keys(activePlugins).forEach(function (key) {
371391
var plugin = activePlugins[key];
372392
if (highed.isFn(plugin.definition.chartchange)) {
@@ -379,14 +399,31 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
379399

380400
applyFeatures();
381401

402+
403+
chartCustomizer.init(chartPreview.options.customized, chartPreview.options.chart);
404+
405+
if (highed.onPhone()) {
406+
chartContainer.className = 'highed-chart-container-icon';
407+
highed.dom.ap(mainToolbar.right, chartIcon);
408+
409+
highed.dom.on(chartIcon, 'click', function (e) {
410+
chartPreview.expand();
411+
e.cancelBubble = true;
412+
e.preventDefault();
413+
e.stopPropagation();
414+
e.stopImmediatePropagation();
415+
return false;
416+
});
417+
}
418+
382419
mainToolbar.addIcon({
383420
css: 'fa-bars',
384421
click: function(e) {
385422
cmenu.show(e.clientX, e.clientY);
386423
}
387424
});
388425

389-
chartCustomizer.init(chartPreview.options.customized, chartPreview.options.chart);
426+
updateToolbarIcon();
390427

391428
///////////////////////////////////////////////////////////////////////////
392429

src/ui/highed.chartpreview.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ highed.ChartPreview = function (parent, attributes) {
115115
window.clearTimeout(throttleTimeout);
116116
throttleTimeout = window.setTimeout(function () {
117117
events.emit('ChartChangeLately', aggregatedOptions);
118-
}, 800);
118+
}, 200);
119119
}
120120

121121
/* Init the chart */
@@ -503,6 +503,11 @@ highed.ChartPreview = function (parent, attributes) {
503503
});
504504
}
505505

506+
function changeParent(newParent) {
507+
parent = newParent;
508+
init();
509+
}
510+
506511
///////////////////////////////////////////////////////////////////////////
507512

508513
//Init the initial chart
@@ -520,6 +525,7 @@ highed.ChartPreview = function (parent, attributes) {
520525
expand: expand,
521526
collapse: collapse,
522527
new: newChart,
528+
changeParent: changeParent,
523529

524530
loadTemplate: loadTemplate,
525531
resize: resize,

src/ui/highed.defctx.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ highed.DefaultContextMenu = function (chartPreview) {
109109
{
110110
title: highed.getLocalizedStr('help'),
111111
icon: 'question-circle'
112-
},
113-
{
114-
title: highed.getLocalizedStr('licenseInfo'),
115-
icon: 'key',
116-
click: function () {
117-
highed.licenseInfo.show();
118-
}
119-
}
112+
}//,
113+
// {
114+
// title: highed.getLocalizedStr('licenseInfo'),
115+
// icon: 'key',
116+
// click: function () {
117+
// highed.licenseInfo.show();
118+
// }
119+
// }
120120
])
121121
;
122122

0 commit comments

Comments
 (0)