frontend

Is it possible to make text-overflow:ellipsis for select with css only?

此生再无相见时 提交于 2019-12-01 05:49:38
Is it possible to make text-overflow: ellipsis; for select ? In the div it is simple. When the string is too long there are dots, I need the same in select . I know, that it is possible with js , but I would like to get "light" css decision: .select { box-sizing: border-box; display: block; width: 200px; height: 34.5px; padding: 5px 22px 3px 11px; font: 400 16px/24px sans-serif; color: #464a4c; vertical-align: middle; background: #fff url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiID8

Fabric JS - send Objects to Back

北战南征 提交于 2019-12-01 03:56:45
When you select an object (in my example a polygon), it gets automatically moved to the Front. I'm searching for a way to prevent the movement on the z-axis or send it backwards after the selection, maybe someone can help? Here is a link to a simple example: http://jsfiddle.net/98cuf9b7/1/ When you select one of the Polygons, it gets moved to the Front. I tried to send it backwards after the selection, but even if the "canvas.sendToBack(object)" function is called, it's still remains in the Front. The code in my Example is: var canvas = new fabric.Canvas('c'); var pol = new fabric.Polygon([ {x

Is it possible to make text-overflow:ellipsis for select with css only?

久未见 提交于 2019-12-01 02:22:28
问题 Is it possible to make text-overflow: ellipsis; for select ? In the div it is simple. When the string is too long there are dots, I need the same in select . I know, that it is possible with js , but I would like to get "light" css decision: .select { box-sizing: border-box; display: block; width: 200px; height: 34.5px; padding: 5px 22px 3px 11px; font: 400 16px/24px sans-serif; color: #464a4c; vertical-align: middle; background: #fff url(data:image/svg+xml;base64

github: comment will be remaining even if reload browser, why?

为君一笑 提交于 2019-12-01 01:08:06
问题 When I write a comment with github's issue page, I noticed that the comment body remains even if I reload the browser. I have checked localStorage, sessionStorage, cacheStorage, IndexedDB, cookie, but I found no instance of the sentence that I wrote. Also, I have checked the network tab of Chrome Devtool, but I could not find any suspicious network traffic. How does github.com achieve this recovery function? 回答1: They are using SessionStorage to do this: On Page Leave: select all of the input

Print from frontend javascript?

做~自己de王妃 提交于 2019-11-30 20:29:39
Is it possible to print something with a printer with javascript in the browser? I want to print a receipt number, so if it's possible, what is the fastest printer so when the user clicks on a button it will print out eg. "1234" on a small paper. Thanks You can't access the printer directly from Javascript but you can call window.print() which will initiate the standard browser print behaviour. Using this, you could try two techniques to achieve what you're after: Just before calling window.print() inject a dynamic print stylesheet that only shows the elements with the text you're wanting to

jsTree: progressive_render with ajax / render nodes from an array

拥有回忆 提交于 2019-11-30 20:07:35
This is regarding the jsTree jQuery plugin . I've been struggling with this for a while now only to realise it's not (natively) possible to do, so I thought about the following solution to my problem below (which doesn't work). I have a tree that uses the json_data plugin with ajax. Once you open a specific node the result from the server is an array of over 1000 json nodes. The response is pretty fast but the rendering itself takes a while (the user experience is that he gets the annoying "script not responding - stop script / continue" message. The solution I thought about was limiting the

Take a value 1-31 and convert it to ordinal date w/ JavaScript

做~自己de王妃 提交于 2019-11-30 17:47:54
Is there a JavaScript code snippet to take a value of 1-31 and convert it to 1st, 2nd, 3rd, etc? Thanks! Pradeep Sanjaya function getOrdinal(n) { var s=["th","st","nd","rd"], v=n%100; return n+(s[(v-20)%10]||s[v]||s[0]); } Thanks @RobG bit modified version function getOrdinal(n) { if((parseFloat(n) == parseInt(n)) && !isNaN(n)){ var s=["th","st","nd","rd"], v=n%100; return n+(s[(v-20)%10]||s[v]||s[0]); } return n; } Tests getOrdinal("test"); // test getOrdinal(1.5); // 1.5 getOrdinal(1); // 1st getOrdinal(2); // 2nd getOrdinal(3); // 3rd getOrdinal(4); // 4th getOrdinal(true); // true

Export to CSV button in react table

杀马特。学长 韩版系。学妹 提交于 2019-11-30 16:31:49
问题 Looking for a way to add an "Export to CSV" button to a react-table which is an npmjs package (https://www.npmjs.com/package/react-table). I need to add a custom button for exporting the table data to an excel sheet in the csv or xls format? 回答1: Take a look at this npm library - https://www.npmjs.com/package/react-csv For example - import {CSVLink, CSVDownload} from 'react-csv'; const csvData =[ ['firstname', 'lastname', 'email'] , ['John', 'Doe' , 'john.doe@xyz.com'] , ['Jane', 'Doe' ,

How do you play a sound on the web browser?

北城以北 提交于 2019-11-30 15:39:20
How do I play a sound on the web browser as notification? You can use the <audio> tag combined with JavaScript to play sounds at a given time. You'll need JavaScript, of course, as it's done on the frontend, and hence, with client-side programming. For example, <audio style="display: none;" id="notification" preload src="path/to/soundfile"> Then, for the scripting, place this somewhere in any part of your script that requires sound notification to occur: document.getElementById('notification').play(); For those who recommend Flash as it's supported in IE, note graceful degradation , where, for

What is the difference between a regular Rails app and a Rails API?

醉酒当歌 提交于 2019-11-30 14:21:28
In the process of learning Rails, I read about how we could combine it with some front-end MV* JavaScript frameworks — such as Backbone.js, Angular.js, or Ember.js — to improve the UX. This introduced (to me) the concept of using Rails as an API, instead of a web app. So, now, I am pretty confused: what is the difference between a regular Rails app and a Rails API? Cyril Duchon-Doris A regular Rails app will use the rails views (erb or haml) to render pages directly. That is to say, it will process the data AND render this data in views, answering directly the client request with a HTML page.