Skip to content

Commit

Permalink
Fixed 'readonly' bug
Browse files Browse the repository at this point in the history
Added additional confirmation prompts
  • Loading branch information
liprec committed Jan 7, 2018
1 parent 9195638 commit ceef6fd
Show file tree
Hide file tree
Showing 5 changed files with 240 additions and 160 deletions.
2 changes: 1 addition & 1 deletion pbiviz.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"displayName": "D3JSVisual",
"guid": "D3JSVisual_PBI_CV_CDD143DEC3A145E7A507B562AF6CF490",
"visualClassName": "D3JSVisual",
"version": "1.1.0",
"version": "1.2.0",
"description": "",
"supportUrl": "https://azurebi.jppp.org/power-bi-d3js-visual/",
"gitHubUrl": "https://github.com/liprec/powerbi-d3jsvisual"
Expand Down
60 changes: 43 additions & 17 deletions src/messagebox.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/*
*
* Copyright (c) 2017 Jan Pieter Posthuma / DataScenarios
*
* Copyright (c) 2018 Jan Pieter Posthuma / DataScenarios
*
* All rights reserved.
*
*
* MIT License.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -40,24 +40,50 @@ module powerbi.extensibility.utils {
}

export interface MessageBoxOptions {
type: MessageBoxType,
base: Selection<any>,
text?: string,
confirm?: boolean,
callback?: () => void
type: MessageBoxType;
base: Selection<any>;
text?: string;
label1?: string;
label2?: string;
label3?: string;
callback1?: () => void;
callback2?: () => void;
callback3?: () => void;
}

export class MessageBox {


private static yesno: string = "<div id='yesbtn'>yes</div>&nbsp;<div id='nobtn'>no</div>";

public static setMessageBox(options: MessageBoxOptions) {
options.base
.style("display", options.type===MessageBoxType.None ? "none" : "inline-block")
.classed("info", options.type===MessageBoxType.Info)
.classed("warning", options.type===MessageBoxType.Warning)
.classed("error", options.type===MessageBoxType.Error)
.style("display", options.type === MessageBoxType.None ? "none" : "inline-block")
.classed("info", options.type === MessageBoxType.Info)
.classed("warning", options.type === MessageBoxType.Warning)
.classed("error", options.type === MessageBoxType.Error)
.text(options.text);
if (options.label1) { // First option; e.g. Yes
options.base
.append('div')
.classed('inlineBtn', true)
.text(options.label1)
.on('click', options.callback1 ? options.callback1 : () => options.base.style("display", "none"));
}
if (options.label2) { // Second option; e.g. No
options.base
.append('div')
.classed('inlineBtn', true)
.text(options.label2)
.on('click', options.callback2 ? options.callback2 : () => options.base.style("display", "none"));
}
if (options.label3) { // Third option; e.g. Cancel
options.base
.append('div')
.classed('inlineBtn', true)
.text(options.label3)
.on('click', options.callback3 ? options.callback3 : () => options.base.style("display", "none"));
}
}

}
}
}
24 changes: 12 additions & 12 deletions src/settings.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/*
*
* Copyright (c) 2017 Jan Pieter Posthuma / DataScenarios
*
* Copyright (c) 2018 Jan Pieter Posthuma / DataScenarios
*
* All rights reserved.
*
*
* MIT License.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -39,13 +39,13 @@ module powerbi.extensibility.visual {
public js: string = "";
public css: string = "";

public iFrame: string = `<iframe id="d3js-sandbox" class="d3js-sandbox" width="#width" height="#height" style="width:#widthpx;height:#heightpx;margin-top:#toppx;margin-left:#leftpx" src="data:text/html,#src" sandbox="allow-scripts"></iframe>`
public d3Document: string = `<html><head><script src='https://d3js.org/d3.v3.min.js'></script><style id='d3js-css'>#style</style><script>window.addEventListener('message', function (e) {var mainWindow=e.source;try {document.getElementById('chart').innerHTML="";eval(e.data);} catch (ex) {console.log('D3js code threw an exception: ' + ex);} mainWindow.postMessage("",e.origin);});</script></head><body style="margin:0px;"><svg class="chart" id="chart"></svg></body></html>`
public d3SVG: string = `<svg class="chart" id="chart" width="#width" height="#height"></svg>`
public d3CSS: string = `<style>#style</style>`
public d3jsError: string = `<div class="d3jsError">#error</div>`
public iFrame: string = `<iframe id="d3js-sandbox" class="d3js-sandbox" width="#width" height="#height" style="width:#widthpx;height:#heightpx;margin-top:#toppx;margin-left:#leftpx" src="data:text/html,#src" sandbox="allow-scripts"></iframe>`;
public d3Document: string = `<html><head><script src='https://d3js.org/d3.v3.min.js'></script><style id='d3js-css'>#style</style><script>window.addEventListener('message', function (e) {var mainWindow=e.source;try {document.getElementById('chart').innerHTML="";eval(e.data);} catch (ex) {console.log('D3js code threw an exception: ' + ex);} mainWindow.postMessage("",e.origin);});</script></head><body style="margin:0px;"><svg class="chart" id="chart"></svg></body></html>`;
public d3SVG: string = `<svg class="chart" id="chart" width="#width" height="#height"></svg>`;
public d3CSS: string = `<style>#style</style>`;
public d3jsError: string = `<div class="d3jsError">#error</div>`;

public helpUrl: string = `https://azurebi.jppp.org/power-bi-d3js-visual/`
public helpUrl: string = `https://azurebi.jppp.org/power-bi-d3js-visual/`;
}

export class MarginSettings {
Expand Down
Loading

0 comments on commit ceef6fd

Please sign in to comment.