Skip to content

Instantly share code, notes, and snippets.

@lahmatiy
lahmatiy / gist:5593176
Created May 16, 2013
Text that always in center and fit window size
View gist:5593176
<!doctype html>
<html>
<body>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100" style="position: fixed; width: 100%; height: 100%">
<text x="0" y="81" fill="black" stroke="black" font-size="100">A!</text>
</svg>
</body>
</html>
@lahmatiy
lahmatiy / .bowerrc
Created Jun 1, 2013
Usually we store 2 files in project for bower: .bowerrc for settings & bower.json for description and dependencies. But we can use single file for both, just put everything into .bowerrc and set "json" property to ".bowerrc".
View .bowerrc
{
"json": ".bowerrc",
"directory": "lib",
"name": "my-project",
"version": "1.0.0",
"dependencies": {
"basisjs": "0.9.0"
}
}
@lahmatiy
lahmatiy / basis_net_rpc_callback_patch.js
Created Jun 29, 2013
This patch bring back basis.net.rpc.callback which was droped in 0.9.4
View basis_net_rpc_callback_patch.js
basis.require('basis.data');
basis.require('basis.net.rpc');
basis.net.rpc.extend({
callback: {
setProcessing: function(){
this.setState(basis.data.STATE.PROCESSING);
},
setUndefined: function(){
this.setState(basis.data.STATE.UNDEFINED);
@lahmatiy
lahmatiy / basis_net_AbstractRequest_failure_on_abort_patch.js
Last active Dec 19, 2015
Patch that emit failure event before abort event for AbstractRequest. This behaviour was changed in 0.9.4
View basis_net_AbstractRequest_failure_on_abort_patch.js
basis.require('basis.event');
basis.require('basis.data');
basis.require('basis.net');
basis.net.AbstractRequest.extend({
stateOnAbort: basis.data.STATE.ERROR,
emit_abort: function(){
this.emit_failure();
basis.event.events.abort.call(this);
}
@lahmatiy
lahmatiy / basis_data_DataObject_restore.js
Created Jun 30, 2013
Patch to restore basis.data.DataObject alias for basis.data.Object (dropped in 0.9.4)
View basis_data_DataObject_restore.js
basis.require('basis.data');
basis.data.DataObject = basis.data.Object;
@lahmatiy
lahmatiy / basis.data.Value#updateCount.js
Last active Dec 19, 2015
Patch to restore basis.data.Value#updateCount (dropped in 0.9.4)
View basis.data.Value#updateCount.js
basis.require('basis.data');
(function(){
var emit_change_ = basis.data.Value.prototype.emit_change;
basis.data.Value.extend({
updateCount: 0,
emit_change: function(){
this.updateCount += 1;
emit_change_.apply(this, arguments);
}
@lahmatiy
lahmatiy / basis.data.Value#set_forceEvent.js
Last active Dec 19, 2015
Path to restore forceEvent argument and boolean result for basis.data.Value#set (dropped in 0.9.4)
View basis.data.Value#set_forceEvent.js
basis.require('basis.data');
(function(){
var set_ = basis.data.Value.prototype.set;
basis.data.Value.prototype.set = function(value, forceEvent){
var valueBeforeSet = this.value;
set_.call(this, value);
@lahmatiy
lahmatiy / basis.data.property.AbstractProperty_restore.js
Created Jun 30, 2013
Path to restore basis.data.property.AbstractProperty (dropped in 0.9.4)
View basis.data.property.AbstractProperty_restore.js
basis.require('basis.data');
basis.require('basis.data.property');
basis.namespace('basis.data.property').extend({
AbstractProperty: basis.data.Value
});
@lahmatiy
lahmatiy / basis.net.Transport_requestHeaders_patch.js
Last active Dec 19, 2015
Returns extra request headers for basis.net.Transport that sending prior to 0.9.5
View basis.net.Transport_requestHeaders_patch.js
basis.require('basis.net');
basis.net.AjaxTransport.prototype.requestHeaders['X-Requested-With'] = 'XMLHttpRequest';
basis.net.AjaxTransport.prototype.requestHeaders['X-Powered-By'] = 'basis.js';
@lahmatiy
lahmatiy / knowhow_indexFieldOnEntityNestedDatasets.js
Last active Dec 19, 2015
HOWTO: Do you know that you can easily create dataset index fields for nested datasets for Entity?
View knowhow_indexFieldOnEntityNestedDatasets.js
basis.require('basis.entity');
basis.require('basis.data.index');
// create type with single field, that used for EntitySet
var Item = basis.entity.createType('SomeType', {
value: Number
});
// main Entity type
var DemoType = basis.entity.createType('DemoType', {