Zoom In functionality not working in getOrgChart - getorgchart

once zoomed out fully in org chart, Zoom In is not working.
Not sure whether any css is blocking the Zoom In functionality.
Is it possible to debug this functionality in getorgchart.All the javascript and css files have been and added and they are as follows. The data fetched to the orgchart is made through an ajax call.
function org_chart() {
$.ajax({
type: "post",
datatype: "json",
url: 'getOrgChartData',
data: {
'Id': Id
},
success: function(data) {
var datasource = data.List;
getOrgChart.themes.Theme1 = {
size: [470, 80],
toolbarHeight: 0,
textPoints: [{
x: 225,
y: 50,
width: 450
}, {
x: 225,
y: 80,
width: 450
}],
textPointsNoImage: [{
x: 225,
y: 50,
width: 450
}, {
x: 225,
y: 80,
width: 450
}],
expandCollapseBtnRadius: 20,
box: '<rect x="0" y="0" height="80" width="470" rx="10" ry="10" />',
text: '<text text-anchor="middle" width="[width]" class="get-text get-text-[index]" x="[x]" y="[y]">[text]</text>'
};
var orgChart = new getOrgChart(document.getElementById("org-container"), {
theme: "Theme1",
idField: "id",
parentIdField: "parent_id",
primaryFields: ["name"],
photoFields: ["icon"],
gridView: true,
linkType: "M",
dataSource: datasource,
enableGridView: false,
enableZoom: true,
enableEdit: false,
enableSearch: true,
enableMove: true,
enableDetailsView: false,
enablePrint: false,
enableZoomOnNodeDoubleClick: true,
enableExportToImage: false,
expandToLevel: 2,
scale: 0.5,
layout: getOrgChart.MIXED_HIERARCHY_RIGHT_LINKS,
clickNodeEvent: function(sender, args) {
var id = args.node.id;
var nodes = sender.nodes;
var selectedKey = args.node.data.key;
$.each(nodes, function(idx, node) {
var nodeId = node.data.key;
console.log(nodeId, selectedKey);
var fillOpacity = selectedKey.indexOf(nodeId) == 0 ? "1" : "0.4";
$('#org-container g[data-node-id = "' + node.id + '"] > rect').css({
'fill-opacity': fillOpacity,
'stroke-width': '5',
'stroke-dasharray': '0'
});
});
$('#org-container g[data-node-id = "' + id + '"] > rect').css({
'fill-opacity': '1',
'stroke-width': '10',
'stroke-dasharray': '20,5',
'animation': 'dash 1s infinite linear'
});
}
});
}
});
}
<link href="../css/jquery.multiselect.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../css/ui.jqgrid.css" media="screen" />
<link rel="stylesheet" type="text/css" href="../css/jquery.mobile-1.3.0.min.css" />
<link rel="stylesheet" type="text/css" href="../css/jquery-ui-custom.css" />
<link rel="stylesheet" type="text/css" href="../css/swiper.min.css" />
<link rel="stylesheet" type="text/css" href="../css/jstree-3.2.1.style.css" />
<link rel="stylesheet" type="text/css" href="../css/getorgchart.css" />
<script type="text/javascript" src="../js/jquery-1.12.4-min.js"></script>
<script type="text/javascript" src="../js/grid.locale-en.js"></script>
<script type="text/javascript" src="../js/jquery.jqGrid.js"></script>
<script type="text/javascript" src="../js/jquery-ui-1.11.2.js"></script>
<script type="text/javascript" src="../js/jquery.mobile-1.3.0.min.js"></script>
<script src="../js/highcharts.js"></script>
<script type="text/javascript" src="../js/jquery.multiselect.js"></script>
<script type="text/javascript" src="../js/d3.v5.min.js"></script>
<script type="text/javascript" src="../js/swiper.min.js"></script>
<script type="text/javascript" src="../js/jstree-3.2.1.min.js"></script>
<script type="text/javascript" src="../js/getorgchart.js"></script>

