|
@@ -1,45 +1,16 @@
|
|
|
|
|
|
|
|
|
-define(function () {
|
|
|
+define(['./kernel-goodies'], function ($goodies) {
|
|
|
"use strict";
|
|
|
|
|
|
- function defineMethod (klass, name, method) {
|
|
|
- Object.defineProperty(klass.prototype, name, {
|
|
|
- value: method,
|
|
|
- enumerable: false, configurable: true, writable: true
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- function installJSMethod (obj, jsSelector, fn) {
|
|
|
- Object.defineProperty(obj, jsSelector, {
|
|
|
- value: fn,
|
|
|
- enumerable: false, configurable: true, writable: true
|
|
|
- });
|
|
|
- }
|
|
|
+ var defineMethod = $goodies.defineMethod;
|
|
|
+ var installJSMethod = $goodies.installJSMethod;
|
|
|
+ var st2js = $goodies.st2js;
|
|
|
+ var js2st = $goodies.js2st;
|
|
|
|
|
|
function SelectorConversionBrik (brikz, st) {
|
|
|
var st2jsMemo = Object.create(null);
|
|
|
|
|
|
-
|
|
|
- function st2js (string) {
|
|
|
- return '_' + string
|
|
|
- .replace(/:/g, '_')
|
|
|
- .replace(/[\&]/g, '_and')
|
|
|
- .replace(/[\|]/g, '_or')
|
|
|
- .replace(/[+]/g, '_plus')
|
|
|
- .replace(/-/g, '_minus')
|
|
|
- .replace(/[*]/g, '_star')
|
|
|
- .replace(/[\/]/g, '_slash')
|
|
|
- .replace(/[\\]/g, '_backslash')
|
|
|
- .replace(/[\~]/g, '_tild')
|
|
|
- .replace(/%/g, '_percent')
|
|
|
- .replace(/>/g, '_gt')
|
|
|
- .replace(/</g, '_lt')
|
|
|
- .replace(/=/g, '_eq')
|
|
|
- .replace(/,/g, '_comma')
|
|
|
- .replace(/[@]/g, '_at');
|
|
|
- };
|
|
|
-
|
|
|
st.st2js = function (stSelector) {
|
|
|
return st2jsMemo[stSelector] || st2js(stSelector);
|
|
|
};
|
|
@@ -51,36 +22,7 @@ define(function () {
|
|
|
|
|
|
if you modify the following functions, also change st2js
|
|
|
accordingly */
|
|
|
- st.js2st = function (selector) {
|
|
|
- if (selector.match(/^__/)) {
|
|
|
- return binaryJsToSt(selector);
|
|
|
- } else {
|
|
|
- return keywordJsToSt(selector);
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- function keywordJsToSt (selector) {
|
|
|
- return selector.replace(/^_/, '').replace(/_/g, ':');
|
|
|
- }
|
|
|
-
|
|
|
- function binaryJsToSt (selector) {
|
|
|
- return selector
|
|
|
- .replace(/^_/, '')
|
|
|
- .replace(/_and/g, '&')
|
|
|
- .replace(/_or/g, '|')
|
|
|
- .replace(/_plus/g, '+')
|
|
|
- .replace(/_minus/g, '-')
|
|
|
- .replace(/_star/g, '*')
|
|
|
- .replace(/_slash/g, '/')
|
|
|
- .replace(/_backslash/g, '\\')
|
|
|
- .replace(/_tild/g, '~')
|
|
|
- .replace(/_percent/g, '%')
|
|
|
- .replace(/_gt/g, '>')
|
|
|
- .replace(/_lt/g, '<')
|
|
|
- .replace(/_eq/g, '=')
|
|
|
- .replace(/_comma/g, ',')
|
|
|
- .replace(/_at/g, '@');
|
|
|
- }
|
|
|
+ st.js2st = js2st;
|
|
|
|
|
|
st.st2prop = function (stSelector) {
|
|
|
var colonPosition = stSelector.indexOf(':');
|