Skip to content

Instantly share code, notes, and snippets.

getEditorAPI(){
{
getPosition(selection) : Promise<x, y> {
}
getSelection(){
this._seelction
}
add({}, selection){
@mkozhukh
mkozhukh / do.sh
Created February 22, 2018 10:31
run script in each folder
#!/bin/bash
C=''
whitespace="[[:space:]]"
for i in "$@"
do
if [[ $i =~ $whitespace ]]
then
i=\"$i\"
fi
//Show component names in layout
var t = document.querySelectorAll("[view_id]"); for (var i=0; i<t.length; i++) {
var box = $$(t[i].getAttribute("view_id"));
if (!box.getChildViews || !box.getChildViews().length)
t[i].innerHTML = "<div style='font-size:14px; text-align:center; position: relative; top: 50%; margin-top:-20px;'>"+box.name+"</div>";
}
@mkozhukh
mkozhukh / handler.js
Created October 28, 2016 11:18
Handling GTM without jquery
var ready = function(fn){ if ( document.readyState === 'complete' ) return fn(); else document.addEventListener( 'DOMContentLoaded', fn, false ); };
var click = function(a, fn){ var node = document.querySelector(a); if (node) node.addEventListener("click", fn, false); }
ready(function(){
click('селектор нужного объекта', function() {
dataLayer.push({'event':'GAevent', 'eventCategory':'Заданное нами значение', 'eventAction':'Заданное нами значение', 'eventLabel':'Заданное нами значение'});
});
});
@mkozhukh
mkozhukh / models--records.js
Created June 13, 2016 10:08
Webix Jet, refreshing data collection on view show
define([],function(){
var collection = new webix.DataCollection({
url:"rest->server/records.php",
save:"rest->server/records.php"
});
return {
data: collection,
refresh:function(){
@mkozhukh
mkozhukh / gist:bd16d6b38503ec4809fc
Created April 22, 2015 20:52
Webix + .Net, dynamic data loading
public ActionResult Data(int start = 0, int count = 0)
{
if (start == 0)
{
//initial data loading
return Json(new
{
data = db.Movies.OrderBy(c => c.Rating).Take(50).ToList(),
total_count = db.Movies.Count()
}, JsonRequestBehavior.AllowGet);
@mkozhukh
mkozhukh / gist:25bc0cac96313fa81fcf
Created April 15, 2015 12:25
Patch for data sorting performance in IE (using merge-sort instead of quick-sort)
webix.ready(function(){
var sort = function(array, method) {
var len = array.length;
if(len < 2) {
return array;
}
var pivot = Math.ceil(len/2);
return merge(sort(array.slice(0,pivot), method), sort(array.slice(pivot), method), method);
@mkozhukh
mkozhukh / gist:a5c8876acd9121a463c2
Created November 26, 2014 12:58
UglifyJS config to remove asserts and debug code from webix_debug.js
var is_debug_name = function(name){
var test = name.toString();
if ((test.indexOf("debug") === 0) || (test.indexOf("log") === 0) || (test.indexOf("assert") === 0))
return true;
};
var is_private_name = function(name){
if (name.toString().charAt(0) == "_") return true;
};
@mkozhukh
mkozhukh / gist:8503293
Created January 19, 2014 10:59
Using pager along with Webix Pivot
webix.ready(function(){
var pivot = {
container:"testA",
view:"pivot",
datatable:{
pager:"pivotPager"
},
height:400,
width:1000,
data:pivot_dataset,
@mkozhukh
mkozhukh / existing.js
Last active December 21, 2015 22:49
webix datatable - export only some columns
$$("admin-customer-grid").exportToExcel("excel/generate.php",{
id:true, //add id column to the export
columns:{ //columns which need to be exported
customer:{ //we can define different width and template for exported data
template:webix.template("#customer#"),
width:500
},
region_id:true,
country_id:true,
}