Related

how to scale image using scalecontroler

I cannot scale the image when moving the scale controller. It shows the following error:
Uncaught TypeError: canvas.requestRenderAll is not a function
Can please anyone help to solve this problem? I want the functionality to be implemented for image please refer to this. Here is my code:
<!DOCTYPE html>
<html>
<head>
<title>Instagram</title>
<script type="text/javascript" src="fabric.js-1.7.21/dist/fabric.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<body>
<canvas id="c" width="500px" height="400px"></canvas>
<div id="range">
<input type="range" class="image-scale-lever" step="0.1" max="3" min="0.1" value="1" id="scale-control"></label>
</div>
<script type="text/javascript">
jQuery( document ).ready(function() {
var canvas = this.__canvas = new fabric.Canvas('c');
fabric.Image.fromURL('locket.png', function(oImg) {
oImg.set({
left: 0,
top: 0,
width:500,
height:400
});
canvas.add(oImg);
var scaleControl = $('#scale-control');
scaleControl.oninput = function(x) {
this.val(x);
oImg.scale(parseFloat(x)).setCoords();
canvas.requestRenderAll();
}
function updateControls() {
scaleControl.oninput(oImg.scaleX);
}
canvas.observe("object:scaling", function (e) {
updateControls();
});
});
});
[1]: https://withyoulockets.com/pub/media/catalog/product/cache/image/700x700/e9c3970ab036de70892d86c6d221abfe/k/a/katieopen1100px-min.png
Here is the result. You need to change the scale of the object on onchange event callback.
<!DOCTYPE html>
<html>
<head>
<title>Instagram</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.7.21/fabric.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" >
jQuery( document ).ready(function() {
var canvas = this.__canvas = new fabric.Canvas('c');
fabric.Image.fromURL('https://withyoulockets.com/pub/media/catalog/product/cache/image/700x700/e9c3970ab036de70892d86c6d221abfe/k/a/katieopen1100px-min.png', function(oImg) {
oImg.set({
left: 0,
top: 0,
width:500,
height:400
});
canvas.add(oImg);
var scaleControl = $('#scale-control');
scaleControl.on("change",function() {
var newValue = this.value;
oImg.scale(parseFloat(newValue)).setCoords();
canvas.renderAll();
})
function updateControls() {
scaleControl.oninput(oImg.scaleX);
}
canvas.observe("object:scaling", function (e) {
updateControls();
});
});
});
</script>
<body>
<canvas id="c" width="500px" height="400px"></canvas>
<div id="range">
<input type="range" class="image-scale-lever" step="0.1" max="3" min="0.1" value="1" id="scale-control"></label>
</div>
Check here:
https://jsfiddle.net/3mjhxcyn/2/

How to send attribute value from child custom element to parent custom element in polymer

