How to use filter method in stryker-parent

Best JavaScript code snippet using stryker-parent

image_filters.js

Source:image_filters.js Github

copy

Full Screen

1(function() {2 function getAbsolutePath(path) {3 var isAbsolute = /^https?:/.test(path);4 if (isAbsolute) return path;5 var imgEl = _createImageElement();6 imgEl.src = path;7 var src = imgEl.src;8 imgEl = null;9 return src;10 }11 var IMG_SRC = fabric.isLikelyNode ? (__dirname + '/../fixtures/test_image.gif') : getAbsolutePath('../fixtures/test_image.gif'),12 IMG_WIDTH = 276,13 IMG_HEIGHT = 110;14 // var REFERENCE_IMG_OBJECT = {15 // 'type': 'image',16 // 'originX': 'left',17 // 'originY': 'top',18 // 'left': 0,19 // 'top': 0,20 // 'width': IMG_WIDTH, // node-canvas doesn't seem to allow setting width/height on image objects21 // 'height': IMG_HEIGHT, // or does it now?22 // 'fill': 'rgb(0,0,0)',23 // 'stroke': null,24 // 'strokeWidth': 1,25 // 'strokeDashArray': null,26 // 'strokeLineCap': 'butt',27 // 'strokeLineJoin': 'miter',28 // 'strokeMiterLimit': 10,29 // 'scaleX': 1,30 // 'scaleY': 1,31 // 'angle': 0,32 // 'flipX': false,33 // 'flipY': false,34 // 'opacity': 1,35 // 'src': fabric.isLikelyNode ? undefined : IMG_SRC,36 // 'selectable': true,37 // 'hasControls': true,38 // 'hasBorders': true,39 // 'hasRotatingPoint': true,40 // 'transparentCorners': true,41 // 'perPixelTargetFind': false,42 // 'shadow': null,43 // 'visible': true,44 // 'clipTo': null,45 // 'filters': []46 // };47 function _createImageElement() {48 return fabric.isLikelyNode ? new (require('canvas').Image)() : fabric.document.createElement('img');49 }50 function _createImageObject(width, height, callback) {51 var elImage = _createImageElement();52 elImage.width = width;53 elImage.height = height;54 setSrc(elImage, IMG_SRC, function() {55 callback(new fabric.Image(elImage));56 });57 }58 function createImageObject(callback) {59 return _createImageObject(IMG_WIDTH, IMG_HEIGHT, callback);60 }61 function setSrc(img, src, callback) {62 if (fabric.isLikelyNode) {63 require('fs').readFile(src, function(err, imgData) {64 if (err) throw err;65 img.src = imgData;66 callback && callback();67 });68 }69 else {70 img.src = src;71 callback && callback();72 }73 }74 QUnit.module('fabric.Image.filters.Brightness');75 test('constructor', function() {76 ok(fabric.Image.filters.Brightness);77 var filter = new fabric.Image.filters.Brightness();78 ok(filter instanceof fabric.Image.filters.Brightness, 'should inherit from fabric.Image.filters.Brightness');79 });80 test('properties', function() {81 var filter = new fabric.Image.filters.Brightness();82 equal(filter.type, 'Brightness');83 equal(filter.brightness, 0);84 var filter2 = new fabric.Image.filters.Brightness({brightness: 30});85 equal(filter2.brightness, 30);86 });87 test('applyTo', function() {88 var filter = new fabric.Image.filters.Brightness();89 ok(typeof filter.applyTo == 'function');90 });91 test('toObject', function() {92 var filter = new fabric.Image.filters.Brightness();93 ok(typeof filter.toObject == 'function');94 var object = filter.toObject();95 equal(JSON.stringify(object), '{"type":"Brightness","brightness":0}');96 filter.brightness = 100;97 object = filter.toObject();98 equal(JSON.stringify(object), '{"type":"Brightness","brightness":100}');99 });100 test('toJSON', function() {101 var filter = new fabric.Image.filters.Brightness();102 ok(typeof filter.toJSON == 'function');103 var json = filter.toJSON();104 equal(JSON.stringify(json), '{"type":"Brightness","brightness":0}');105 filter.brightness = 100;106 json = filter.toJSON();107 equal(JSON.stringify(json), '{"type":"Brightness","brightness":100}');108 });109 test('fromObject', function() {110 var filter = new fabric.Image.filters.Brightness();111 var object = filter.toObject();112 deepEqual(fabric.Image.filters.Brightness.fromObject(object), filter);113 });114 QUnit.module('fabric.Image.filters.Convolute');115 test('constructor', function() {116 ok(fabric.Image.filters.Convolute);117 var filter = new fabric.Image.filters.Convolute();118 ok(filter instanceof fabric.Image.filters.Convolute, 'should inherit from fabric.Image.filters.Convolute');119 });120 test('properties', function() {121 var filter = new fabric.Image.filters.Convolute();122 equal(filter.type, 'Convolute');123 equal(filter.opaque, undefined);124 deepEqual(filter.matrix, [0,0,0,0,1,0,0,0,0]);125 var filter2 = new fabric.Image.filters.Convolute({opaque: 0.5, matrix: [1,-1,1,0,1,0,0,0,0]});126 equal(filter2.opaque, 0.5);127 deepEqual(filter2.matrix, [1,-1,1,0,1,0,0,0,0]);128 });129 test('applyTo', function() {130 var filter = new fabric.Image.filters.Convolute();131 ok(typeof filter.applyTo == 'function');132 });133 test('toObject', function() {134 var filter = new fabric.Image.filters.Convolute({opaque: 1});135 ok(typeof filter.toObject == 'function');136 var object = filter.toObject();137 equal(JSON.stringify(object), '{"type":"Convolute","opaque":1,"matrix":[0,0,0,0,1,0,0,0,0]}');138 });139 test('toJSON', function() {140 var filter = new fabric.Image.filters.Convolute({opaque: 1});141 ok(typeof filter.toJSON == 'function');142 var json = filter.toJSON();143 equal(JSON.stringify(json), '{"type":"Convolute","opaque":1,"matrix":[0,0,0,0,1,0,0,0,0]}');144 });145 test('fromObject', function() {146 var filter = new fabric.Image.filters.Convolute();147 var object = filter.toObject();148 deepEqual(fabric.Image.filters.Convolute.fromObject(object), filter);149 });150 QUnit.module('fabric.Image.filters.GradientTransparency');151 test('constructor', function() {152 ok(fabric.Image.filters.GradientTransparency);153 var filter = new fabric.Image.filters.GradientTransparency();154 ok(filter instanceof fabric.Image.filters.GradientTransparency, 'should inherit from fabric.Image.filters.GradientTransparency');155 });156 test('properties', function() {157 var filter = new fabric.Image.filters.GradientTransparency();158 equal(filter.type, 'GradientTransparency');159 equal(filter.threshold, 100);160 var filter2 = new fabric.Image.filters.GradientTransparency({threshold: 50});161 equal(filter2.threshold, 50);162 });163 test('applyTo', function() {164 var filter = new fabric.Image.filters.GradientTransparency();165 ok(typeof filter.applyTo == 'function');166 });167 test('toObject', function() {168 var filter = new fabric.Image.filters.GradientTransparency();169 ok(typeof filter.toObject == 'function');170 var object = filter.toObject();171 equal(JSON.stringify(object), '{"type":"GradientTransparency","threshold":100}');172 });173 test('toJSON', function() {174 var filter = new fabric.Image.filters.GradientTransparency();175 ok(typeof filter.toJSON == 'function');176 var json = filter.toJSON();177 equal(JSON.stringify(json), '{"type":"GradientTransparency","threshold":100}');178 });179 test('fromObject', function() {180 var filter = new fabric.Image.filters.GradientTransparency();181 var object = filter.toObject();182 deepEqual(fabric.Image.filters.GradientTransparency.fromObject(object), filter);183 });184 QUnit.module('fabric.Image.filters.Grayscale');185 test('constructor', function() {186 ok(fabric.Image.filters.Grayscale);187 var filter = new fabric.Image.filters.Grayscale();188 ok(filter instanceof fabric.Image.filters.Grayscale, 'should inherit from fabric.Image.filters.Grayscale');189 });190 test('properties', function() {191 var filter = new fabric.Image.filters.Grayscale();192 equal(filter.type, 'Grayscale');193 });194 test('applyTo', function() {195 var filter = new fabric.Image.filters.Grayscale();196 ok(typeof filter.applyTo == 'function');197 });198 test('toObject', function() {199 var filter = new fabric.Image.filters.Grayscale();200 ok(typeof filter.toObject == 'function');201 var object = filter.toObject();202 equal(JSON.stringify(object), '{"type":"Grayscale"}');203 });204 test('toJSON', function() {205 var filter = new fabric.Image.filters.Grayscale();206 ok(typeof filter.toJSON == 'function');207 var json = filter.toJSON();208 equal(JSON.stringify(json), '{"type":"Grayscale"}');209 });210 test('fromObject', function() {211 var filter = new fabric.Image.filters.Grayscale();212 var object = filter.toObject();213 deepEqual(fabric.Image.filters.Grayscale.fromObject(object), filter);214 });215 QUnit.module('fabric.Image.filters.Invert');216 test('constructor', function() {217 ok(fabric.Image.filters.Invert);218 var filter = new fabric.Image.filters.Invert();219 ok(filter instanceof fabric.Image.filters.Invert, 'should inherit from fabric.Image.filters.Invert');220 });221 test('properties', function() {222 var filter = new fabric.Image.filters.Invert();223 equal(filter.type, 'Invert');224 });225 test('applyTo', function() {226 var filter = new fabric.Image.filters.Invert();227 ok(typeof filter.applyTo == 'function');228 });229 test('toObject', function() {230 var filter = new fabric.Image.filters.Invert();231 ok(typeof filter.toObject == 'function');232 var object = filter.toObject();233 equal(JSON.stringify(object), '{"type":"Invert"}');234 });235 test('toJSON', function() {236 var filter = new fabric.Image.filters.Invert();237 ok(typeof filter.toJSON == 'function');238 var json = filter.toJSON();239 equal(JSON.stringify(json), '{"type":"Invert"}');240 });241 test('fromObject', function() {242 var filter = new fabric.Image.filters.Invert();243 var object = filter.toObject();244 deepEqual(fabric.Image.filters.Invert.fromObject(object), filter);245 });246 QUnit.module('fabric.Image.filters.Noise');247 test('constructor', function() {248 ok(fabric.Image.filters.Noise);249 var filter = new fabric.Image.filters.Noise();250 ok(filter instanceof fabric.Image.filters.Noise, 'should inherit from fabric.Image.filters.Noise');251 });252 test('properties', function() {253 var filter = new fabric.Image.filters.Noise();254 equal(filter.type, 'Noise');255 equal(filter.noise, 0);256 var filter2 = new fabric.Image.filters.Noise({noise: 200});257 equal(filter2.noise, 200);258 });259 test('applyTo', function() {260 var filter = new fabric.Image.filters.Noise();261 ok(typeof filter.applyTo == 'function');262 });263 test('toObject', function() {264 var filter = new fabric.Image.filters.Noise();265 ok(typeof filter.toObject == 'function');266 var object = filter.toObject();267 equal(JSON.stringify(object), '{"type":"Noise","noise":0}');268 filter.noise = 100;269 object = filter.toObject();270 equal(JSON.stringify(object), '{"type":"Noise","noise":100}');271 });272 test('toJSON', function() {273 var filter = new fabric.Image.filters.Noise();274 ok(typeof filter.toJSON == 'function');275 var json = filter.toJSON();276 equal(JSON.stringify(json), '{"type":"Noise","noise":0}');277 filter.noise = 100;278 json = filter.toJSON();279 equal(JSON.stringify(json), '{"type":"Noise","noise":100}');280 });281 test('fromObject', function() {282 var filter = new fabric.Image.filters.Noise();283 var object = filter.toObject();284 deepEqual(fabric.Image.filters.Noise.fromObject(object), filter);285 });286 QUnit.module('fabric.Image.filters.Pixelate');287 test('constructor', function() {288 ok(fabric.Image.filters.Pixelate);289 var filter = new fabric.Image.filters.Pixelate();290 ok(filter instanceof fabric.Image.filters.Pixelate, 'should inherit from fabric.Image.filters.Pixelate');291 });292 test('properties', function() {293 var filter = new fabric.Image.filters.Pixelate();294 equal(filter.type, 'Pixelate');295 equal(filter.blocksize, 4);296 var filter2 = new fabric.Image.filters.Pixelate({blocksize: 8});297 equal(filter2.blocksize, 8);298 });299 test('applyTo', function() {300 var filter = new fabric.Image.filters.Pixelate();301 ok(typeof filter.applyTo == 'function');302 });303 test('toObject', function() {304 var filter = new fabric.Image.filters.Pixelate();305 ok(typeof filter.toObject == 'function');306 var object = filter.toObject();307 equal(JSON.stringify(object), '{"type":"Pixelate","blocksize":4}');308 });309 test('toJSON', function() {310 var filter = new fabric.Image.filters.Pixelate();311 ok(typeof filter.toJSON == 'function');312 var json = filter.toJSON();313 equal(JSON.stringify(json), '{"type":"Pixelate","blocksize":4}');314 });315 test('fromObject', function() {316 var filter = new fabric.Image.filters.Pixelate();317 var object = filter.toObject();318 deepEqual(fabric.Image.filters.Pixelate.fromObject(object), filter);319 });320 QUnit.module('fabric.Image.filters.RemoveWhite');321 test('constructor', function() {322 ok(fabric.Image.filters.RemoveWhite);323 var filter = new fabric.Image.filters.RemoveWhite();324 ok(filter instanceof fabric.Image.filters.RemoveWhite, 'should inherit from fabric.Image.filters.RemoveWhite');325 });326 test('properties', function() {327 var filter = new fabric.Image.filters.RemoveWhite();328 equal(filter.type, 'RemoveWhite');329 equal(filter.threshold, 30);330 equal(filter.distance, 20);331 var filter2 = new fabric.Image.filters.RemoveWhite({threshold: 10, distance: 60});332 equal(filter2.threshold, 10);333 equal(filter2.distance, 60);334 });335 test('applyTo', function() {336 var filter = new fabric.Image.filters.RemoveWhite();337 ok(typeof filter.applyTo == 'function');338 });339 test('toObject', function() {340 var filter = new fabric.Image.filters.RemoveWhite();341 ok(typeof filter.toObject == 'function');342 var object = filter.toObject();343 equal(JSON.stringify(object), '{"type":"RemoveWhite","threshold":30,"distance":20}');344 });345 test('toJSON', function() {346 var filter = new fabric.Image.filters.RemoveWhite();347 ok(typeof filter.toJSON == 'function');348 var json = filter.toJSON();349 equal(JSON.stringify(json), '{"type":"RemoveWhite","threshold":30,"distance":20}');350 });351 test('fromObject', function() {352 var filter = new fabric.Image.filters.RemoveWhite();353 var object = filter.toObject();354 deepEqual(fabric.Image.filters.RemoveWhite.fromObject(object), filter);355 });356 QUnit.module('fabric.Image.filters.Sepia2');357 test('constructor', function() {358 ok(fabric.Image.filters.Sepia2);359 var filter = new fabric.Image.filters.Sepia2();360 ok(filter instanceof fabric.Image.filters.Sepia2, 'should inherit from fabric.Image.filters.Sepia2');361 });362 test('properties', function() {363 var filter = new fabric.Image.filters.Sepia2();364 equal(filter.type, 'Sepia2');365 });366 test('applyTo', function() {367 var filter = new fabric.Image.filters.Sepia2();368 ok(typeof filter.applyTo == 'function');369 });370 test('toObject', function() {371 var filter = new fabric.Image.filters.Sepia2();372 ok(typeof filter.toObject == 'function');373 var object = filter.toObject();374 equal(JSON.stringify(object), '{"type":"Sepia2"}');375 });376 test('toJSON', function() {377 var filter = new fabric.Image.filters.Sepia2();378 ok(typeof filter.toJSON == 'function');379 var json = filter.toJSON();380 equal(JSON.stringify(json), '{"type":"Sepia2"}');381 });382 test('fromObject', function() {383 var filter = new fabric.Image.filters.Sepia2();384 var object = filter.toObject();385 deepEqual(fabric.Image.filters.Sepia2.fromObject(object), filter);386 });387 QUnit.module('fabric.Image.filters.Sepia');388 test('constructor', function() {389 ok(fabric.Image.filters.Sepia);390 var filter = new fabric.Image.filters.Sepia();391 ok(filter instanceof fabric.Image.filters.Sepia, 'should inherit from fabric.Image.filters.Sepia');392 });393 test('properties', function() {394 var filter = new fabric.Image.filters.Sepia();395 equal(filter.type, 'Sepia');396 });397 test('applyTo', function() {398 var filter = new fabric.Image.filters.Sepia();399 ok(typeof filter.applyTo == 'function');400 });401 test('toObject', function() {402 var filter = new fabric.Image.filters.Sepia();403 ok(typeof filter.toObject == 'function');404 var object = filter.toObject();405 equal(JSON.stringify(object), '{"type":"Sepia"}');406 });407 test('toJSON', function() {408 var filter = new fabric.Image.filters.Sepia();409 ok(typeof filter.toJSON == 'function');410 var json = filter.toJSON();411 equal(JSON.stringify(json), '{"type":"Sepia"}');412 });413 test('fromObject', function() {414 var filter = new fabric.Image.filters.Sepia();415 var object = filter.toObject();416 deepEqual(fabric.Image.filters.Sepia.fromObject(object), filter);417 });418 QUnit.module('fabric.Image.filters.Tint');419 test('constructor', function() {420 ok(fabric.Image.filters.Tint);421 var filter = new fabric.Image.filters.Tint();422 ok(filter instanceof fabric.Image.filters.Tint, 'should inherit from fabric.Image.filters.Tint');423 });424 test('properties', function() {425 var filter = new fabric.Image.filters.Tint();426 equal(filter.type, 'Tint');427 equal(filter.color, '#000000');428 equal(filter.opacity, 1);429 var filter2 = new fabric.Image.filters.Tint({color: 'rgba(0,0,255,0.5)', opacity: 0.2});430 equal(filter2.color, 'rgba(0,0,255,0.5)');431 equal(filter2.opacity, 0.2);432 var filter3 = new fabric.Image.filters.Tint({color: 'rgba(0,0,255,0.5)'});433 equal(filter3.color, 'rgba(0,0,255,0.5)');434 equal(filter3.opacity, 0.5);435 });436 test('applyTo', function() {437 var filter = new fabric.Image.filters.Tint();438 ok(typeof filter.applyTo == 'function');439 });440 test('toObject', function() {441 var filter = new fabric.Image.filters.Tint();442 ok(typeof filter.toObject == 'function');443 var object = filter.toObject();444 equal(JSON.stringify(object), '{"type":"Tint","color":"#000000","opacity":1}');445 filter.color = '#FF00FF';446 filter.opacity = 0.2;447 equal(JSON.stringify(filter.toObject()), '{"type":"Tint","color":"#FF00FF","opacity":0.2}');448 });449 test('toJSON', function() {450 var filter = new fabric.Image.filters.Tint();451 ok(typeof filter.toJSON == 'function');452 var json = filter.toJSON();453 equal(JSON.stringify(json), '{"type":"Tint","color":"#000000","opacity":1}');454 filter.color = '#FF00FF';455 filter.opacity = 0.2;456 equal(JSON.stringify(filter.toJSON()), '{"type":"Tint","color":"#FF00FF","opacity":0.2}');457 });458 test('fromObject', function() {459 var filter = new fabric.Image.filters.Tint();460 var object = filter.toObject();461 deepEqual(fabric.Image.filters.Tint.fromObject(object), filter);462 filter.color = '#FF0000';463 filter.opacity = 0.8;464 deepEqual(fabric.Image.filters.Tint.fromObject(filter.toObject()), filter);465 });466 QUnit.module('fabric.Image.filters.Mask');467 test('constructor', function() {468 ok(fabric.Image.filters.Mask);469 var filter = new fabric.Image.filters.Mask();470 ok(filter instanceof fabric.Image.filters.Mask, 'should inherit from fabric.Image.filters.Mask');471 });472 asyncTest('properties', function() {473 var filter = new fabric.Image.filters.Mask();474 equal(filter.type, 'Mask');475 equal(filter.mask, undefined);476 equal(filter.channel, 0);477 createImageObject(function(image) {478 var filter2 = new fabric.Image.filters.Mask({mask: image, channel: 2});479 equal(filter2.mask, image);480 equal(filter2.channel, 2);481 start();482 });483 });484 test('applyTo', function() {485 var filter = new fabric.Image.filters.Mask();486 ok(typeof filter.applyTo == 'function');487 });488 asyncTest('toObject', function() {489 createImageObject(function(image) {490 var filter = new fabric.Image.filters.Mask({mask: image});491 ok(typeof filter.toObject == 'function');492 var object = filter.toObject(),493 maskObj = object.mask;494 // workaround for node-canvas sometimes producing images with width/height and sometimes not495 if (maskObj.width === 0) {496 maskObj.width = IMG_WIDTH;497 }498 if (maskObj.height === 0) {499 maskObj.height = IMG_HEIGHT;500 }501 equal(JSON.stringify(object), '{"type":"Mask","mask":'+JSON.stringify(maskObj)+',"channel":0}');502 start();503 });504 });505 asyncTest('toJSON', function() {506 createImageObject(function(image) {507 var filter = new fabric.Image.filters.Mask({mask: image});508 ok(typeof filter.toJSON == 'function');509 var json = filter.toJSON(),510 maskObj = json.mask;511 // workaround for node-canvas sometimes producing images with width/height and sometimes not512 if (maskObj.width === 0) {513 maskObj.width = IMG_WIDTH;514 }515 if (maskObj.height === 0) {516 maskObj.height = IMG_HEIGHT;517 }518 equal(JSON.stringify(json), '{"type":"Mask","mask":'+JSON.stringify(maskObj)+',"channel":0}');519 start();520 });521 });522 QUnit.module('fabric.Image.filters.Resize');523 test('constructor', function() {524 ok(fabric.Image.filters.Resize);525 var filter = new fabric.Image.filters.Resize();526 ok(filter instanceof fabric.Image.filters.Resize, 'should inherit from fabric.Image.filters.Resize');527 });528 test('properties', function() {529 var filter = new fabric.Image.filters.Resize();530 equal(filter.type, 'Resize');531 equal(filter.resizeType, 'hermite');532 equal(filter.lanczosLobes, 3);533 equal(filter.scaleX, 0);534 equal(filter.scaleY, 0);535 var filter2 = new fabric.Image.filters.Resize({resizeType: 'bilinear', scaleX: 0.3, scaleY: 0.3});536 equal(filter2.resizeType, 'bilinear');537 equal(filter2.scaleX, 0.3);538 equal(filter2.scaleY, 0.3);539 });540 test('applyTo', function() {541 var filter = new fabric.Image.filters.Resize();542 ok(typeof filter.applyTo == 'function');543 });544 test('toObject', function() {545 var filter = new fabric.Image.filters.Resize();546 ok(typeof filter.toObject == 'function');547 var object = filter.toObject();548 equal(JSON.stringify(object), '{"type":"Resize","scaleX":0,"scaleY":0,"resizeType":"hermite","lanczosLobes":3}');549 filter.resizeType = 'bilinear';550 object = filter.toObject();551 equal(JSON.stringify(object), '{"type":"Resize","scaleX":0,"scaleY":0,"resizeType":"bilinear","lanczosLobes":3}');552 });553 test('fromObject', function() {554 var filter = new fabric.Image.filters.Resize();555 var object = filter.toObject();556 var fromObject = fabric.Image.filters.Resize.fromObject(object);557 deepEqual(fromObject, filter);558 ok(fromObject instanceof fabric.Image.filters.Resize, 'should inherit from fabric.Image.filters.Resize');559 filter.resizeType = 'bilinear';560 filter.scaleX = 0.8;561 filter.scaleY = 0.8;562 deepEqual(fabric.Image.filters.Resize.fromObject(filter.toObject()), filter);563 });564 // asyncTest('fromObject', function() {565 // createImageObject(function(image) {566 // var filter = new fabric.Image.filters.Mask({mask: image});567 // var object = filter.toObject();568 // fabric.Image.filters.Mask.fromObject(object, function(filterObj) {569 // deepEqual(filterObj, filter);570 // start();571 // });572 // });573 // });...

Full Screen

Full Screen

filter-property-parsing.js

Source:filter-property-parsing.js Github

copy

Full Screen

1description("Test the parsing of the -webkit-filter property.");2function jsWrapperClass(node)3{4 if (!node)5 return "[null]";6 var string = Object.prototype.toString.apply(node);7 return string.substr(8, string.length - 9);8}9function shouldBeType(expression, className, prototypeName, constructorName)10{11 if (!prototypeName)12 prototypeName = className + "Prototype";13 if (!constructorName)14 constructorName = className + "Constructor";15 shouldBe("jsWrapperClass(" + expression + ")", "'" + className + "'");16 shouldBe("jsWrapperClass(" + expression + ".__proto__)", "'" + prototypeName + "'");17 shouldBe("jsWrapperClass(" + expression + ".constructor)", "'" + constructorName + "'");18}19// These have to be global for the test helpers to see them.20var stylesheet, cssRule, declaration, filterRule, subRule;21var styleElement = document.createElement("style");22document.head.appendChild(styleElement);23stylesheet = styleElement.sheet;24function testFilterRule(description, rule, expectedLength, expectedValue, expectedTypes, expectedTexts)25{26 debug("");27 debug(description + " : " + rule);28 stylesheet.insertRule("body { -webkit-filter: " + rule + "; }", 0);29 cssRule = stylesheet.cssRules.item(0);30 31 shouldBe("cssRule.type", "1");32 declaration = cssRule.style;33 shouldBe("declaration.length", "1");34 shouldBe("declaration.getPropertyValue('-webkit-filter')", "'" + expectedValue + "'");35 filterRule = declaration.getPropertyCSSValue('-webkit-filter');36 shouldBeType("filterRule", "CSSValueList");37 38 shouldBe("filterRule.length", "" + expectedLength); // shouldBe expects string arguments39 40 if (filterRule) {41 for (var i = 0; i < expectedLength; i++) {42 subRule = filterRule[i];43 shouldBe("subRule.operationType", expectedTypes[i]);44 shouldBe("subRule.cssText", "'" + expectedTexts[i] + "'");45 }46 }47}48testFilterRule("Basic reference",49 "url('#a')", 1, "url(\\'#a\\')",50 ["WebKitCSSFilterValue.CSS_FILTER_REFERENCE"],51 ["url(\\'#a\\')"]);52testFilterRule("Bare unquoted reference converting to quoted form",53 "url(#a)", 1, "url(\\'#a\\')",54 ["WebKitCSSFilterValue.CSS_FILTER_REFERENCE"],55 ["url(\\'#a\\')"]);56testFilterRule("Multiple references",57 "url('#a') url('#b')", 2, "url(\\'#a\\') url(\\'#b\\')",58 ["WebKitCSSFilterValue.CSS_FILTER_REFERENCE", "WebKitCSSFilterValue.CSS_FILTER_REFERENCE"],59 ["url(\\'#a\\')", "url(\\'#b\\')"]);60testFilterRule("Reference as 2nd value",61 "grayscale(1) url('#a')", 2, "grayscale(1) url(\\'#a\\')",62 ["WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE", "WebKitCSSFilterValue.CSS_FILTER_REFERENCE"],63 ["grayscale(1)", "url(\\'#a\\')"]);64testFilterRule("Integer value",65 "grayscale(1)", 1, "grayscale(1)",66 ["WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],67 ["grayscale(1)"]);68testFilterRule("Percentage value",69 "grayscale(50%)", 1, "grayscale(50%)",70 ["WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],71 ["grayscale(50%)"]);72testFilterRule("Float value converts to integer",73 "grayscale(1.0)", 1, "grayscale(1)",74 ["WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],75 ["grayscale(1)"]);76testFilterRule("Zero value",77 "grayscale(0)", 1, "grayscale(0)",78 ["WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],79 ["grayscale(0)"]);80testFilterRule("No values",81 "grayscale()", 1, "grayscale()",82 ["WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],83 ["grayscale()"]);84testFilterRule("Multiple values",85 "grayscale(0.5) grayscale(0.25)", 2, "grayscale(0.5) grayscale(0.25)",86 ["WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE", "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],87 ["grayscale(0.5)", "grayscale(0.25)"]);88testFilterRule("Integer value",89 "sepia(1)", 1, "sepia(1)",90 ["WebKitCSSFilterValue.CSS_FILTER_SEPIA"],91 ["sepia(1)"]);92testFilterRule("Percentage value",93 "sepia(50%)", 1, "sepia(50%)",94 ["WebKitCSSFilterValue.CSS_FILTER_SEPIA"],95 ["sepia(50%)"]);96testFilterRule("Float value converts to integer",97 "sepia(1.0)", 1, "sepia(1)",98 ["WebKitCSSFilterValue.CSS_FILTER_SEPIA"],99 ["sepia(1)"]);100testFilterRule("Zero value",101 "sepia(0)", 1, "sepia(0)",102 ["WebKitCSSFilterValue.CSS_FILTER_SEPIA"],103 ["sepia(0)"]);104testFilterRule("No values",105 "sepia()", 1, "sepia()",106 ["WebKitCSSFilterValue.CSS_FILTER_SEPIA"],107 ["sepia()"]);108testFilterRule("Multiple values",109 "sepia(0.5) sepia(0.25)", 2, "sepia(0.5) sepia(0.25)",110 ["WebKitCSSFilterValue.CSS_FILTER_SEPIA", "WebKitCSSFilterValue.CSS_FILTER_SEPIA"],111 ["sepia(0.5)", "sepia(0.25)"]);112testFilterRule("Rule combinations",113 "sepia(0.5) grayscale(0.25)", 2, "sepia(0.5) grayscale(0.25)",114 ["WebKitCSSFilterValue.CSS_FILTER_SEPIA", "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],115 ["sepia(0.5)", "grayscale(0.25)"]);116testFilterRule("Integer value",117 "saturate(1)", 1, "saturate(1)",118 ["WebKitCSSFilterValue.CSS_FILTER_SATURATE"],119 ["saturate(1)"]);120testFilterRule("Percentage value",121 "saturate(50%)", 1, "saturate(50%)",122 ["WebKitCSSFilterValue.CSS_FILTER_SATURATE"],123 ["saturate(50%)"]);124testFilterRule("Percentage value > 1",125 "saturate(250%)", 1, "saturate(250%)",126 ["WebKitCSSFilterValue.CSS_FILTER_SATURATE"],127 ["saturate(250%)"]);128testFilterRule("Float value converts to integer",129 "saturate(1.0)", 1, "saturate(1)",130 ["WebKitCSSFilterValue.CSS_FILTER_SATURATE"],131 ["saturate(1)"]);132testFilterRule("Input value > 1",133 "saturate(5.5)", 1, "saturate(5.5)",134 ["WebKitCSSFilterValue.CSS_FILTER_SATURATE"],135 ["saturate(5.5)"]);136testFilterRule("Zero value",137 "saturate(0)", 1, "saturate(0)",138 ["WebKitCSSFilterValue.CSS_FILTER_SATURATE"],139 ["saturate(0)"]);140testFilterRule("No values",141 "saturate()", 1, "saturate()",142 ["WebKitCSSFilterValue.CSS_FILTER_SATURATE"],143 ["saturate()"]);144testFilterRule("Multiple values",145 "saturate(0.5) saturate(0.25)", 2, "saturate(0.5) saturate(0.25)",146 ["WebKitCSSFilterValue.CSS_FILTER_SATURATE", "WebKitCSSFilterValue.CSS_FILTER_SATURATE"],147 ["saturate(0.5)", "saturate(0.25)"]);148testFilterRule("Rule combinations",149 "saturate(0.5) grayscale(0.25)", 2, "saturate(0.5) grayscale(0.25)",150 ["WebKitCSSFilterValue.CSS_FILTER_SATURATE", "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],151 ["saturate(0.5)", "grayscale(0.25)"]);152testFilterRule("Degrees value as integer",153 "hue-rotate(10deg)", 1, "hue-rotate(10deg)",154 ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE"],155 ["hue-rotate(10deg)"]);156testFilterRule("Degrees float value converts to integer",157 "hue-rotate(10.0deg)", 1, "hue-rotate(10deg)",158 ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE"],159 ["hue-rotate(10deg)"]);160testFilterRule("Radians value",161 "hue-rotate(10rad)", 1, "hue-rotate(10rad)",162 ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE"],163 ["hue-rotate(10rad)"]);164testFilterRule("Gradians value",165 "hue-rotate(10grad)", 1, "hue-rotate(10grad)",166 ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE"],167 ["hue-rotate(10grad)"]);168testFilterRule("Turns value",169 "hue-rotate(0.5turn)", 1, "hue-rotate(0.5turn)",170 ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE"],171 ["hue-rotate(0.5turn)"]);172testFilterRule("Zero value",173 "hue-rotate(0)", 1, "hue-rotate(0deg)",174 ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE"],175 ["hue-rotate(0deg)"]);176testFilterRule("No values",177 "hue-rotate()", 1, "hue-rotate()",178 ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE"],179 ["hue-rotate()"]);180testFilterRule("Rule combinations",181 "hue-rotate(10deg) grayscale(0.25)", 2, "hue-rotate(10deg) grayscale(0.25)",182 ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE", "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],183 ["hue-rotate(10deg)", "grayscale(0.25)"]);184testFilterRule("Integer value",185 "invert(1)", 1, "invert(1)",186 ["WebKitCSSFilterValue.CSS_FILTER_INVERT"],187 ["invert(1)"]);188testFilterRule("Percentage value",189 "invert(50%)", 1, "invert(50%)",190 ["WebKitCSSFilterValue.CSS_FILTER_INVERT"],191 ["invert(50%)"]);192testFilterRule("Float value converts to integer",193 "invert(1.0)", 1, "invert(1)",194 ["WebKitCSSFilterValue.CSS_FILTER_INVERT"],195 ["invert(1)"]);196testFilterRule("Zero value",197 "invert(0)", 1, "invert(0)",198 ["WebKitCSSFilterValue.CSS_FILTER_INVERT"],199 ["invert(0)"]);200testFilterRule("No values",201 "invert()", 1, "invert()",202 ["WebKitCSSFilterValue.CSS_FILTER_INVERT"],203 ["invert()"]);204testFilterRule("Multiple values",205 "invert(0.5) invert(0.25)", 2, "invert(0.5) invert(0.25)",206 ["WebKitCSSFilterValue.CSS_FILTER_INVERT", "WebKitCSSFilterValue.CSS_FILTER_INVERT"],207 ["invert(0.5)", "invert(0.25)"]);208testFilterRule("Rule combinations",209 "invert(0.5) grayscale(0.25)", 2, "invert(0.5) grayscale(0.25)",210 ["WebKitCSSFilterValue.CSS_FILTER_INVERT", "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],211 ["invert(0.5)", "grayscale(0.25)"]);212testFilterRule("Integer value",213 "opacity(1)", 1, "opacity(1)",214 ["WebKitCSSFilterValue.CSS_FILTER_OPACITY"],215 ["opacity(1)"]);216testFilterRule("Percentage value",217 "opacity(50%)", 1, "opacity(50%)",218 ["WebKitCSSFilterValue.CSS_FILTER_OPACITY"],219 ["opacity(50%)"]);220testFilterRule("Float value converts to integer",221 "opacity(1.0)", 1, "opacity(1)",222 ["WebKitCSSFilterValue.CSS_FILTER_OPACITY"],223 ["opacity(1)"]);224testFilterRule("Zero value",225 "opacity(0)", 1, "opacity(0)",226 ["WebKitCSSFilterValue.CSS_FILTER_OPACITY"],227 ["opacity(0)"]);228testFilterRule("No values",229 "opacity()", 1, "opacity()",230 ["WebKitCSSFilterValue.CSS_FILTER_OPACITY"],231 ["opacity()"]);232testFilterRule("Multiple values",233 "opacity(0.5) opacity(0.25)", 2, "opacity(0.5) opacity(0.25)",234 ["WebKitCSSFilterValue.CSS_FILTER_OPACITY", "WebKitCSSFilterValue.CSS_FILTER_OPACITY"],235 ["opacity(0.5)", "opacity(0.25)"]);236testFilterRule("Rule combinations",237 "opacity(0.5) grayscale(0.25)", 2, "opacity(0.5) grayscale(0.25)",238 ["WebKitCSSFilterValue.CSS_FILTER_OPACITY", "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],239 ["opacity(0.5)", "grayscale(0.25)"]);240testFilterRule("Integer value",241 "brightness(1)", 1, "brightness(1)",242 ["WebKitCSSFilterValue.CSS_FILTER_BRIGHTNESS"],243 ["brightness(1)"]);244testFilterRule("Percentage value",245 "brightness(50%)", 1, "brightness(50%)",246 ["WebKitCSSFilterValue.CSS_FILTER_BRIGHTNESS"],247 ["brightness(50%)"]);248testFilterRule("Float value converts to integer",249 "brightness(1.0)", 1, "brightness(1)",250 ["WebKitCSSFilterValue.CSS_FILTER_BRIGHTNESS"],251 ["brightness(1)"]);252testFilterRule("Zero value",253 "brightness(0)", 1, "brightness(0)",254 ["WebKitCSSFilterValue.CSS_FILTER_BRIGHTNESS"],255 ["brightness(0)"]);256testFilterRule("No values",257 "brightness()", 1, "brightness()",258 ["WebKitCSSFilterValue.CSS_FILTER_BRIGHTNESS"],259 ["brightness()"]);260testFilterRule("Multiple values",261 "brightness(0.5) brightness(0.25)", 2, "brightness(0.5) brightness(0.25)",262 ["WebKitCSSFilterValue.CSS_FILTER_BRIGHTNESS", "WebKitCSSFilterValue.CSS_FILTER_BRIGHTNESS"],263 ["brightness(0.5)", "brightness(0.25)"]);264testFilterRule("Rule combinations",265 "brightness(0.5) grayscale(0.25)", 2, "brightness(0.5) grayscale(0.25)",266 ["WebKitCSSFilterValue.CSS_FILTER_BRIGHTNESS", "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],267 ["brightness(0.5)", "grayscale(0.25)"]);268testFilterRule("Rule combinations",269 "grayscale(0.25) brightness(0.5)", 2, "grayscale(0.25) brightness(0.5)",270 [ "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE", "WebKitCSSFilterValue.CSS_FILTER_BRIGHTNESS"],271 ["grayscale(0.25)", "brightness(0.5)"]);272testFilterRule("Integer value",273 "contrast(1)", 1, "contrast(1)",274 ["WebKitCSSFilterValue.CSS_FILTER_CONTRAST"],275 ["contrast(1)"]);276testFilterRule("Percentage value",277 "contrast(50%)", 1, "contrast(50%)",278 ["WebKitCSSFilterValue.CSS_FILTER_CONTRAST"],279 ["contrast(50%)"]);280testFilterRule("Percentage value > 1",281 "contrast(250%)", 1, "contrast(250%)",282 ["WebKitCSSFilterValue.CSS_FILTER_CONTRAST"],283 ["contrast(250%)"]);284testFilterRule("Float value converts to integer",285 "contrast(1.0)", 1, "contrast(1)",286 ["WebKitCSSFilterValue.CSS_FILTER_CONTRAST"],287 ["contrast(1)"]);288testFilterRule("Zero value",289 "contrast(0)", 1, "contrast(0)",290 ["WebKitCSSFilterValue.CSS_FILTER_CONTRAST"],291 ["contrast(0)"]);292testFilterRule("No values",293 "contrast()", 1, "contrast()",294 ["WebKitCSSFilterValue.CSS_FILTER_CONTRAST"],295 ["contrast()"]);296testFilterRule("Value greater than one",297 "contrast(2)", 1, "contrast(2)",298 ["WebKitCSSFilterValue.CSS_FILTER_CONTRAST"],299 ["contrast(2)"]);300testFilterRule("Multiple values",301 "contrast(0.5) contrast(0.25)", 2, "contrast(0.5) contrast(0.25)",302 ["WebKitCSSFilterValue.CSS_FILTER_CONTRAST", "WebKitCSSFilterValue.CSS_FILTER_CONTRAST"],303 ["contrast(0.5)", "contrast(0.25)"]);304testFilterRule("Rule combinations",305 "contrast(0.5) grayscale(0.25)", 2, "contrast(0.5) grayscale(0.25)",306 ["WebKitCSSFilterValue.CSS_FILTER_CONTRAST", "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],307 ["contrast(0.5)", "grayscale(0.25)"]);308testFilterRule("Rule combinations",309 "grayscale(0.25) contrast(0.5)", 2, "grayscale(0.25) contrast(0.5)",310 [ "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE", "WebKitCSSFilterValue.CSS_FILTER_CONTRAST"],311 ["grayscale(0.25)", "contrast(0.5)"]);312testFilterRule("One zero to px",313 "blur(0)", 1, "blur(0px)",314 ["WebKitCSSFilterValue.CSS_FILTER_BLUR"],315 ["blur(0px)"]);316testFilterRule("One length",317 "blur(10px)", 1, "blur(10px)",318 ["WebKitCSSFilterValue.CSS_FILTER_BLUR"],319 ["blur(10px)"]);320testFilterRule("No values",321 "blur()", 1, "blur()",322 ["WebKitCSSFilterValue.CSS_FILTER_BLUR"],323 ["blur()"]);324testFilterRule("Color then three values",325 "drop-shadow(red 1px 2px 3px)", 1, "drop-shadow(red 1px 2px 3px)",326 ["WebKitCSSFilterValue.CSS_FILTER_DROP_SHADOW"],327 ["drop-shadow(red 1px 2px 3px)"]);328testFilterRule("Three values then color",329 "drop-shadow(1px 2px 3px red)", 1, "drop-shadow(red 1px 2px 3px)",330 ["WebKitCSSFilterValue.CSS_FILTER_DROP_SHADOW"],331 ["drop-shadow(red 1px 2px 3px)"]);332testFilterRule("Color then three values with zero length",333 "drop-shadow(#abc 0 0 0)", 1, "drop-shadow(rgb(170, 187, 204) 0px 0px 0px)",334 ["WebKitCSSFilterValue.CSS_FILTER_DROP_SHADOW"],335 ["drop-shadow(rgb(170, 187, 204) 0px 0px 0px)"]);336testFilterRule("Three values with zero length",337 "drop-shadow(0 0 0)", 1, "drop-shadow(0px 0px 0px)",338 ["WebKitCSSFilterValue.CSS_FILTER_DROP_SHADOW"],339 ["drop-shadow(0px 0px 0px)"]);340testFilterRule("Two values no color",341 "drop-shadow(1px 2px)", 1, "drop-shadow(1px 2px)",342 ["WebKitCSSFilterValue.CSS_FILTER_DROP_SHADOW"],343 ["drop-shadow(1px 2px)"]);344testFilterRule("Multiple operations",345 "grayscale(0.5) sepia(0.25) saturate(0.75) hue-rotate(35deg) invert(0.2) opacity(0.9) blur(5px) drop-shadow(green 1px 2px 3px)", 8,346 "grayscale(0.5) sepia(0.25) saturate(0.75) hue-rotate(35deg) invert(0.2) opacity(0.9) blur(5px) drop-shadow(green 1px 2px 3px)",347 [348 "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE",349 "WebKitCSSFilterValue.CSS_FILTER_SEPIA",350 "WebKitCSSFilterValue.CSS_FILTER_SATURATE",351 "WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE",352 "WebKitCSSFilterValue.CSS_FILTER_INVERT",353 "WebKitCSSFilterValue.CSS_FILTER_OPACITY",354 "WebKitCSSFilterValue.CSS_FILTER_BLUR",355 "WebKitCSSFilterValue.CSS_FILTER_DROP_SHADOW"356 ],357 [358 "grayscale(0.5)",359 "sepia(0.25)",360 "saturate(0.75)",361 "hue-rotate(35deg)",362 "invert(0.2)",363 "opacity(0.9)",364 "blur(5px)",365 "drop-shadow(green 1px 2px 3px)"366 ]);...

Full Screen

Full Screen

filter-property-computed-style.js

Source:filter-property-computed-style.js Github

copy

Full Screen

1description("Test the computed style of the -webkit-filter property.");2// These have to be global for the test helpers to see them.3var stylesheet, filterStyle, subRule;4var styleElement = document.createElement("style");5document.head.appendChild(styleElement);6stylesheet = styleElement.sheet;7function testComputedFilterRule(description, rule, expectedLength, expectedTypes, expectedTexts)8{9 debug("");10 debug(description + " : " + rule);11 stylesheet.insertRule("body { -webkit-filter: " + rule + "; }", 0);12 filterStyle = window.getComputedStyle(document.body).getPropertyCSSValue('-webkit-filter');13 shouldBe("filterStyle.length", "" + expectedLength);14 for (var i = 0; i < expectedLength; i++) {15 subRule = filterStyle[i];16 shouldBe("subRule.operationType", expectedTypes[i]);17 shouldBe("subRule.cssText", "'" + expectedTexts[i] + "'");18 }19 stylesheet.deleteRule(0);20}21testComputedFilterRule("Basic reference",22 "url('#a')", 1,23 ["WebKitCSSFilterValue.CSS_FILTER_REFERENCE"],24 ["url(\\'#a\\')"]);25testComputedFilterRule("Bare unquoted reference converting to quoted form",26 "url(#a)", 1,27 ["WebKitCSSFilterValue.CSS_FILTER_REFERENCE"],28 ["url(\\'#a\\')"]);29testComputedFilterRule("Multiple references",30 "url('#a') url('#b')", 2,31 ["WebKitCSSFilterValue.CSS_FILTER_REFERENCE", "WebKitCSSFilterValue.CSS_FILTER_REFERENCE"],32 ["url(\\'#a\\')", "url(\\'#b\\')"]);33testComputedFilterRule("Reference as 2nd value",34 "grayscale(1) url('#a')", 2,35 ["WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE", "WebKitCSSFilterValue.CSS_FILTER_REFERENCE"],36 ["grayscale(1)", "url(\\'#a\\')"]);37testComputedFilterRule("Integer value",38 "grayscale(1)", 1,39 ["WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],40 ["grayscale(1)"]);41testComputedFilterRule("Float value converts to integer",42 "grayscale(1.0)", 1,43 ["WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],44 ["grayscale(1)"]);45testComputedFilterRule("Zero value",46 "grayscale(0)", 1,47 ["WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],48 ["grayscale(0)"]);49testComputedFilterRule("No values",50 "grayscale()", 1,51 ["WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],52 ["grayscale(1)"]);53testComputedFilterRule("Multiple values",54 "grayscale(0.5) grayscale(0.25)", 2,55 ["WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE", "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],56 ["grayscale(0.5)", "grayscale(0.25)"]);57testComputedFilterRule("Integer value",58 "sepia(1)", 1,59 ["WebKitCSSFilterValue.CSS_FILTER_SEPIA"],60 ["sepia(1)"]);61testComputedFilterRule("Float value converts to integer",62 "sepia(1.0)", 1,63 ["WebKitCSSFilterValue.CSS_FILTER_SEPIA"],64 ["sepia(1)"]);65testComputedFilterRule("Zero value",66 "sepia(0)", 1,67 ["WebKitCSSFilterValue.CSS_FILTER_SEPIA"],68 ["sepia(0)"]);69testComputedFilterRule("No values",70 "sepia()", 1,71 ["WebKitCSSFilterValue.CSS_FILTER_SEPIA"],72 ["sepia(1)"]);73testComputedFilterRule("Multiple values",74 "sepia(0.5) sepia(0.25)", 2,75 ["WebKitCSSFilterValue.CSS_FILTER_SEPIA", "WebKitCSSFilterValue.CSS_FILTER_SEPIA"],76 ["sepia(0.5)", "sepia(0.25)"]);77testComputedFilterRule("Rule combinations",78 "sepia(0.5) grayscale(0.25)", 2,79 ["WebKitCSSFilterValue.CSS_FILTER_SEPIA", "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],80 ["sepia(0.5)", "grayscale(0.25)"]);81testComputedFilterRule("Integer value",82 "saturate(1)", 1,83 ["WebKitCSSFilterValue.CSS_FILTER_SATURATE"],84 ["saturate(1)"]);85testComputedFilterRule("Float value converts to integer",86 "saturate(1.0)", 1,87 ["WebKitCSSFilterValue.CSS_FILTER_SATURATE"],88 ["saturate(1)"]);89testComputedFilterRule("Zero value",90 "saturate(0)", 1,91 ["WebKitCSSFilterValue.CSS_FILTER_SATURATE"],92 ["saturate(0)"]);93testComputedFilterRule("No values",94 "saturate()", 1,95 ["WebKitCSSFilterValue.CSS_FILTER_SATURATE"],96 ["saturate(1)"]);97testComputedFilterRule("Multiple values",98 "saturate(0.5) saturate(0.25)", 2,99 ["WebKitCSSFilterValue.CSS_FILTER_SATURATE", "WebKitCSSFilterValue.CSS_FILTER_SATURATE"],100 ["saturate(0.5)", "saturate(0.25)"]);101testComputedFilterRule("Rule combinations",102 "saturate(0.5) grayscale(0.25)", 2,103 ["WebKitCSSFilterValue.CSS_FILTER_SATURATE", "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],104 ["saturate(0.5)", "grayscale(0.25)"]);105testComputedFilterRule("Degrees value as integer",106 "hue-rotate(10deg)", 1,107 ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE"],108 ["hue-rotate(10deg)"]);109testComputedFilterRule("Degrees float value converts to integer",110 "hue-rotate(10.0deg)", 1,111 ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE"],112 ["hue-rotate(10deg)"]);113testComputedFilterRule("Radians value",114 "hue-rotate(10rad)", 1,115 ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE"],116 ["hue-rotate(572.9577951308232deg)"]);117testComputedFilterRule("Gradians value",118 "hue-rotate(10grad)", 1,119 ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE"],120 ["hue-rotate(9deg)"]);121testComputedFilterRule("Turns value",122 "hue-rotate(0.5turn)", 1,123 ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE"],124 ["hue-rotate(180deg)"]);125testComputedFilterRule("Zero value",126 "hue-rotate(0)", 1,127 ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE"],128 ["hue-rotate(0deg)"]);129testComputedFilterRule("No values",130 "hue-rotate()", 1,131 ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE"],132 ["hue-rotate(0deg)"]);133testComputedFilterRule("Rule combinations",134 "hue-rotate(10deg) grayscale(0.25)", 2,135 ["WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE", "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],136 ["hue-rotate(10deg)", "grayscale(0.25)"]);137testComputedFilterRule("Integer value",138 "invert(1)", 1,139 ["WebKitCSSFilterValue.CSS_FILTER_INVERT"],140 ["invert(1)"]);141testComputedFilterRule("Float value converts to integer",142 "invert(1.0)", 1,143 ["WebKitCSSFilterValue.CSS_FILTER_INVERT"],144 ["invert(1)"]);145testComputedFilterRule("Zero value",146 "invert(0)", 1,147 ["WebKitCSSFilterValue.CSS_FILTER_INVERT"],148 ["invert(0)"]);149testComputedFilterRule("No values",150 "invert()", 1,151 ["WebKitCSSFilterValue.CSS_FILTER_INVERT"],152 ["invert(1)"]);153testComputedFilterRule("Multiple values",154 "invert(0.5) invert(0.25)", 2,155 ["WebKitCSSFilterValue.CSS_FILTER_INVERT", "WebKitCSSFilterValue.CSS_FILTER_INVERT"],156 ["invert(0.5)", "invert(0.25)"]);157testComputedFilterRule("Rule combinations",158 "invert(0.5) grayscale(0.25)", 2,159 ["WebKitCSSFilterValue.CSS_FILTER_INVERT", "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],160 ["invert(0.5)", "grayscale(0.25)"]);161testComputedFilterRule("Integer value",162 "opacity(1)", 1,163 ["WebKitCSSFilterValue.CSS_FILTER_OPACITY"],164 ["opacity(1)"]);165testComputedFilterRule("Float value converts to integer",166 "opacity(1.0)", 1,167 ["WebKitCSSFilterValue.CSS_FILTER_OPACITY"],168 ["opacity(1)"]);169testComputedFilterRule("Zero value",170 "opacity(0)", 1,171 ["WebKitCSSFilterValue.CSS_FILTER_OPACITY"],172 ["opacity(0)"]);173testComputedFilterRule("No values",174 "opacity()", 1,175 ["WebKitCSSFilterValue.CSS_FILTER_OPACITY"],176 ["opacity(1)"]);177testComputedFilterRule("Multiple values",178 "opacity(0.5) opacity(0.25)", 2,179 ["WebKitCSSFilterValue.CSS_FILTER_OPACITY", "WebKitCSSFilterValue.CSS_FILTER_OPACITY"],180 ["opacity(0.5)", "opacity(0.25)"]);181testComputedFilterRule("Rule combinations",182 "opacity(0.5) grayscale(0.25)", 2,183 ["WebKitCSSFilterValue.CSS_FILTER_OPACITY", "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],184 ["opacity(0.5)", "grayscale(0.25)"]);185testComputedFilterRule("Integer value",186 "brightness(1)", 1,187 ["WebKitCSSFilterValue.CSS_FILTER_BRIGHTNESS"],188 ["brightness(1)"]);189testComputedFilterRule("Float value converts to integer",190 "brightness(1.0)", 1,191 ["WebKitCSSFilterValue.CSS_FILTER_BRIGHTNESS"],192 ["brightness(1)"]);193testComputedFilterRule("Zero value",194 "brightness(0)", 1,195 ["WebKitCSSFilterValue.CSS_FILTER_BRIGHTNESS"],196 ["brightness(0)"]);197testComputedFilterRule("No values",198 "brightness()", 1,199 ["WebKitCSSFilterValue.CSS_FILTER_BRIGHTNESS"],200 ["brightness(0)"]);201testComputedFilterRule("Multiple values",202 "brightness(0.5) brightness(0.25)", 2,203 ["WebKitCSSFilterValue.CSS_FILTER_BRIGHTNESS", "WebKitCSSFilterValue.CSS_FILTER_BRIGHTNESS"],204 ["brightness(0.5)", "brightness(0.25)"]);205testComputedFilterRule("Rule combinations",206 "brightness(0.5) grayscale(0.25)", 2,207 ["WebKitCSSFilterValue.CSS_FILTER_BRIGHTNESS", "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],208 ["brightness(0.5)", "grayscale(0.25)"]);209testComputedFilterRule("Integer value",210 "contrast(1)", 1,211 ["WebKitCSSFilterValue.CSS_FILTER_CONTRAST"],212 ["contrast(1)"]);213testComputedFilterRule("Value greater than 1",214 "contrast(2)", 1,215 ["WebKitCSSFilterValue.CSS_FILTER_CONTRAST"],216 ["contrast(2)"]);217testComputedFilterRule("Float value converts to integer",218 "contrast(1.0)", 1,219 ["WebKitCSSFilterValue.CSS_FILTER_CONTRAST"],220 ["contrast(1)"]);221testComputedFilterRule("Zero value",222 "contrast(0)", 1,223 ["WebKitCSSFilterValue.CSS_FILTER_CONTRAST"],224 ["contrast(0)"]);225testComputedFilterRule("No values",226 "contrast()", 1,227 ["WebKitCSSFilterValue.CSS_FILTER_CONTRAST"],228 ["contrast(1)"]);229testComputedFilterRule("Multiple values",230 "contrast(0.5) contrast(0.25)", 2,231 ["WebKitCSSFilterValue.CSS_FILTER_CONTRAST", "WebKitCSSFilterValue.CSS_FILTER_CONTRAST"],232 ["contrast(0.5)", "contrast(0.25)"]);233testComputedFilterRule("Rule combinations",234 "contrast(0.5) grayscale(0.25)", 2,235 ["WebKitCSSFilterValue.CSS_FILTER_CONTRAST", "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE"],236 ["contrast(0.5)", "grayscale(0.25)"]);237testComputedFilterRule("One zero to px",238 "blur(0)", 1,239 ["WebKitCSSFilterValue.CSS_FILTER_BLUR"],240 ["blur(0px)"]);241testComputedFilterRule("One length",242 "blur(2em)", 1,243 ["WebKitCSSFilterValue.CSS_FILTER_BLUR"],244 ["blur(32px)"]);245testComputedFilterRule("One length",246 "blur(5px)", 1,247 ["WebKitCSSFilterValue.CSS_FILTER_BLUR"],248 ["blur(5px)"]);249testComputedFilterRule("No values",250 "blur()", 1,251 ["WebKitCSSFilterValue.CSS_FILTER_BLUR"],252 ["blur(0px)"]);253testComputedFilterRule("Color then three values",254 "drop-shadow(red 1px 2px 3px)", 1,255 ["WebKitCSSFilterValue.CSS_FILTER_DROP_SHADOW"],256 ["drop-shadow(rgb(255, 0, 0) 1px 2px 3px)"]);257testComputedFilterRule("Three values then color",258 "drop-shadow(1px 2px 3px red)", 1,259 ["WebKitCSSFilterValue.CSS_FILTER_DROP_SHADOW"],260 ["drop-shadow(rgb(255, 0, 0) 1px 2px 3px)"]);261testComputedFilterRule("Color then three values with zero length",262 "drop-shadow(#abc 0 0 0)", 1,263 ["WebKitCSSFilterValue.CSS_FILTER_DROP_SHADOW"],264 ["drop-shadow(rgb(170, 187, 204) 0px 0px 0px)"]);265testComputedFilterRule("Three values with zero length",266 "drop-shadow(0 0 0)", 1,267 ["WebKitCSSFilterValue.CSS_FILTER_DROP_SHADOW"],268 ["drop-shadow(rgba(0, 0, 0, 0) 0px 0px 0px)"]);269testComputedFilterRule("Two values no color",270 "drop-shadow(1px 2px)", 1,271 ["WebKitCSSFilterValue.CSS_FILTER_DROP_SHADOW"],272 ["drop-shadow(rgba(0, 0, 0, 0) 1px 2px 0px)"]);273testComputedFilterRule("Multiple operations",274 "grayscale(0.5) sepia(0.25) saturate(0.75) hue-rotate(35deg) invert(0.2) opacity(0.9) blur(5px)", 7,275 [276 "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE",277 "WebKitCSSFilterValue.CSS_FILTER_SEPIA",278 "WebKitCSSFilterValue.CSS_FILTER_SATURATE",279 "WebKitCSSFilterValue.CSS_FILTER_HUE_ROTATE",280 "WebKitCSSFilterValue.CSS_FILTER_INVERT",281 "WebKitCSSFilterValue.CSS_FILTER_OPACITY",282 "WebKitCSSFilterValue.CSS_FILTER_BLUR",283 ],284 [285 "grayscale(0.5)",286 "sepia(0.25)",287 "saturate(0.75)",288 "hue-rotate(35deg)",289 "invert(0.2)",290 "opacity(0.9)",291 "blur(5px)"292 ]);293testComputedFilterRule("Percentage values",294 "grayscale(50%) sepia(25%) saturate(75%) invert(20%) opacity(90%) brightness(60%) contrast(30%)", 7,295 [296 "WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE",297 "WebKitCSSFilterValue.CSS_FILTER_SEPIA",298 "WebKitCSSFilterValue.CSS_FILTER_SATURATE",299 "WebKitCSSFilterValue.CSS_FILTER_INVERT",300 "WebKitCSSFilterValue.CSS_FILTER_OPACITY",301 "WebKitCSSFilterValue.CSS_FILTER_BRIGHTNESS",302 "WebKitCSSFilterValue.CSS_FILTER_CONTRAST"303 ],304 [305 "grayscale(0.5)",306 "sepia(0.25)",307 "saturate(0.75)",308 "invert(0.2)",309 "opacity(0.9)",310 "brightness(0.6)",311 "contrast(0.3)"312 ]);...

Full Screen

Full Screen

v1.js

Source:v1.js Github

copy

Full Screen

1/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for 2 * full list of contributors). Published under the Clear BSD license. 3 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the4 * full text of the license. */5/**6 * @requires OpenLayers/Format/Filter.js7 * @requires OpenLayers/Format/XML.js8 */9/**10 * Class: OpenLayers.Format.Filter.v111 * Superclass for Filter version 1 parsers.12 *13 * Inherits from:14 * - <OpenLayers.Format.XML>15 */16OpenLayers.Format.Filter.v1 = OpenLayers.Class(OpenLayers.Format.XML, {17 18 /**19 * Property: namespaces20 * {Object} Mapping of namespace aliases to namespace URIs.21 */22 namespaces: {23 ogc: "http://www.opengis.net/ogc",24 gml: "http://www.opengis.net/gml",25 xlink: "http://www.w3.org/1999/xlink",26 xsi: "http://www.w3.org/2001/XMLSchema-instance"27 },28 29 /**30 * Property: defaultPrefix31 */32 defaultPrefix: "ogc",33 /**34 * Property: schemaLocation35 * {String} Schema location for a particular minor version.36 */37 schemaLocation: null,38 39 /**40 * Constructor: OpenLayers.Format.Filter.v141 * Instances of this class are not created directly. Use the42 * <OpenLayers.Format.Filter> constructor instead.43 *44 * Parameters:45 * options - {Object} An optional object whose properties will be set on46 * this instance.47 */48 initialize: function(options) {49 OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);50 },51 52 /**53 * Method: read54 *55 * Parameters:56 * data - {DOMElement} A Filter document element.57 *58 * Returns:59 * {<OpenLayers.Filter>} A filter object.60 */61 read: function(data) {62 var obj = {};63 this.readers.ogc["Filter"].apply(this, [data, obj]);64 return obj.filter;65 },66 67 /**68 * Property: readers69 * Contains public functions, grouped by namespace prefix, that will70 * be applied when a namespaced node is found matching the function71 * name. The function will be applied in the scope of this parser72 * with two arguments: the node being read and a context object passed73 * from the parent.74 */75 readers: {76 "ogc": {77 "Filter": function(node, parent) {78 // Filters correspond to subclasses of OpenLayers.Filter.79 // Since they contain information we don't persist, we80 // create a temporary object and then pass on the filter81 // (ogc:Filter) to the parent obj.82 var obj = {83 fids: [],84 filters: []85 };86 this.readChildNodes(node, obj);87 if(obj.fids.length > 0) {88 parent.filter = new OpenLayers.Filter.FeatureId({89 fids: obj.fids90 });91 } else if(obj.filters.length > 0) {92 parent.filter = obj.filters[0];93 }94 },95 "FeatureId": function(node, obj) {96 var fid = node.getAttribute("fid");97 if(fid) {98 obj.fids.push(fid);99 }100 },101 "And": function(node, obj) {102 var filter = new OpenLayers.Filter.Logical({103 type: OpenLayers.Filter.Logical.AND104 });105 this.readChildNodes(node, filter);106 obj.filters.push(filter);107 },108 "Or": function(node, obj) {109 var filter = new OpenLayers.Filter.Logical({110 type: OpenLayers.Filter.Logical.OR111 });112 this.readChildNodes(node, filter);113 obj.filters.push(filter);114 },115 "Not": function(node, obj) {116 var filter = new OpenLayers.Filter.Logical({117 type: OpenLayers.Filter.Logical.NOT118 });119 this.readChildNodes(node, filter);120 obj.filters.push(filter);121 },122 "PropertyIsLessThan": function(node, obj) {123 var filter = new OpenLayers.Filter.Comparison({124 type: OpenLayers.Filter.Comparison.LESS_THAN125 });126 this.readChildNodes(node, filter);127 obj.filters.push(filter);128 },129 "PropertyIsGreaterThan": function(node, obj) {130 var filter = new OpenLayers.Filter.Comparison({131 type: OpenLayers.Filter.Comparison.GREATER_THAN132 });133 this.readChildNodes(node, filter);134 obj.filters.push(filter);135 },136 "PropertyIsLessThanOrEqualTo": function(node, obj) {137 var filter = new OpenLayers.Filter.Comparison({138 type: OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO139 });140 this.readChildNodes(node, filter);141 obj.filters.push(filter);142 },143 "PropertyIsGreaterThanOrEqualTo": function(node, obj) {144 var filter = new OpenLayers.Filter.Comparison({145 type: OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO146 });147 this.readChildNodes(node, filter);148 obj.filters.push(filter);149 },150 "PropertyIsBetween": function(node, obj) {151 var filter = new OpenLayers.Filter.Comparison({152 type: OpenLayers.Filter.Comparison.BETWEEN153 });154 this.readChildNodes(node, filter);155 obj.filters.push(filter);156 },157 "Literal": function(node, obj) {158 obj.value = OpenLayers.String.numericIf(159 this.getChildValue(node));160 },161 "PropertyName": function(node, filter) {162 filter.property = this.getChildValue(node);163 },164 "LowerBoundary": function(node, filter) {165 filter.lowerBoundary = OpenLayers.String.numericIf(166 this.readOgcExpression(node));167 },168 "UpperBoundary": function(node, filter) {169 filter.upperBoundary = OpenLayers.String.numericIf(170 this.readOgcExpression(node));171 },172 "Intersects": function(node, obj) {173 this.readSpatial(node, obj, OpenLayers.Filter.Spatial.INTERSECTS);174 },175 "Within": function(node, obj) {176 this.readSpatial(node, obj, OpenLayers.Filter.Spatial.WITHIN);177 },178 "Contains": function(node, obj) {179 this.readSpatial(node, obj, OpenLayers.Filter.Spatial.CONTAINS);180 },181 "DWithin": function(node, obj) {182 this.readSpatial(node, obj, OpenLayers.Filter.Spatial.DWITHIN);183 },184 "Distance": function(node, obj) {185 obj.distance = parseInt(this.getChildValue(node));186 obj.distanceUnits = node.getAttribute("units");187 }188 }189 },190 191 /**192 * Method: readSpatial193 *194 * Read a {<OpenLayers.Filter.Spatial>} filter.195 * 196 * Parameters:197 * node - {DOMElement} A DOM element that contains an ogc:expression.198 * obj - {Object} The target object.199 * type - {String} One of the OpenLayers.Filter.Spatial.* constants.200 *201 * Returns:202 * {<OpenLayers.Filter.Spatial>} The created filter.203 */204 readSpatial: function(node, obj, type) {205 var filter = new OpenLayers.Filter.Spatial({206 type: type207 });208 this.readChildNodes(node, filter);209 filter.value = filter.components[0];210 delete filter.components;211 obj.filters.push(filter);212 },213 /**214 * Method: readOgcExpression215 * Limited support for OGC expressions.216 *217 * Parameters:218 * node - {DOMElement} A DOM element that contains an ogc:expression.219 *220 * Returns:221 * {String} A value to be used in a symbolizer.222 */223 readOgcExpression: function(node) {224 var obj = {};225 this.readChildNodes(node, obj);226 var value = obj.value;227 if(value === undefined) {228 value = this.getChildValue(node);229 }230 return value;231 },232 /**233 * Method: write234 *235 * Parameters:236 * filter - {<OpenLayers.Filter>} A filter object.237 *238 * Returns:239 * {DOMElement} An ogc:Filter element.240 */241 write: function(filter) {242 return this.writers.ogc["Filter"].apply(this, [filter]);243 },244 245 /**246 * Property: writers247 * As a compliment to the readers property, this structure contains public248 * writing functions grouped by namespace alias and named like the249 * node names they produce.250 */251 writers: {252 "ogc": {253 "Filter": function(filter) {254 var node = this.createElementNSPlus("ogc:Filter");255 var sub = filter.CLASS_NAME.split(".").pop();256 if(sub == "FeatureId") {257 for(var i=0; i<filter.fids.length; ++i) {258 this.writeNode("FeatureId", filter.fids[i], node);259 }260 } else {261 this.writeNode(this.getFilterType(filter), filter, node);262 }263 return node;264 },265 "FeatureId": function(fid) {266 return this.createElementNSPlus("ogc:FeatureId", {267 attributes: {fid: fid}268 });269 },270 "And": function(filter) {271 var node = this.createElementNSPlus("ogc:And");272 var childFilter;273 for(var i=0; i<filter.filters.length; ++i) {274 childFilter = filter.filters[i];275 this.writeNode(276 this.getFilterType(childFilter), childFilter, node277 );278 }279 return node;280 },281 "Or": function(filter) {282 var node = this.createElementNSPlus("ogc:Or");283 var childFilter;284 for(var i=0; i<filter.filters.length; ++i) {285 childFilter = filter.filters[i];286 this.writeNode(287 this.getFilterType(childFilter), childFilter, node288 );289 }290 return node;291 },292 "Not": function(filter) {293 var node = this.createElementNSPlus("ogc:Not");294 var childFilter = filter.filters[0];295 this.writeNode(296 this.getFilterType(childFilter), childFilter, node297 );298 return node;299 },300 "PropertyIsLessThan": function(filter) {301 var node = this.createElementNSPlus("ogc:PropertyIsLessThan");302 // no ogc:expression handling for now303 this.writeNode("PropertyName", filter, node);304 this.writeNode("Literal", filter.value, node); 305 return node;306 },307 "PropertyIsGreaterThan": function(filter) {308 var node = this.createElementNSPlus("ogc:PropertyIsGreaterThan");309 // no ogc:expression handling for now310 this.writeNode("PropertyName", filter, node);311 this.writeNode("Literal", filter.value, node);312 return node;313 },314 "PropertyIsLessThanOrEqualTo": function(filter) {315 var node = this.createElementNSPlus("ogc:PropertyIsLessThanOrEqualTo");316 // no ogc:expression handling for now317 this.writeNode("PropertyName", filter, node);318 this.writeNode("Literal", filter.value, node);319 return node;320 },321 "PropertyIsGreaterThanOrEqualTo": function(filter) {322 var node = this.createElementNSPlus("ogc:PropertyIsGreaterThanOrEqualTo");323 // no ogc:expression handling for now324 this.writeNode("PropertyName", filter, node);325 this.writeNode("Literal", filter.value, node);326 return node;327 },328 "PropertyIsBetween": function(filter) {329 var node = this.createElementNSPlus("ogc:PropertyIsBetween");330 // no ogc:expression handling for now331 this.writeNode("PropertyName", filter, node);332 this.writeNode("LowerBoundary", filter, node);333 this.writeNode("UpperBoundary", filter, node);334 return node;335 },336 "PropertyName": function(filter) {337 // no ogc:expression handling for now338 return this.createElementNSPlus("ogc:PropertyName", {339 value: filter.property340 });341 },342 "Literal": function(value) {343 // no ogc:expression handling for now344 return this.createElementNSPlus("ogc:Literal", {345 value: value346 });347 },348 "LowerBoundary": function(filter) {349 // no ogc:expression handling for now350 var node = this.createElementNSPlus("ogc:LowerBoundary");351 this.writeNode("Literal", filter.lowerBoundary, node);352 return node;353 },354 "UpperBoundary": function(filter) {355 // no ogc:expression handling for now356 var node = this.createElementNSPlus("ogc:UpperBoundary");357 this.writeNode("Literal", filter.upperBoundary, node);358 return node;359 },360 "INTERSECTS": function(filter) {361 return this.writeSpatial(filter, "Intersects");362 },363 "WITHIN": function(filter) {364 return this.writeSpatial(filter, "Within");365 },366 "CONTAINS": function(filter) {367 return this.writeSpatial(filter, "Contains");368 },369 "DWITHIN": function(filter) {370 var node = this.writeSpatial(filter, "DWithin");371 this.writeNode("Distance", filter, node);372 return node;373 },374 "Distance": function(filter) {375 return this.createElementNSPlus("ogc:Distance", {376 attributes: {377 units: filter.distanceUnits378 },379 value: filter.distance380 });381 }382 }383 },384 /**385 * Method: getFilterType386 */387 getFilterType: function(filter) {388 var filterType = this.filterMap[filter.type];389 if(!filterType) {390 throw "Filter writing not supported for rule type: " + filter.type;391 }392 return filterType;393 },394 395 /**396 * Property: filterMap397 * {Object} Contains a member for each filter type. Values are node names398 * for corresponding OGC Filter child elements.399 */400 filterMap: {401 "&&": "And",402 "||": "Or",403 "!": "Not",404 "==": "PropertyIsEqualTo",405 "!=": "PropertyIsNotEqualTo",406 "<": "PropertyIsLessThan",407 ">": "PropertyIsGreaterThan",408 "<=": "PropertyIsLessThanOrEqualTo",409 ">=": "PropertyIsGreaterThanOrEqualTo",410 "..": "PropertyIsBetween",411 "~": "PropertyIsLike",412 "BBOX": "BBOX",413 "DWITHIN": "DWITHIN",414 "WITHIN": "WITHIN",415 "CONTAINS": "CONTAINS",416 "INTERSECTS": "INTERSECTS"417 },418 CLASS_NAME: "OpenLayers.Format.Filter.v1" ...

Full Screen

Full Screen

module_filter_tab.js

Source:module_filter_tab.js Github

copy

Full Screen

...20 case 13:21 if (Drupal.ModuleFilter.timeout) {22 clearTimeout(Drupal.ModuleFilter.timeout);23 }24 Drupal.ModuleFilter.filter(Drupal.ModuleFilter.textFilter);25 break;26 default:27 if (Drupal.ModuleFilter.textFilter != $(this).val()) {28 Drupal.ModuleFilter.textFilter = this.value;29 if (Drupal.ModuleFilter.timeout) {30 clearTimeout(Drupal.ModuleFilter.timeout);31 }32 Drupal.ModuleFilter.timeout = setTimeout('Drupal.ModuleFilter.filter("' + Drupal.ModuleFilter.textFilter + '")', 500);33 }34 break;35 }36 });37 $('input[name="module_filter[name]"]').keypress(function(e) {38 if (e.which == 13) e.preventDefault();39 });40 Drupal.ModuleFilter.showEnabled = $('#edit-module-filter-show-enabled').is(':checked');41 $('#edit-module-filter-show-enabled').change(function() {42 Drupal.ModuleFilter.showEnabled = $(this).is(':checked');43 Drupal.ModuleFilter.filter($('input[name="module_filter[name]"]').val());44 });45 Drupal.ModuleFilter.showDisabled = $('#edit-module-filter-show-disabled').is(':checked');46 $('#edit-module-filter-show-disabled').change(function() {47 Drupal.ModuleFilter.showDisabled = $(this).is(':checked');48 Drupal.ModuleFilter.filter($('input[name="module_filter[name]"]').val());49 });50 Drupal.ModuleFilter.showRequired = $('#edit-module-filter-show-required').is(':checked');51 $('#edit-module-filter-show-required').change(function() {52 Drupal.ModuleFilter.showRequired = $(this).is(':checked');53 Drupal.ModuleFilter.filter($('input[name="module_filter[name]"]').val());54 });55 Drupal.ModuleFilter.showUnavailable = $('#edit-module-filter-show-unavailable').is(':checked');56 $('#edit-module-filter-show-unavailable').change(function() {57 Drupal.ModuleFilter.showUnavailable = $(this).is(':checked');58 Drupal.ModuleFilter.filter($('input[name="module_filter[name]"]').val());59 });60 if (Drupal.settings.moduleFilter.visualAid == 1) {61 $('table.package tbody td.checkbox input').change(function() {62 if ($(this).is(':checked')) {63 Drupal.ModuleFilter.updateVisualAid('enable', $(this).parents('tr'));64 }65 else {66 Drupal.ModuleFilter.updateVisualAid('disable', $(this).parents('tr'));67 }68 });69 }70 // Check for anchor.71 var url = document.location.toString();72 if (url.match('#')) {...

Full Screen

Full Screen

filter_bar.js

Source:filter_bar.js Github

copy

Full Screen

1define(function (require) {2 var _ = require('lodash');3 var module = require('ui/modules').get('kibana');4 var template = require('ui/filter_bar/filter_bar.html');5 var moment = require('moment');6 var angular = require('angular');7 require('ui/directives/json_input');8 module.directive('filterBar', function (Private, Promise, getAppState) {9 var mapAndFlattenFilters = Private(require('ui/filter_bar/lib/mapAndFlattenFilters'));10 var mapFlattenAndWrapFilters = Private(require('ui/filter_bar/lib/mapFlattenAndWrapFilters'));11 var extractTimeFilter = Private(require('ui/filter_bar/lib/extractTimeFilter'));12 var filterOutTimeBasedFilter = Private(require('ui/filter_bar/lib/filterOutTimeBasedFilter'));13 var filterAppliedAndUnwrap = require('ui/filter_bar/lib/filterAppliedAndUnwrap');14 var changeTimeFilter = Private(require('ui/filter_bar/lib/changeTimeFilter'));15 var queryFilter = Private(require('ui/filter_bar/query_filter'));16 var privateFilterFieldRegex = /(^\$|meta)/;17 return {18 restrict: 'E',19 template: template,20 scope: {},21 link: function ($scope, $el, attrs) {22 // bind query filter actions to the scope23 [24 'addFilters',25 'toggleFilter',26 'toggleAll',27 'pinFilter',28 'pinAll',29 'invertFilter',30 'invertAll',31 'removeFilter',32 'removeAll',33 'updateFilter'34 ].forEach(function (method) {35 $scope[method] = queryFilter[method];36 });37 $scope.state = getAppState();38 $scope.aceLoaded = function (editor) {39 editor.$blockScrolling = Infinity;40 var session = editor.getSession();41 session.setTabSize(2);42 session.setUseSoftTabs(true);43 };44 $scope.applyFilters = function (filters) {45 // add new filters46 $scope.addFilters(filterAppliedAndUnwrap(filters));47 $scope.newFilters = [];48 // change time filter49 if ($scope.changeTimeFilter && $scope.changeTimeFilter.meta && $scope.changeTimeFilter.meta.apply) {50 changeTimeFilter($scope.changeTimeFilter);51 }52 };53 $scope.startEditingFilter = function (source) {54 return $scope.editingFilter = {55 source: source,56 type: _.findKey(source, function (val, key) {57 return !key.match(privateFilterFieldRegex);58 }),59 model: convertToEditableFilter(source),60 alias: source.meta.alias61 };62 };63 $scope.stopEditingFilter = function () {64 $scope.editingFilter = null;65 };66 $scope.editDone = function () {67 $scope.updateFilter($scope.editingFilter);68 $scope.stopEditingFilter();69 };70 $scope.clearFilterBar = function () {71 $scope.newFilters = [];72 $scope.changeTimeFilter = null;73 };74 // update the scope filter list on filter changes75 $scope.$listen(queryFilter, 'update', function () {76 $scope.stopEditingFilter();77 updateFilters();78 });79 // when appState changes, update scope's state80 $scope.$watch(getAppState, function (appState) {81 $scope.state = appState;82 });83 $scope.$watch('state.$newFilters', function (filters) {84 if (!filters) return;85 // If filters is not undefined and the length is greater than86 // one we need to set the newFilters attribute and allow the87 // users to decide what they want to apply.88 if (filters.length > 1) {89 return mapFlattenAndWrapFilters(filters)90 .then(function (results) {91 extractTimeFilter(results).then(function (filter) {92 $scope.changeTimeFilter = filter;93 });94 return results;95 })96 .then(filterOutTimeBasedFilter)97 .then(function (results) {98 $scope.newFilters = results;99 });100 }101 // Just add single filters to the state.102 if (filters.length === 1) {103 Promise.resolve(filters).then(function (filters) {104 extractTimeFilter(filters)105 .then(function (timeFilter) {106 if (timeFilter) changeTimeFilter(timeFilter);107 });108 return filters;109 })110 .then(filterOutTimeBasedFilter)111 .then($scope.addFilters);112 }113 });114 function convertToEditableFilter(filter) {115 return _.omit(_.cloneDeep(filter), function (val, key) {116 return key.match(privateFilterFieldRegex);117 });118 }119 function updateFilters() {120 var filters = queryFilter.getFilters();121 mapAndFlattenFilters(filters).then(function (results) {122 // used to display the current filters in the state123 $scope.filters = _.sortBy(results, function (filter) {124 return !filter.meta.pinned;125 });126 $scope.$emit('filterbar:updated');127 });128 }129 updateFilters();130 }131 };132 });...

Full Screen

Full Screen

filter_lists.js

Source:filter_lists.js Github

copy

Full Screen

...34 setFilterLists = (filterLists) => {35 // Check selected filter lists still exist.36 this.setState((prevState) => {37 const loadedFilterIds = filterLists.map((filterList) => filterList.filter_id);38 const selectedFilterLists = prevState.selectedFilterLists.filter((filterList) => {39 return loadedFilterIds.indexOf(filterList.filter_id) !== -1;40 });41 return {42 filterLists,43 selectedFilterLists,44 };45 });46 };47 setSelectedFilterLists = (selectedFilterLists) => {48 this.setState({ selectedFilterLists });49 };50 refreshFilterLists = () => {51 // Load the list of filters.52 ml.filters...

Full Screen

Full Screen

buildRequestFilter.js

Source:buildRequestFilter.js Github

copy

Full Screen

1function getTermFilterValue(field, fieldValue) {2 // We do this because if the value is a boolean value, we need to apply3 // our filter differently. We're also only storing the string representation4 // of the boolean value, so we need to convert it to a Boolean.5 // TODO We need better approach for boolean values6 if (fieldValue === "false" || fieldValue === "true") {7 return { [field]: fieldValue === "true" };8 }9 return { [`${field}.keyword`]: fieldValue };10}11function getTermFilter(filter) {12 if (filter.type === "any") {13 return {14 bool: {15 should: filter.values.map(filterValue => ({16 term: getTermFilterValue(filter.field, filterValue)17 })),18 minimum_should_match: 119 }20 };21 } else if (filter.type === "all") {22 return {23 bool: {24 filter: filter.values.map(filterValue => ({25 term: getTermFilterValue(filter.field, filterValue)26 }))27 }28 };29 }30}31function getRangeFilter(filter) {32 if (filter.type === "any") {33 return {34 bool: {35 should: filter.values.map(filterValue => ({36 range: {37 [filter.field]: {38 ...(filterValue.to && { lt: filterValue.to }),39 ...(filterValue.to && { gt: filterValue.from })40 }41 }42 })),43 minimum_should_match: 144 }45 };46 } else if (filter.type === "all") {47 return {48 bool: {49 filter: filter.values.map(filterValue => ({50 range: {51 [filter.field]: {52 ...(filterValue.to && { lt: filterValue.to }),53 ...(filterValue.to && { gt: filterValue.from })54 }55 }56 }))57 }58 };59 }60}61export default function buildRequestFilter(filters) {62 if (!filters) return;63 filters = filters.reduce((acc, filter) => {64 if (["states", "world_heritage_site"].includes(filter.field)) {65 return [...acc, getTermFilter(filter)];66 }67 if (["acres", "visitors"].includes(filter.field)) {68 return [...acc, getRangeFilter(filter)];69 }70 return acc;71 }, []);72 if (filters.length < 1) return;73 return filters;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { filter } = require("stryker-parent");2const { filter } = require("stryker-parent");3const { filter } = require("stryker-parent");4const { filter } = require("stryker-parent");5const { filter } = require("stryker-parent");6const { filter } = require("stryker-parent");7const { filter } = require("stryker-parent");8const { filter } = require("stryker-parent");9const { filter } = require("stryker-parent");10const { filter } = require("stryker-parent");11const { filter } = require("stryker-parent");12const { filter } = require("stryker-parent");13const { filter } = require("stryker-parent");14const { filter } = require("stryker-parent");15const { filter } = require("stryker-parent");16const { filter } = require("stryker-parent");17const { filter } = require("stryker-parent");18const { filter } = require("stryker-parent");19const { filter } = require("stryker-parent");20const { filter } = require("stry

Full Screen

Using AI Code Generation

copy

Full Screen

1const parent = require('stryker-parent');2const stryker = parent.filter('stryker');3console.log(stryker);4const parent = require('stryker-parent');5const stryker = parent.filter('stryker');6console.log(stryker);7const parent = require('stryker-parent');8const stryker = parent.filter('stryker');9console.log(stryker);10const parent = require('stryker-parent');11const stryker = parent.filter('stryker');12console.log(stryker);13const parent = require('stryker-parent');14const stryker = parent.filter('stryker');15console.log(stryker);16const parent = require('stryker-parent');17const stryker = parent.filter('stryker');18console.log(stryker);19const parent = require('stryker-parent');20const stryker = parent.filter('stryker');21console.log(stryker);22const parent = require('stryker-parent');23const stryker = parent.filter('stryker');24console.log(stryker);25const parent = require('stryker-parent');26const stryker = parent.filter('stryker');27console.log(stryker);28const parent = require('stryker-parent');29const stryker = parent.filter('stryker');30console.log(stryker);31const parent = require('stryker-parent');32const stryker = parent.filter('stryker');33console.log(stryker);34const parent = require('stryker-parent');35const stryker = parent.filter('stryker');36console.log(stryker);37const parent = require('stryker

Full Screen

Using AI Code Generation

copy

Full Screen

1var filter = require('stryker-parent').filter;2var files = filter(['test.js', 'test2.js']);3var filter = require('stryker-parent').filter;4var files = filter(['test.js', 'test2.js']);5var filter = require('stryker-parent').filter;6var files = filter(['test.js', 'test2.js']);7var filter = require('stryker-parent').filter;8var files = filter(['test.js', 'test2.js']);9var filter = require('stryker-parent').filter;10var files = filter(['test.js', 'test2.js']);11var filter = require('stryker-parent').filter;12var files = filter(['test.js', 'test2.js']);13var filter = require('stryker-parent').filter;14var files = filter(['test.js', 'test2.js']);15var filter = require('stryker-parent').filter;16var files = filter(['test.js', 'test2.js']);17var filter = require('stryker-parent').filter;18var files = filter(['test.js', 'test2.js']);19var filter = require('stryker-parent').filter;20var files = filter(['test.js', 'test2.js']);

Full Screen

Using AI Code Generation

copy

Full Screen

1var parent = require('stryker-parent');2console.log(parent.filter(['A','B','C'], function(item) { return item !== 'B'; }));3module.exports = {4 filter: function (arr, predicate) {5 return arr.filter(predicate);6 }7};8var assert = require('assert');9var myModule = require('../myModule.js');10describe('myModule', function() {11 describe('myFunction', function() {12 it('should return true', function() {13 assert.equal(true, myModule.myFunction());14 });15 });16});17function isEven(value) {18 if (value % 2 == 0)19 return true;20 return false;21}22var assert = require('assert');23var isEven = require('../isEven.js');24describe('isEven', function() {25 it('should return true', function() {26 assert.equal(true, isEven(2));27 });28});29var assert = require('assert');30var myModule = require('../myModule.js');31describe('myModule', function() {32 describe('myFunction', function() {33 it('should return true', function() {34 assert.equal(true, myModule.myFunction());35 });36 });37});

Full Screen

Using AI Code Generation

copy

Full Screen

1var parent = require('stryker-parent');2var parent = require('stryker-parent');3var parent = require('stryker-parent');4var parent = require('stryker-parent');5var parent = require('stryker-parent');6var parent = require('stryker-parent');7var parent = require('stryker-parent');

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerParentFilter = require('stryker-parent-filter');2const files = strykerParentFilter({ files: ['test.js', 'test2.js', 'test3.js'] });3console.log(files);4const strykerParentFilter = require('stryker-parent-filter');5const files = strykerParentFilter({ files: ['test.js', 'test2.js', 'test3.js'] });6console.log(files);7const strykerParentFilter = require('stryker-parent-filter');8const files = strykerParentFilter({ files: ['test.js', 'test2.js', 'test3.js'] });9console.log(files);10const strykerParentFilter = require('stryker-parent-filter');11const files = strykerParentFilter({ files: ['test.js', 'test2.js', 'test3.js'] });12console.log(files);13const strykerParentFilter = require('stryker-parent-filter');14const files = strykerParentFilter({ files: ['test.js', 'test2.js', 'test3.js'] });15console.log(files);16const strykerParentFilter = require('stryker-parent-filter');17const files = strykerParentFilter({ files: ['test.js', 'test2.js', 'test3.js'] });18console.log(files);19const strykerParentFilter = require('stryker-parent

Full Screen

Using AI Code Generation

copy

Full Screen

1var filter = require('stryker-parent').filter;2var file = 'C:/Users/abc/stryker/stryker-parent/test.js';3var pattern = 'C:/Users/abc/stryker/stryker-parent/**/*.js';4console.log(filter([file], [pattern]));5var filter = require('stryker').filter;6var file = 'C:/Users/abc/stryker/stryker-parent/test.js';7var pattern = 'C:/Users/abc/stryker/stryker-parent/**/*.js';8console.log(filter([file], [pattern]));9var filter = require('stryker-parent').filter;10var file = 'C:/Users/abc/stryker/stryker-parent/test.js';11var pattern = 'C:/Users/abc/stryker/stryker-parent/**/*.js';12console.log(filter([file], [pattern]));

Full Screen

Using AI Code Generation

copy

Full Screen

1var filter = require('stryker-parent').filter;2var mutants = filter('test.js', [3 { id: 1, killed: true },4 { id: 2, killed: true },5 { id: 3, killed: false },6 { id: 4, killed: true }7]);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful