-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
4,463 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* jshint browser: true */ | ||
|
||
// The properties that we copy into a mirrored div. | ||
// Note that some browsers, such as Firefox, | ||
// do not concatenate properties, i.e. padding-top, bottom etc. -> padding, | ||
// so we have to do every single property specifically. | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.getCaretCoordinates = getCaretCoordinates; | ||
var properties = ['direction', // RTL support | ||
'boxSizing', 'width', // on Chrome and IE, exclude the scrollbar, so the mirror div wraps exactly as the textarea does | ||
'height', 'overflowX', 'overflowY', // copy the scrollbar for IE | ||
|
||
'borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth', 'borderStyle', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', | ||
|
||
// https://developer.mozilla.org/en-US/docs/Web/CSS/font | ||
'fontStyle', 'fontVariant', 'fontWeight', 'fontStretch', 'fontSize', 'fontSizeAdjust', 'lineHeight', 'fontFamily', 'textAlign', 'textTransform', 'textIndent', 'textDecoration', // might not make a difference, but better be safe | ||
|
||
'letterSpacing', 'wordSpacing', 'tabSize', 'MozTabSize']; | ||
|
||
var isFirefox = window.mozInnerScreenX != null; | ||
|
||
function getCaretCoordinates(element, position) { | ||
// mirrored div | ||
var div = document.createElement('div'); | ||
div.id = 'input-textarea-caret-position-mirror-div'; | ||
document.body.appendChild(div); | ||
|
||
var style = div.style; | ||
var computed = window.getComputedStyle ? getComputedStyle(element) : element.currentStyle; // currentStyle for IE < 9 | ||
|
||
// default textarea styles | ||
style.whiteSpace = 'nowrap'; | ||
if (element.nodeName !== 'INPUT') style.wordWrap = 'nowrap'; // only for textarea-s | ||
|
||
// position off-screen | ||
style.position = 'absolute'; // required to return coordinates properly | ||
style.visibility = 'hidden'; // not 'display: none' because we want rendering | ||
|
||
// transfer the element's properties to the div | ||
properties.forEach(function (prop) { | ||
style[prop] = computed[prop]; | ||
}); | ||
|
||
if (isFirefox) { | ||
// Firefox lies about the overflow property for textareas: https://bugzilla.mozilla.org/show_bug.cgi?id=984275 | ||
if (element.scrollHeight > parseInt(computed.height)) style.overflowY = 'scroll'; | ||
} else { | ||
style.overflow = 'hidden'; // for Chrome to not render a scrollbar; IE keeps overflowY = 'scroll' | ||
} | ||
|
||
div.textContent = element.value.substring(0, position); | ||
// the second special handling for input type="text" vs textarea: spaces need to be replaced with non-breaking spaces - http://stackoverflow.com/a/13402035/1269037 | ||
if (element.nodeName === 'INPUT') div.textContent = div.textContent.replace(/\s/g, ' '); | ||
|
||
var span = document.createElement('span'); | ||
// Wrapping must be replicated *exactly*, including when a long word gets | ||
// onto the next line, with whitespace at the end of the line before (#7). | ||
// The *only* reliable way to do that is to copy the *entire* rest of the | ||
// textarea's content into the <span> created at the caret position. | ||
// for inputs, just '.' would be enough, but why bother? | ||
span.textContent = element.value.substring(position) || '.'; // || because a completely empty faux span doesn't render at all | ||
div.appendChild(span); | ||
|
||
var coordinates = { | ||
top: span.offsetTop + parseInt(computed['borderTopWidth']), | ||
left: span.offsetLeft + parseInt(computed['borderLeftWidth']) | ||
}; | ||
|
||
document.body.removeChild(div); | ||
|
||
return coordinates; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
|
||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
|
||
var _parserJs = require('./parser.js'); | ||
|
||
var _parserSql_builderJs = require('./parser/sql_builder.js'); | ||
|
||
var PQL = (function () { | ||
function PQL() { | ||
_classCallCheck(this, PQL); | ||
} | ||
|
||
_createClass(PQL, null, [{ | ||
key: 'getSQL', | ||
value: function getSQL(_ref) { | ||
var _this = this; | ||
|
||
var query = _ref.query; | ||
var table = _ref.table; | ||
var group = _ref.group; | ||
var selects = _ref.selects; | ||
var orderBys = _ref.orderBys; | ||
var variables = _ref.variables; | ||
|
||
var query_parser = new _parserJs.PARSER(query, table, false, this.defaultConfig, [], variables); | ||
if (query_parser.hasError()) { | ||
throw query_parser.getError(); | ||
} | ||
|
||
if (group === undefined) { | ||
group = 'id'; | ||
} | ||
var group_parser = new _parserJs.PARSER(group, table, true, this.defaultConfig, [], variables); | ||
if (group_parser.hasError()) { | ||
throw group_parser.getError(); | ||
} | ||
|
||
var select_parsers = new Map(); | ||
if (selects instanceof Map) { | ||
selects.forEach(function (v, k) { | ||
var val = new _parserJs.PARSER(v, table, false, _this.defaultConfig, [], variables); | ||
if (val.hasError()) { | ||
throw val.getError(); | ||
} | ||
select_parsers.set(k, val); | ||
}); | ||
} else { | ||
for (var k in selects) { | ||
if (selects.hasOwnProperty(k)) { | ||
var v = new _parserJs.PARSER(selects[k], table, false, this.defaultConfig, [], variables); | ||
if (v.hasError()) { | ||
throw v.getError(); | ||
} | ||
select_parsers.set(k, v); | ||
} | ||
} | ||
} | ||
|
||
var order_by_parsers = new Map(); | ||
if (orderBys instanceof Map) { | ||
orderBys.forEach(function (v, k) { | ||
// This one is backwards... be warned that k is the string v is the [desc, asc] | ||
var val = new _parserJs.PARSER(k, table, false, _this.defaultConfig, [], variables); | ||
if (val.hasError()) { | ||
throw val.getError(); | ||
} | ||
order_by_parsers.set(val, v); | ||
}); | ||
} else { | ||
for (var k in orderBys) { | ||
if (orderBys.hasOwnProperty(k)) { | ||
var v = new _parserJs.PARSER(k, table, false, this.defaultConfig, [], variables); | ||
if (v.hasError()) { | ||
throw v.getError(); | ||
} | ||
order_by_parsers.set(v, orderBys[k]); | ||
} | ||
} | ||
} | ||
|
||
var sb = new _parserSql_builderJs.SQL_BUILDER({ | ||
query: query_parser, | ||
table: table, | ||
group: group_parser, | ||
selects: select_parsers, | ||
orderBys: order_by_parsers | ||
}); | ||
return sb.toString(); | ||
} | ||
}, { | ||
key: 'setDefaultConfig', | ||
value: function setDefaultConfig(config) { | ||
PQL._defaultConfig = config; | ||
} | ||
}, { | ||
key: 'defaultConfig', | ||
get: function get() { | ||
return PQL._defaultConfig; | ||
}, | ||
set: function set(v) { | ||
PQL._defaultConfig = v; | ||
} | ||
}]); | ||
|
||
return PQL; | ||
})(); | ||
|
||
exports.PQL = PQL; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"use strict"; | ||
var PQL = window.PQL; | ||
PQL.OPCODES = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
|
||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
|
||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
|
||
var _seperatorsJs = require('./seperators.js'); | ||
|
||
var AND = (function (_SEPERATORS) { | ||
_inherits(AND, _SEPERATORS); | ||
|
||
function AND() { | ||
_classCallCheck(this, AND); | ||
|
||
_get(Object.getPrototypeOf(AND.prototype), 'constructor', this).apply(this, arguments); | ||
} | ||
|
||
_createClass(AND, [{ | ||
key: 'getSQL', | ||
value: function getSQL() { | ||
return 'AND'; | ||
} | ||
}]); | ||
|
||
return AND; | ||
})(_seperatorsJs.SEPERATORS); | ||
|
||
exports.AND = AND; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
|
||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
|
||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
|
||
var _opcodeJs = require('./../opcode.js'); | ||
|
||
var COMPARITOR = (function (_OPCODE) { | ||
_inherits(COMPARITOR, _OPCODE); | ||
|
||
function COMPARITOR() { | ||
_classCallCheck(this, COMPARITOR); | ||
|
||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
|
||
_get(Object.getPrototypeOf(COMPARITOR.prototype), 'constructor', this).apply(this, args); | ||
this._needs_group_cache = null; | ||
} | ||
|
||
_createClass(COMPARITOR, [{ | ||
key: 'setLeft', | ||
value: function setLeft(v) { | ||
this.left = v; | ||
return this; | ||
} | ||
}, { | ||
key: 'setRight', | ||
value: function setRight(v) { | ||
this.right = v; | ||
return this; | ||
} | ||
}, { | ||
key: 'needsGroup', | ||
value: function needsGroup() { | ||
if (this._needs_group_cache !== null) { | ||
return this._needs_group_cache; | ||
} | ||
if (this.left) { | ||
if (this.left.needsGroup()) { | ||
return this._needs_group_cache = true; | ||
} | ||
} | ||
if (this.right) { | ||
if (this.right.needsGroup()) { | ||
return this._needs_group_cache = true; | ||
} | ||
} | ||
return this._needs_group_cache = false; | ||
} | ||
}, { | ||
key: 'left', | ||
get: function get() { | ||
return this._left; | ||
}, | ||
set: function set(v) { | ||
return this._left = v; | ||
} | ||
}, { | ||
key: 'right', | ||
get: function get() { | ||
return this._right; | ||
}, | ||
set: function set(v) { | ||
return this._right = v; | ||
} | ||
}]); | ||
|
||
return COMPARITOR; | ||
})(_opcodeJs.OPCODE); | ||
|
||
exports.COMPARITOR = COMPARITOR; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
|
||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
|
||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
|
||
var _comparitorJs = require('./comparitor.js'); | ||
|
||
var _nullJs = require('./../null.js'); | ||
|
||
var _constants_arrayJs = require('./../constants_array.js'); | ||
|
||
var EQUAL = (function (_COMPARITOR) { | ||
_inherits(EQUAL, _COMPARITOR); | ||
|
||
function EQUAL() { | ||
_classCallCheck(this, EQUAL); | ||
|
||
_get(Object.getPrototypeOf(EQUAL.prototype), 'constructor', this).apply(this, arguments); | ||
} | ||
|
||
_createClass(EQUAL, [{ | ||
key: 'getSQL', | ||
value: function getSQL(query_object) { | ||
var _this = this; | ||
|
||
var left_type = undefined; | ||
var right_type = undefined; | ||
if (this.left.getType) { | ||
left_type = this.left.getType(); | ||
} | ||
if (this.right.getType) { | ||
right_type = this.right.getType(); | ||
} | ||
if (this.right.isInstanceOf(_nullJs.NULL)) { | ||
return this.left.getSQL(query_object, right_type) + ' IS NULL'; | ||
} else if (this.right.isInstanceOf(_constants_arrayJs.CONSTANTS_ARRAY)) { | ||
var _ret = (function () { | ||
var right_values = _this.right.getValue(); | ||
var sql_safe_values = []; | ||
right_values.forEach(function (v) { | ||
sql_safe_values.push(v.getSQL(query_object, left_type)); | ||
}); | ||
return { | ||
v: _this.left.getSQL(query_object, right_type) + ' IN (' + sql_safe_values.join(', ') + ')' | ||
}; | ||
})(); | ||
|
||
if (typeof _ret === 'object') return _ret.v; | ||
} else { | ||
return this.left.getSQL(query_object, right_type) + ' = ' + this.right.getSQL(query_object, left_type); | ||
} | ||
} | ||
}], [{ | ||
key: 'comparitors', | ||
set: function set(v) {}, | ||
get: function get() { | ||
return ['=', ':']; | ||
} | ||
}]); | ||
|
||
return EQUAL; | ||
})(_comparitorJs.COMPARITOR); | ||
|
||
exports.EQUAL = EQUAL; |
Oops, something went wrong.