I have searched a lot on this, but could not find an answer. I have the following code :
netflix-search:
<!DOCTYPE html>
<html>
<head>
<link href="../bower_components/polymer/polymer.html" rel="import">
<link href="netflix-search-criteria.html" rel="import">
<link href="netflix-search-result.html" rel="import">
<!-- Element Imports -->
</head>
<dom-module id="netflix-search">
<style>
/* CSS rules for your element */
</style>
<template>
<netflix-search-criteria></netflix-search-criteria>
<h1> here it is + {{criteria}}</h1>
<!--<netflix-search-result content="{{criteria}}"></netflix-search- result>-->
</template>
</dom-module>
<script>
Polymer({
is: "netflix-search",
properties: {
}
},
ready: function(e){
}
});
</script>
The child element is :
<!DOCTYPE html>
<html>
<head>
<link href="../bower_components/polymer/polymer.html" rel="import">
<link href="../bower_components/paper-material/paper-material.html" rel="import">
<link href="../bower_components/paper-dropdown-menu/paper-dropdown-menu.html" rel="import">
<link href="../bower_components/paper-listbox/paper-listbox.html" rel="import">
<link href="../bower_components/paper-item/paper-item.html" rel="import">
<!-- Element Imports -->
</head>
<dom-module id="netflix-search-criteria">
<style>
/* CSS rules for your element */
</style>
<template>
<paper-material elevation="1">
<paper-dropdown-menu id="mymenu" label="What do you know about the content?" attr-for-selected="value"
selected="{{selItem}}" on-iron-select="_itemSelected">
<paper-listbox class="dropdown-content">
<paper-item>Movie Name</paper-item>
<paper-item>Actor</paper-item>
<paper-item>Director</paper-item>
</paper-listbox>
</paper-dropdown-menu>
<template is="dom-if" if="{{show}}">
<paper-input label="Enter Search content" on-input="_search">
</paper-input>
<h1>{{criteria}}</h1>
</template>
</template>
</dom-module>
<script>
Polymer({
is: "netflix-search-criteria",
_itemSelected : function(e) {
console.log("Coming here" + e.target.selectedItem.innerText);
this.selItem = e.target.selectedItem.innerText;
if(this.selItem == 'Movie Name' || this.selItem == 'Actor'
|| this.selItem == 'Director')
{
this.show = true;
}
},
_search : function(e) {
var cont = e.target.value;
if(cont.length > 3){
this.criteria = this.selItem + "=" + cont;
console.log("Coming here" + this.criteria);
}
},
properties: {
selItem: {
type: String,
value: ""
},
show: {
type: Boolean,
value: false
},
criteria: {
type: String,
value: "Show",
notify: true,
reflecToAttribute: true
}
},
ready: function(e){
}
});
</script>
I want to pass the value criteria from child element to parent element. But not sure how to do that
Figured it out:
here is the code
parent class
<!DOCTYPE html>
<html>
<head>
<link href="../bower_components/polymer/polymer.html" rel="import">
<link href="netflix-search-criteria.html" rel="import">
<link href="netflix-search-result.html" rel="import">
<!-- Element Imports -->
</head>
<dom-module id="netflix-search">
<style>
/* CSS rules for your element */
</style>
<template>
<netflix-search-criteria criteria={{content}}></netflix-search-criteria>
<netflix-search-result search="{{content}}"></netflix-search-result>
</template>
</dom-module>
<script>
Polymer({
is: "netflix-search",
properties: {
content: {
type: String,
value: "No",
notify: true,
reflecToAttribute: true
}
},
ready: function(e){
}
});
</script>
child class:
<!DOCTYPE html>
<html>
<head>
<link href="../bower_components/polymer/polymer.html" rel="import">
<link href="../bower_components/paper-material/paper-material.html" rel="import">
<link href="../bower_components/paper-dropdown-menu/paper-dropdown-menu.html" rel="import">
<link href="../bower_components/paper-listbox/paper-listbox.html" rel="import">
<link href="../bower_components/paper-item/paper-item.html" rel="import">
<!-- Element Imports -->
</head>
<dom-module id="netflix-search-criteria">
<style>
/* CSS rules for your element */
</style>
<template>
<paper-material elevation="1">
<paper-dropdown-menu id="mymenu" label="What do you know about the content?" attr-for-selected="value"
selected="{{selItem}}" on-iron-select="_itemSelected">
<paper-listbox class="dropdown-content">
<paper-item>Movie Name</paper-item>
<paper-item>Actor</paper-item>
<paper-item>Director</paper-item>
</paper-listbox>
</paper-dropdown-menu>
<template is="dom-if" if="{{show}}">
<paper-input label="Enter Search content" on-input="_search">
</paper-input>
<h1>{{content}}</h1>
</template>
</template>
</dom-module>
<script>
Polymer({
is: "netflix-search-criteria",
_itemSelected : function(e) {
console.log("Coming here" + e.target.selectedItem.innerText);
this.selItem = e.target.selectedItem.innerText;
if(this.selItem == 'Movie Name' || this.selItem == 'Actor'
|| this.selItem == 'Director')
{
this.show = true;
}
},
_search : function(e) {
var cont = e.target.value;
if(cont.length > 3){
this.criteria = this.selItem + "=" + cont;
console.log("Coming here" + this.criteria);
}
},
properties: {
selItem: {
type: String,
value: ""
},
show: {
type: Boolean,
value: false
},
criteria: {
type: String,
value: "Show",
notify: true,
reflecToAttribute: true
}
},
ready: function(e){
}
});
</script>

iron-pages: Page Changed Event

Is there any event that can be captured by a web component when the page is changed, or even a lifecycle callback?
I tried using the attached callback but it doesn't being fired again..
From the parent element of <iron-pages>, you could observe changes to <iron-pages>.selected to monitor the page index/name:
<head>
<base href="https://polygit.org/polymer+1.9.3/components/">
<script src="webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="polymer/polymer.html">
<link rel="import" href="paper-button/paper-button.html">
<link rel="import" href="iron-pages/iron-pages.html">
</head>
<body>
<x-foo></x-foo>
<dom-module id="x-foo">
<template>
<iron-pages id="pages" selected="{{selected}}">
<div>One</div>
<div>Two</div>
<div>Three</div>
</iron-pages>
<paper-button on-tap="_prev">Prev</paper-button>
<paper-button on-tap="_next">Next</paper-button>
</template>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'x-foo',
properties : {
selected: {
type: Number,
value: 0,
observer: '_selectedChanged'
}
},
_selectedChanged: function(newPage, oldPage) {
console.log('<iron-pages>.selected', 'new', newPage, 'old', oldPage);
},
_prev: function() {
this.$.pages.selectPrevious();
},
_next: function() {
this.$.pages.selectNext();
}
});
});
</script>
</dom-module>
</body>
codepen
Or you could setup an event listener for the <iron-pages>.iron-select and <iron-pages>.iron-deselect events in order to watch the selected and deselected elements.
<head>
<base href="https://polygit.org/polymer+1.9.3/components/">
<script src="webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="polymer/polymer.html">
<link rel="import" href="paper-button/paper-button.html">
<link rel="import" href="iron-pages/iron-pages.html">
</head>
<body>
<x-foo></x-foo>
<dom-module id="x-foo">
<template>
<iron-pages id="pages" selected="0"
on-iron-select="_pageSelected"
on-iron-deselect="_pageDeselected">
<div>One</div>
<div>Two</div>
<div>Three</div>
</iron-pages>
<paper-button on-tap="_prev">Prev</paper-button>
<paper-button on-tap="_next">Next</paper-button>
</template>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'x-foo',
_pageSelected: function(e) {
var page = e.detail.item;
console.log('page selected', page);
},
_pageDeselected: function(e) {
var page = e.detail.item;
console.log('page deselected', page);
},
_prev: function() {
this.$.pages.selectPrevious();
},
_next: function() {
this.$.pages.selectNext();
}
});
});
</script>
</dom-module>
</body>
codepen
Or you could configure <iron-pages>.selectedAttribute so that it sets an attribute on the newly and previously selected pages, which you could observe from within the page itself. When the page selection changes, the previously selected page's attribute is set to false, and the newly selected to true.
<head>
<base href="https://polygit.org/polymer+1.9.3/components/">
<script src="webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="polymer/polymer.html">
<link rel="import" href="paper-button/paper-button.html">
<link rel="import" href="iron-pages/iron-pages.html">
</head>
<body>
<x-foo></x-foo>
<dom-module id="x-foo">
<template>
<iron-pages id="pages" selected="0" selected-attribute="selected">
<x-page data-name="p1">One</x-page>
<x-page data-name="p2">Two</x-page>
<x-page data-name="p3">Three</x-page>
</iron-pages>
<paper-button on-tap="_prev">Prev</paper-button>
<paper-button on-tap="_next">Next</paper-button>
</template>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'x-foo',
_prev: function() {
this.$.pages.selectPrevious();
},
_next: function() {
this.$.pages.selectNext();
}
});
});
</script>
</dom-module>
<dom-module id="x-page">
<template>
<content id="content"></content>
</template>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'x-page',
properties: {
selected: {
type: Boolean,
value: false,
observer: '_selectedChanged'
}
},
_selectedChanged: function(selected) {
console.log('<x-page>.sel', this.dataset.name, selected);
}
});
});
</script>
</dom-module>
</body>
codepen
Yes there's the 'iron-select' event. You can create a listener on an element and have it listen for this event.
'iron-activate' is triggered right before the item changes, if you prefer.
Here's the link to all the iron-pages events: https://elements.polymer-project.org/elements/iron-pages#event-iron-activate

how to convert html to pdf with specific font or language using pdfmake

This is just a simple html file using pdfmake .
I click a button and then open a pdf file .
using :
pdfMake.createPdf(docDefinition).open();
it's ok , but now i want to see a specific language (ex:Bangla) in my pdfpage . how it is possible . please help or suggest me .
header part:
<head>
<!-- <meta charset="utf-8" />-->
<meta http-equiv="Content-Type" content="text/html" meta charset="utf-8" />
<title>html to pdf</title>
<link href="css/main.css" rel="stylesheet">
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='pdfmake/build/pdfmake.min.js'></script>
<script src='pdfmake/build/vfs_fonts.js'></script>
<script src='build/pdfmake.min.js'></script>
<script src='build/vfs_fonts.js'></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</head>
body part :
<body>
<h1>Hello World</h1>
<div class="btn-group">
<div class="btn btn-success buttin_click_1" type="button">download</div>
<div class="btn btn-danger button_click_2" type="button">open</div>
</div>
</body>
Script :
<script>
$(document).ready(function () {
var docDefinition = {
content: 'This is an sample PDF printed with pdfMake ami '
};
$('.buttin_click_1').click(function () {
console.log('btn 1 clicked');
pdfMake.createPdf(docDefinition).open();
});
$('.button_click_2').click(function () {
console.log('btn 2 clicked');
});
});
</script>
Thank you .
Import the Font in pdfMake.
Afterwards update the vfs_fonts.js as described on github
assign pdfMake.fonts in your javascript
$(document).ready(function () {
pdfMake.fonts = {
'SolaimanLipi': {
normal: 'SolaimanLipi-Regular.ttf',
bold: 'SolaimanLipi-Medium.ttf'
}
};
var docDefinition = {
content: 'হ্যালো',
defaultStyle:{
font: 'SolaimanLipi'
}
};
$('.buttin_click_1').click(function () {
console.log('btn 1 clicked');
pdfMake.createPdf(docDefinition).open();
});
$('.button_click_2').click(function () {
console.log('btn 2 clicked');
});
});

Dragging in Fabric.js

I feel strange that I cannot find the actual dragging-handling code in Fabric.js's demo (for example, this one), but the objects are already draggable "automatically", which is not my case. Here's my code in an external test.js file:
$(function(){
var canvas = new fabric.Canvas('c');
canvas.setWidth(window.innerWidth);
canvas.setHeight(window.innerHeight);
fabric.Image.fromURL('1.png', function(img) {
var group = new fabric.Group([img],
{
hasBorders: false,
hasControls: false,
selectable: true,
evented: true
})
canvas.add(group).setActiveObject(group);
},
{
originX: 'left',
originY: 'top'
});
canvas.renderAll();
});
And here is the test.html:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>test</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.3.0/fabric.min.js"></script>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
<canvas id="c"></canvas>
</body>
</html>
Am I missing something? Thank you.
UPDATE: solved by using the newest fabricjs (1.3.12) in github.

Resources