How to use Kb method in Playwright Internal

Best JavaScript code snippet using playwright-internal

knockback-core.js

Source:knockback-core.js Github

copy

Full Screen

1/*2 knockback-core.js 0.16.73 (c) 2011, 2012 Kevin Malakoff - http://kmalakoff.github.com/knockback/4 License: MIT (http://www.opensource.org/licenses/mit-license.php)5 Dependencies: Knockout.js, Backbone.js, and Underscore.js.6*/7(function() {8 return (function(factory) {9 // AMD10 if (typeof define === 'function' && define.amd) {11 return define('knockback', ['underscore', 'backbone', 'knockout'], factory);12 }13 // CommonJS/NodeJS or No Loader14 else {15 return factory.call(this);16 }17 })(function() {// Generated by CoffeeScript 1.3.318/*19 knockback-core.js 0.16.720 (c) 2011, 2012 Kevin Malakoff.21 Knockback.js is freely distributable under the MIT license.22 See the following for full license details:23 https://github.com/kmalakoff/knockback/blob/master/LICENSE24 Dependencies: Knockout.js, Backbone.js, and Underscore.js.25*/26var Backbone, COMPARE_ASCENDING, COMPARE_DESCENDING, COMPARE_EQUAL, KB_TYPE_ARRAY, KB_TYPE_COLLECTION, KB_TYPE_MODEL, KB_TYPE_SIMPLE, KB_TYPE_UNKNOWN, addStatisticsEvent, collapseOptions, kb, ko, onReady, _, _argumentsAddKey, _arraySplice, _legacyWarning, _throwMissing, _throwUnexpected, _unwrapModels, _unwrapObservable, _wrappedKey,27 __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };28kb = (function() {29 function kb() {}30 kb.VERSION = '0.16.7';31 kb.TYPE_UNKNOWN = 0;32 kb.TYPE_SIMPLE = 1;33 kb.TYPE_ARRAY = 2;34 kb.TYPE_MODEL = 3;35 kb.TYPE_COLLECTION = 4;36 kb.release = function(obj, pre_release_fn) {37 var array, item, view_model, view_models, _i, _j, _len, _len1;38 if ((!obj || (obj !== Object(obj))) || ((typeof obj === 'function') && !ko.isObservable(obj)) || obj.__kb_destroyed || ((obj instanceof Backbone.Model) || (obj instanceof Backbone.Collection))) {39 return this;40 }41 if (_.isArray(obj)) {42 array = obj.splice(0, obj.length);43 for (_i = 0, _len = array.length; _i < _len; _i++) {44 item = array[_i];45 kb.release(item);46 }47 return this;48 }49 obj.__kb_destroyed = true;50 !pre_release_fn || pre_release_fn();51 if (ko.isObservable(obj) || (typeof obj.dispose === 'function') || (typeof obj.destroy === 'function') || (typeof obj.release === 'function')) {52 if (ko.isObservable(obj) && _.isArray(array = obj())) {53 if (obj.__kb_is_co || (obj.__kb_is_o && (obj.valueType() === KB_TYPE_COLLECTION))) {54 if (obj.destroy) {55 obj.destroy();56 } else if (obj.dispose) {57 obj.dispose();58 }59 } else if (array.length) {60 view_models = array.slice(0);61 array.splice(0, array.length);62 for (_j = 0, _len1 = view_models.length; _j < _len1; _j++) {63 view_model = view_models[_j];64 kb.release(view_model);65 }66 }67 } else if (obj.release) {68 obj.release();69 } else if (obj.destroy) {70 obj.destroy();71 } else if (obj.dispose) {72 obj.dispose();73 }74 } else {75 this.releaseKeys(obj);76 }77 return this;78 };79 kb.releaseKeys = function(obj) {80 var key, value;81 for (key in obj) {82 value = obj[key];83 (key === '__kb') || kb.release(value, (function() {84 return obj[key] = null;85 }));86 }87 return this;88 };89 kb.releaseOnNodeRemove = function(view_model, node) {90 view_model || _throwUnexpected(this, 'missing view model');91 node || _throwUnexpected(this, 'missing node');92 return ko.utils.domNodeDisposal.addDisposeCallback(node, function() {93 return kb.release(view_model);94 });95 };96 kb.renderTemplate = function(template, view_model, options) {97 var el, observable;98 if (options == null) {99 options = {};100 }101 el = document.createElement('div');102 observable = ko.renderTemplate(template, view_model, options, el, 'replaceChildren');103 if (el.children.length === 1) {104 el = el.children[0];105 }106 kb.releaseOnNodeRemove(view_model, el);107 observable.dispose();108 return el;109 };110 kb.renderAutoReleasedTemplate = function(template, view_model, options) {111 if (options == null) {112 options = {};113 }114 _legacyWarning('kb.renderAutoReleasedTemplate', '0.16.3', 'Please use kb.renderTemplate instead');115 return this.renderTemplate(template, view_model, options = {});116 };117 kb.applyBindings = function(view_model, node) {118 ko.applyBindings(view_model, node);119 return kb.releaseOnNodeRemove(view_model, node);120 };121 return kb;122})();123this.Knockback = this.kb = kb;124if (typeof exports !== 'undefined') {125 module.exports = kb;126}127if (!this._ && (typeof require !== 'undefined')) {128 try {129 _ = require('lodash');130 } catch (e) {131 _ = require('underscore');132 }133} else {134 _ = this._;135}136kb._ = _ = _.hasOwnProperty('_') ? _._ : _;137kb.Backbone = Backbone = !this.Backbone && (typeof require !== 'undefined') ? require('backbone') : this.Backbone;138kb.ko = ko = !this.ko && (typeof require !== 'undefined') ? require('knockout') : this.ko;139_throwMissing = function(instance, message) {140 throw "" + (_.isString(instance) ? instance : instance.constructor.name) + ": " + message + " is missing";141};142_throwUnexpected = function(instance, message) {143 throw "" + (_.isString(instance) ? instance : instance.constructor.name) + ": " + message + " is unexpected";144};145_legacyWarning = function(identifier, last_version, message) {146 var _base;147 this._legacy_warnings || (this._legacy_warnings = {});148 (_base = this._legacy_warnings)[identifier] || (_base[identifier] = 0);149 this._legacy_warnings[identifier]++;150 return console.warn("warning: '" + identifier + "' has been deprecated (will be removed in Knockback after " + last_version + "). " + message + ".");151};152_arraySplice = Array.prototype.splice;153_unwrapObservable = ko.utils.unwrapObservable;154collapseOptions = function(options) {155 var result;156 result = _.clone(options);157 while (options.options) {158 _.defaults(result, options.options);159 options = options.options;160 }161 delete result.options;162 return result;163};164KB_TYPE_UNKNOWN = kb.TYPE_UNKNOWN;165KB_TYPE_SIMPLE = kb.TYPE_SIMPLE;166KB_TYPE_ARRAY = kb.TYPE_ARRAY;167KB_TYPE_MODEL = kb.TYPE_MODEL;168KB_TYPE_COLLECTION = kb.TYPE_COLLECTION;169/*170 knockback-utils.js171 (c) 2011, 2012 Kevin Malakoff.172 Knockback.js is freely distributable under the MIT license.173 See the following for full license details:174 https://github.com/kmalakoff/knockback/blob/master/LICENSE175 Dependencies: Knockout.js, Backbone.js, and Underscore.js.176 Optional dependency: Backbone.ModelRef.js.177*/178_wrappedKey = function(obj, key, value) {179 if (arguments.length === 2) {180 if (obj && obj.__kb && obj.__kb.hasOwnProperty(key)) {181 return obj.__kb[key];182 } else {183 return void 0;184 }185 }186 obj || _throwUnexpected(this, "no obj for wrapping " + key);187 obj.__kb || (obj.__kb = {});188 obj.__kb[key] = value;189 return value;190};191_argumentsAddKey = function(args, key) {192 _arraySplice.call(args, 1, 0, key);193 return args;194};195_unwrapModels = function(obj) {196 var key, result, value;197 if (!obj) {198 return obj;199 }200 if (obj.__kb) {201 if ('object' in obj.__kb) {202 return obj.__kb.object;203 } else {204 return obj;205 }206 } else if (_.isArray(obj)) {207 return _.map(obj, function(test) {208 return _unwrapModels(test);209 });210 } else if (_.isObject(obj) && (obj.constructor === {}.constructor)) {211 result = {};212 for (key in obj) {213 value = obj[key];214 result[key] = _unwrapModels(value);215 }216 return result;217 }218 return obj;219};220kb.utils = (function() {221 function utils() {}222 utils.wrappedObservable = function(obj, value) {223 return _wrappedKey.apply(this, _argumentsAddKey(arguments, 'observable'));224 };225 utils.wrappedObject = function(obj, value) {226 return _wrappedKey.apply(this, _argumentsAddKey(arguments, 'object'));227 };228 utils.wrappedModel = function(obj, value) {229 if (arguments.length === 1) {230 value = _wrappedKey(obj, 'object');231 if (_.isUndefined(value)) {232 return obj;233 } else {234 return value;235 }236 } else {237 return _wrappedKey(obj, 'object', value);238 }239 };240 utils.wrappedStore = function(obj, value) {241 return _wrappedKey.apply(this, _argumentsAddKey(arguments, 'store'));242 };243 utils.wrappedStoreIsOwned = function(obj, value) {244 return _wrappedKey.apply(this, _argumentsAddKey(arguments, 'store_is_owned'));245 };246 utils.wrappedFactory = function(obj, value) {247 return _wrappedKey.apply(this, _argumentsAddKey(arguments, 'factory'));248 };249 utils.wrappedEventWatcher = function(obj, value) {250 return _wrappedKey.apply(this, _argumentsAddKey(arguments, 'event_watcher'));251 };252 utils.wrappedEventWatcherIsOwned = function(obj, value) {253 return _wrappedKey.apply(this, _argumentsAddKey(arguments, 'event_watcher_is_owned'));254 };255 utils.wrappedDestroy = function(obj) {256 var __kb;257 if (!obj.__kb) {258 return;259 }260 if (obj.__kb.event_watcher) {261 obj.__kb.event_watcher.releaseCallbacks(obj);262 }263 __kb = obj.__kb;264 obj.__kb = null;265 if (__kb.observable) {266 __kb.observable.destroy = __kb.observable.release = null;267 this.wrappedDestroy(__kb.observable);268 __kb.observable = null;269 }270 __kb.factory = null;271 if (__kb.event_watcher_is_owned) {272 __kb.event_watcher.destroy();273 }274 __kb.event_watcher = null;275 if (__kb.store_is_owned) {276 __kb.store.destroy();277 }278 return __kb.store = null;279 };280 utils.valueType = function(observable) {281 if (!observable) {282 return KB_TYPE_UNKNOWN;283 }284 if (observable.__kb_is_o) {285 return observable.valueType();286 }287 if (observable.__kb_is_co || (observable instanceof Backbone.Collection)) {288 return KB_TYPE_COLLECTION;289 }290 if ((observable instanceof kb.ViewModel) || (observable instanceof Backbone.Model)) {291 return KB_TYPE_MODEL;292 }293 if (_.isArray(observable)) {294 return KB_TYPE_ARRAY;295 }296 return KB_TYPE_SIMPLE;297 };298 utils.pathJoin = function(path1, path2) {299 return (path1 ? (path1[path1.length - 1] !== '.' ? "" + path1 + "." : path1) : '') + path2;300 };301 utils.optionsPathJoin = function(options, path) {302 return _.defaults({303 path: this.pathJoin(options.path, path)304 }, options);305 };306 utils.inferCreator = function(value, factory, path, owner, key) {307 var creator, relation;308 if (factory) {309 creator = factory.creatorForPath(value, path);310 }311 if (creator) {312 return creator;313 }314 if (owner && Backbone.RelationalModel && (owner instanceof Backbone.RelationalModel)) {315 key = _unwrapObservable(key);316 relation = _.find(owner.getRelations(), function(test) {317 return test.key === key;318 });319 if (relation) {320 if (relation.collectionType || _.isArray(relation.keyContents)) {321 return kb.CollectionObservable;322 } else {323 return kb.ViewModel;324 }325 }326 }327 if (!value) {328 return null;329 }330 if (value instanceof Backbone.Model) {331 return kb.ViewModel;332 }333 if (value instanceof Backbone.Collection) {334 return kb.CollectionObservable;335 }336 return null;337 };338 utils.createFromDefaultCreator = function(obj, options) {339 if (obj instanceof Backbone.Model) {340 return kb.viewModel(obj, options);341 }342 if (obj instanceof Backbone.Collection) {343 return kb.collectionObservable(obj, options);344 }345 if (_.isArray(obj)) {346 return ko.observableArray(obj);347 }348 return ko.observable(obj);349 };350 utils.hasModelSignature = function(obj) {351 return obj && (obj.attributes && !obj.models) && (typeof obj.get === 'function') && (typeof obj.trigger === 'function');352 };353 utils.hasCollectionSignature = function(obj) {354 return obj && obj.models && (typeof obj.get === 'function') && (typeof obj.trigger === 'function');355 };356 utils.release = function(obj) {357 _legacyWarning('kb.utils.release', '0.16.0', 'Please use kb.release instead');358 return kb.release(obj);359 };360 return utils;361})();362/*363 knockback_factory.js364 (c) 2011, 2012 Kevin Malakoff.365 Knockback.Factory is freely distributable under the MIT license.366 See the following for full license details:367 https://github.com/kmalakoff/knockback/blob/master/LICENSE368*/369kb.Factory = (function() {370 Factory.useOptionsOrCreate = function(options, obj, owner_path) {371 var factory;372 if (options.factory && (!options.factories || (options.factories && options.factory.hasPathMappings(options.factories, owner_path)))) {373 return kb.utils.wrappedFactory(obj, options.factory);374 }375 factory = kb.utils.wrappedFactory(obj, new kb.Factory(options.factory));376 if (options.factories) {377 factory.addPathMappings(options.factories, owner_path);378 }379 return factory;380 };381 function Factory(parent_factory) {382 this.parent_factory = parent_factory;383 this.paths = {};384 }385 Factory.prototype.hasPath = function(path) {386 return this.paths.hasOwnProperty(path) || (this.parent_factory && this.parent_factory.hasPath(path));387 };388 Factory.prototype.addPathMapping = function(path, create_info) {389 return this.paths[path] = create_info;390 };391 Factory.prototype.addPathMappings = function(factories, owner_path) {392 var create_info, path;393 for (path in factories) {394 create_info = factories[path];395 this.paths[kb.utils.pathJoin(owner_path, path)] = create_info;396 }397 };398 Factory.prototype.hasPathMappings = function(factories, owner_path) {399 var all_exist, creator, existing_creator, path;400 all_exist = true;401 for (path in factories) {402 creator = factories[path];403 all_exist &= (existing_creator = this.creatorForPath(null, kb.utils.pathJoin(owner_path, path))) && (creator === existing_creator);404 }405 return all_exist;406 };407 Factory.prototype.creatorForPath = function(obj, path) {408 var creator;409 if ((creator = this.paths[path])) {410 if (creator.view_model) {411 return creator.view_model;412 } else {413 return creator;414 }415 }416 if (this.parent_factory) {417 if ((creator = this.parent_factory.creatorForPath(obj, path))) {418 return creator;419 }420 }421 return null;422 };423 return Factory;424})();425/*426 knockback_store.js427 (c) 2012 Kevin Malakoff.428 Knockback.Store is freely distributable under the MIT license.429 See the following for full license details:430 https://github.com/kmalakoff/knockback/blob/master/LICENSE431*/432kb.Store = (function() {433 Store.useOptionsOrCreate = function(options, obj, observable) {434 if (options.store) {435 options.store.register(obj, observable, options);436 return kb.utils.wrappedStore(observable, options.store);437 } else {438 kb.utils.wrappedStoreIsOwned(observable, true);439 return kb.utils.wrappedStore(observable, new kb.Store());440 }441 };442 function Store() {443 this.observable_records = [];444 this.replaced_observables = [];445 }446 Store.prototype.destroy = function() {447 return this.clear();448 };449 Store.prototype.clear = function() {450 var record, _i, _len, _ref;451 _ref = this.observable_records.splice(0, this.observable_records.length);452 for (_i = 0, _len = _ref.length; _i < _len; _i++) {453 record = _ref[_i];454 kb.release(record.observable);455 }456 kb.release(this.replaced_observables);457 };458 Store.prototype.register = function(obj, observable, options) {459 var creator;460 if (!observable) {461 return;462 }463 if (ko.isObservable(observable) || observable.__kb_is_co) {464 return;465 }466 kb.utils.wrappedObject(observable, obj);467 obj || (observable.__kb_null = true);468 creator = options.creator ? options.creator : (options.path && options.factory ? options.factory.creatorForPath(obj, options.path) : null);469 if (!creator) {470 creator = observable.constructor;471 }472 this.observable_records.push({473 obj: obj,474 observable: observable,475 creator: creator476 });477 return observable;478 };479 Store.prototype.findIndex = function(obj, creator) {480 var index, record, _ref;481 if (!obj || (obj instanceof Backbone.Model)) {482 _ref = this.observable_records;483 for (index in _ref) {484 record = _ref[index];485 if (!record.observable) {486 continue;487 }488 if (record.observable.__kb_destroyed) {489 record.obj = null;490 record.observable = null;491 continue;492 }493 if ((!obj && !record.observable.__kb_null) || (obj && (record.observable.__kb_null || (record.obj !== obj)))) {494 continue;495 } else if ((record.creator === creator) || (record.creator.create && (record.creator.create === creator.create))) {496 return index;497 }498 }499 }500 return -1;501 };502 Store.prototype.find = function(obj, creator) {503 var index;504 if ((index = this.findIndex(obj, creator)) < 0) {505 return null;506 } else {507 return this.observable_records[index].observable;508 }509 };510 Store.prototype.isRegistered = function(observable) {511 var record, _i, _len, _ref;512 _ref = this.observable_records;513 for (_i = 0, _len = _ref.length; _i < _len; _i++) {514 record = _ref[_i];515 if (record.observable === observable) {516 return true;517 }518 }519 return false;520 };521 Store.prototype.findOrCreate = function(obj, options) {522 var creator, observable;523 options.store = this;524 options.creator || (options.creator = kb.utils.inferCreator(obj, options.factory, options.path));525 if (!options.creator && (obj instanceof Backbone.Model)) {526 options.creator = kv.ViewModel;527 }528 creator = options.creator;529 if (!creator) {530 return kb.utils.createFromDefaultCreator(obj, options);531 } else if (creator.models_only) {532 return obj;533 }534 if (creator) {535 observable = this.find(obj, creator);536 }537 if (observable) {538 return observable;539 }540 if (creator.create) {541 observable = creator.create(obj, options);542 } else {543 observable = new creator(obj, options);544 }545 observable || (observable = ko.observable(null));546 if (!ko.isObservable(observable)) {547 this.isRegistered(observable) || this.register(obj, observable, options);548 }549 return observable;550 };551 Store.prototype.findOrReplace = function(obj, creator, observable) {552 var index, record;553 obj || raiseUnexpected('obj missing');554 if ((index = this.findIndex(obj, creator)) < 0) {555 return this.register(obj, observable, {556 creator: creator557 });558 } else {559 record = this.observable_records[index];560 (kb.utils.wrappedObject(record.observable) === obj) || _throwUnexpected(this, 'different object');561 if (record.observable !== observable) {562 (record.observable.constructor === observable.constructor) || _throwUnexpected(this, 'replacing different type');563 this.replaced_observables.push(record.observable);564 record.observable = observable;565 }566 return observable;567 }568 };569 return Store;570})();571/*572 knockback_event_watcher.js573 (c) 2011, 2012 Kevin Malakoff.574 Knockback.Observable is freely distributable under the MIT license.575 See the following for full license details:576 https://github.com/kmalakoff/knockback/blob/master/LICENSE577*/578addStatisticsEvent = function(emitter, event_name, info) {579 return !kb.statistics || kb.statistics.addModelEvent({580 name: event_name,581 emitter: emitter,582 key: info.key,583 path: info.path584 });585};586kb.EventWatcher = (function() {587 EventWatcher.useOptionsOrCreate = function(options, emitter, obj, callback_options) {588 if (options.event_watcher) {589 if (!(options.event_watcher.emitter() === emitter || (options.event_watcher.model_ref === emitter))) {590 _throwUnexpected(this, 'emitter not matching');591 }592 return kb.utils.wrappedEventWatcher(obj, options.event_watcher).registerCallbacks(obj, callback_options);593 } else {594 kb.utils.wrappedEventWatcherIsOwned(obj, true);595 return kb.utils.wrappedEventWatcher(obj, new kb.EventWatcher(emitter)).registerCallbacks(obj, callback_options);596 }597 };598 function EventWatcher(emitter, obj, callback_options) {599 this._onModelUnloaded = __bind(this._onModelUnloaded, this);600 this._onModelLoaded = __bind(this._onModelLoaded, this);601 this.__kb || (this.__kb = {});602 this.__kb.callbacks = {};603 this.__kb._onModelLoaded = _.bind(this._onModelLoaded, this);604 this.__kb._onModelUnloaded = _.bind(this._onModelUnloaded, this);605 if (callback_options) {606 this.registerCallbacks(obj, callback_options);607 }608 if (emitter) {609 this.emitter(emitter);610 } else {611 this.ee = null;612 }613 }614 EventWatcher.prototype.destroy = function() {615 this.emitter(null);616 this.__kb.callbacks = null;617 return kb.utils.wrappedDestroy(this);618 };619 EventWatcher.prototype.emitter = function(new_emitter) {620 var callbacks, event_name, info, list, previous_emitter, _i, _len, _ref;621 if ((arguments.length === 0) || (this.ee === new_emitter)) {622 return this.ee;623 }624 if (this.model_ref) {625 this.model_ref.unbind('loaded', this.__kb._onModelLoaded);626 this.model_ref.unbind('unloaded', this.__kb._onModelUnloaded);627 this.model_ref.release();628 this.model_ref = null;629 }630 if (Backbone.ModelRef && (new_emitter instanceof Backbone.ModelRef)) {631 this.model_ref = new_emitter;632 this.model_ref.retain();633 this.model_ref.bind('loaded', this.__kb._onModelLoaded);634 this.model_ref.bind('unloaded', this.__kb._onModelUnloaded);635 new_emitter = this.model_ref.model();636 } else {637 delete this.model_ref;638 }639 previous_emitter = this.ee;640 this.ee = new_emitter;641 _ref = this.__kb.callbacks;642 for (event_name in _ref) {643 callbacks = _ref[event_name];644 if (previous_emitter) {645 previous_emitter.unbind(event_name, callbacks.fn);646 }647 if (new_emitter) {648 this.ee.bind(event_name, callbacks.fn);649 }650 list = callbacks.list;651 for (_i = 0, _len = list.length; _i < _len; _i++) {652 info = list[_i];653 if (info.emitter) {654 info.emitter(this.ee);655 }656 }657 }658 return new_emitter;659 };660 EventWatcher.prototype.registerCallbacks = function(obj, callback_info) {661 var callbacks, event_name, event_names, event_selector, info, list, _i, _len,662 _this = this;663 obj || _throwMissing(this, 'obj');664 callback_info || _throwMissing(this, 'info');665 event_selector = callback_info.event_selector ? callback_info.event_selector : 'change';666 event_names = event_selector.split(' ');667 for (_i = 0, _len = event_names.length; _i < _len; _i++) {668 event_name = event_names[_i];669 if (!event_name) {670 continue;671 }672 callbacks = this.__kb.callbacks[event_name];673 if (!callbacks) {674 list = [];675 callbacks = {676 list: list,677 fn: function(emitter) {678 var info, _j, _len1;679 for (_j = 0, _len1 = list.length; _j < _len1; _j++) {680 info = list[_j];681 if (info.update && !info.rel_fn) {682 if (emitter && info.key && (emitter.hasChanged && !emitter.hasChanged(_unwrapObservable(info.key)))) {683 continue;684 }685 !kb.statistics || addStatisticsEvent(emitter, event_name, info);686 info.update();687 }688 }689 return null;690 }691 };692 this.__kb.callbacks[event_name] = callbacks;693 if (this.ee) {694 this.ee.bind(event_name, callbacks.fn);695 }696 }697 info = _.defaults({698 obj: obj699 }, callback_info);700 callbacks.list.push(info);701 }702 if (this.ee) {703 if (Backbone.RelationalModel && (this.ee instanceof Backbone.RelationalModel) && _.contains(event_names, 'change')) {704 this._modelBindRelatationalInfo('change', info);705 }706 info.emitter(this.ee) && info.emitter;707 }708 };709 EventWatcher.prototype.releaseCallbacks = function(obj) {710 var callbacks, event_name, index, info, _ref, _ref1;711 if (!this.__kb.callbacks) {712 return;713 }714 _ref = this.__kb.callbacks;715 for (event_name in _ref) {716 callbacks = _ref[event_name];717 _ref1 = callbacks.list;718 for (index in _ref1) {719 info = _ref1[index];720 if (info.obj !== obj) {721 continue;722 }723 callbacks.list.splice(index, 1);724 if (info.rel_fn) {725 this._modelUnbindRelatationalInfo(event_name, info);726 }727 if (info.emitter) {728 info.emitter(null);729 }730 return;731 }732 }733 };734 EventWatcher.prototype._onModelLoaded = function(model) {735 var callbacks, event_name, info, is_relational, list, _i, _len, _ref;736 is_relational = Backbone.RelationalModel && (model instanceof Backbone.RelationalModel);737 this.ee = model;738 _ref = this.__kb.callbacks;739 for (event_name in _ref) {740 callbacks = _ref[event_name];741 this.ee.bind(event_name, callbacks.fn);742 list = callbacks.list;743 for (_i = 0, _len = list.length; _i < _len; _i++) {744 info = list[_i];745 if (is_relational) {746 this._modelBindRelatationalInfo(event_name, info);747 }748 if (info.emitter) {749 info.emitter(this.ee);750 }751 }752 }753 };754 EventWatcher.prototype._onModelUnloaded = function(model) {755 var callbacks, event_name, info, list, _i, _len, _ref;756 this.ee = null;757 _ref = this.__kb.callbacks;758 for (event_name in _ref) {759 callbacks = _ref[event_name];760 model.unbind(event_name, callbacks.fn);761 list = callbacks.list;762 for (_i = 0, _len = list.length; _i < _len; _i++) {763 info = list[_i];764 if (info.rel_fn) {765 this._modelUnbindRelatationalInfo(event_name, info);766 }767 if (info.emitter) {768 info.emitter(null);769 }770 }771 }772 };773 EventWatcher.prototype._modelBindRelatationalInfo = function(event_name, info) {774 var key, relation;775 if ((event_name === 'change') && info.key && info.update) {776 key = _unwrapObservable(info.key);777 relation = _.find(this.ee.getRelations(), function(test) {778 return test.key === key;779 });780 if (!relation) {781 return;782 }783 info.rel_fn = function(emitter) {784 !kb.statistics || addStatisticsEvent(emitter, "" + event_name + " (relational)", info);785 return info.update();786 };787 if (relation.collectionType || _.isArray(relation.keyContents)) {788 info.is_collection = true;789 this.ee.bind("add:" + info.key, info.rel_fn);790 this.ee.bind("remove:" + info.key, info.rel_fn);791 } else {792 this.ee.bind("update:" + info.key, info.rel_fn);793 }794 }795 };796 EventWatcher.prototype._modelUnbindRelatationalInfo = function(event_name, info) {797 if (!info.rel_fn) {798 return;799 }800 if (info.is_collection) {801 this.ee.unbind("add:" + info.key, info.rel_fn);802 this.ee.unbind("remove:" + info.key, info.rel_fn);803 } else {804 this.ee.unbind("update:" + info.key, info.rel_fn);805 }806 info.rel_fn = null;807 };808 return EventWatcher;809})();810kb.emitterObservable = function(emitter, observable) {811 return new kb.EventWatcher(emitter, observable);812};813/*814 knockback-observable.js815 (c) 2012 Kevin Malakoff.816 Knockback.Observable is freely distributable under the MIT license.817 See the following for full license details:818 https://github.com/kmalakoff/knockback/blob/master/LICENSE819*/820kb.Observable = (function() {821 function Observable(model, options, vm) {822 var create_options, event_watcher, observable,823 _this = this;824 this.vm = vm;825 options || _throwMissing(this, 'options');826 this.vm || (this.vm = {});827 if (_.isString(options) || ko.isObservable(options)) {828 create_options = this.create_options = {829 key: options830 };831 } else {832 create_options = this.create_options = collapseOptions(options);833 }834 this.key = create_options.key;835 delete create_options.key;836 this.key || _throwMissing(this, 'key');837 !create_options.args || (this.args = create_options.args, delete create_options.args);838 !create_options.read || (this.read = create_options.read, delete create_options.read);839 !create_options.write || (this.write = create_options.write, delete create_options.write);840 event_watcher = create_options.event_watcher;841 delete create_options.event_watcher;842 this.vo = ko.observable(null);843 this._model = ko.observable();844 observable = kb.utils.wrappedObservable(this, ko.dependentObservable({845 read: function() {846 var arg, args, new_value, _i, _len, _ref;847 args = [_unwrapObservable(_this.key)];848 if (_this.args) {849 if (_.isArray(_this.args)) {850 _ref = _this.args;851 for (_i = 0, _len = _ref.length; _i < _len; _i++) {852 arg = _ref[_i];853 args.push(_unwrapObservable(arg));854 }855 } else {856 args.push(_unwrapObservable(_this.args));857 }858 }859 if (_this._mdl === _this._model() && _this._mdl) {860 new_value = _this.read ? _this.read.apply(_this.vm, args) : _this._mdl.get.apply(_this._mdl, args);861 _this.update(new_value);862 }863 return _unwrapObservable(_this.vo());864 },865 write: function(new_value) {866 var arg, args, set_info, unwrapped_new_value, _i, _len, _ref;867 unwrapped_new_value = _unwrapModels(new_value);868 set_info = {};869 set_info[_unwrapObservable(_this.key)] = unwrapped_new_value;870 args = _this.write ? [unwrapped_new_value] : [set_info];871 if (_this.args) {872 if (_.isArray(_this.args)) {873 _ref = _this.args;874 for (_i = 0, _len = _ref.length; _i < _len; _i++) {875 arg = _ref[_i];876 args.push(_unwrapObservable(arg));877 }878 } else {879 args.push(_unwrapObservable(_this.args));880 }881 }882 if (_this._mdl) {883 if (_this.write) {884 _this.write.apply(_this.vm, args);885 } else {886 _this._mdl.set.apply(_this._mdl, args);887 }888 }889 return _this.update(new_value);890 },891 owner: this.vm892 }));893 observable.__kb_is_o = true;894 create_options.store = kb.utils.wrappedStore(observable, create_options.store);895 create_options.path = kb.utils.pathJoin(create_options.path, this.key);896 if (create_options.factories && ((typeof create_options.factories === 'function') || create_options.factories.create)) {897 create_options.factory = kb.utils.wrappedFactory(observable, new kb.Factory(create_options.factory));898 create_options.factory.addPathMapping(create_options.path, create_options.factories);899 } else {900 create_options.factory = kb.Factory.useOptionsOrCreate(create_options, observable, create_options.path);901 }902 delete create_options.factories;903 observable.value = _.bind(this.value, this);904 observable.valueType = _.bind(this.valueType, this);905 observable.destroy = _.bind(this.destroy, this);906 observable.model = this.model = ko.dependentObservable({907 read: function() {908 _this._model();909 return _this._mdl;910 },911 write: function(new_model) {912 if (_this.__kb_destroyed || (_this._mdl === new_model)) {913 return;914 }915 _this._mdl = new_model;916 _this.update(null);917 return _this._model(new_model);918 }919 });920 kb.EventWatcher.useOptionsOrCreate({921 event_watcher: event_watcher922 }, model, this, {923 emitter: this.model,924 update: _.bind(this.update, this),925 key: this.key,926 path: create_options.path927 });928 this.__kb_value || this.update();929 if (kb.LocalizedObservable && create_options.localizer) {930 observable = new create_options.localizer(observable);931 delete create_options.localizer;932 }933 if (kb.DefaultObservable && create_options.hasOwnProperty('default')) {934 observable = kb.defaultObservable(observable, create_options["default"]);935 delete create_options["default"];936 }937 return observable;938 }939 Observable.prototype.destroy = function() {940 var observable;941 observable = kb.utils.wrappedObservable(this);942 this.__kb_destroyed = true;943 kb.release(this.__kb_value);944 this.__kb_value = null;945 this.model.dispose();946 this._mdl = this.model = observable.model = null;947 return kb.utils.wrappedDestroy(this);948 };949 Observable.prototype.value = function() {950 return this.__kb_value;951 };952 Observable.prototype.valueType = function() {953 var new_value;954 new_value = this._mdl ? this._mdl.get(this.key) : null;955 this.value_type || this._updateValueObservable(new_value);956 return this.value_type;957 };958 Observable.prototype.update = function(new_value) {959 var new_type, value;960 if (this.__kb_destroyed) {961 return;962 }963 if (this._mdl && !arguments.length) {964 new_value = this._mdl.get(_unwrapObservable(this.key));965 }966 (new_value !== void 0) || (new_value = null);967 new_type = kb.utils.valueType(new_value);968 if (!this.__kb_value || (this.__kb_value.__kb_destroyed || (this.__kb_value.__kb_null && new_value))) {969 this.__kb_value = void 0;970 this.value_type = void 0;971 }972 value = this.__kb_value;973 if (_.isUndefined(this.value_type) || (this.value_type !== new_type && new_type !== KB_TYPE_UNKNOWN)) {974 if ((this.value_type === KB_TYPE_COLLECTION) && (new_type === KB_TYPE_ARRAY)) {975 return value(new_value);976 } else {977 return this._updateValueObservable(new_value);978 }979 } else if (this.value_type === KB_TYPE_MODEL) {980 if (typeof value.model === 'function') {981 if (value.model() !== new_value) {982 return value.model(new_value);983 }984 } else if (kb.utils.wrappedObject(value) !== new_value) {985 return this._updateValueObservable(new_value);986 }987 } else if (this.value_type === KB_TYPE_COLLECTION) {988 if (value.collection() !== new_value) {989 return value.collection(new_value);990 }991 } else {992 if (value() !== new_value) {993 return value(new_value);994 }995 }996 };997 Observable.prototype._updateValueObservable = function(new_value) {998 var create_options, creator, previous_value, value;999 create_options = this.create_options;1000 create_options.creator = kb.utils.inferCreator(new_value, create_options.factory, create_options.path, this._mdl, this.key);1001 this.value_type = KB_TYPE_UNKNOWN;1002 creator = create_options.creator;1003 previous_value = this.__kb_value;1004 this.__kb_value = void 0;1005 if (previous_value) {1006 kb.release(previous_value);1007 }1008 if (creator) {1009 if (create_options.store) {1010 value = create_options.store.findOrCreate(new_value, create_options);1011 } else {1012 if (creator.models_only) {1013 value = new_value;1014 this.value_type = KB_TYPE_SIMPLE;1015 } else if (creator.create) {1016 value = creator.create(new_value, create_options);1017 } else {1018 value = new creator(new_value, create_options);1019 }1020 }1021 } else {1022 if (_.isArray(new_value)) {1023 this.value_type = KB_TYPE_ARRAY;1024 value = ko.observableArray(new_value);1025 } else {1026 this.value_type = KB_TYPE_SIMPLE;1027 value = ko.observable(new_value);1028 }1029 }1030 if (this.value_type === KB_TYPE_UNKNOWN) {1031 if (!ko.isObservable(value)) {1032 this.value_type = KB_TYPE_MODEL;1033 if (typeof value.model !== 'function') {1034 kb.utils.wrappedObject(value, new_value);1035 }1036 } else if (value.__kb_is_co) {1037 this.value_type = KB_TYPE_COLLECTION;1038 } else {1039 this.value_type = KB_TYPE_SIMPLE;1040 }1041 }1042 this.__kb_value = value;1043 return this.vo(value);1044 };1045 return Observable;1046})();1047kb.observable = function(model, options, view_model) {1048 return new kb.Observable(model, options, view_model);1049};1050/*1051 knockback-view-model.js1052 (c) 2011, 2012 Kevin Malakoff.1053 Knockback.Observable is freely distributable under the MIT license.1054 See the following for full license details:1055 https://github.com/kmalakoff/knockback/blob/master/LICENSE1056*/1057kb.ViewModel = (function() {1058 ViewModel.extend = Backbone.Model.extend;1059 function ViewModel(model, options, view_model) {1060 var attribute_keys, bb_model, event_watcher, keys, mapped_keys, mapping_info, vm_key, _mdl, _ref,1061 _this = this;1062 !model || (model instanceof Backbone.Model) || ((typeof model.get === 'function') && (typeof model.bind === 'function')) || _throwUnexpected(this, 'not a model');1063 options || (options = {});1064 view_model || (view_model = {});1065 if (_.isArray(options)) {1066 options = {1067 keys: options1068 };1069 } else {1070 options = collapseOptions(options);1071 }1072 this.__kb || (this.__kb = {});1073 this.__kb.vm_keys = {};1074 this.__kb.model_keys = {};1075 this.__kb.view_model = _.isUndefined(view_model) ? this : view_model;1076 !options.internals || (this.__kb.internals = options.internals);1077 !options.excludes || (this.__kb.excludes = options.excludes);1078 kb.Store.useOptionsOrCreate(options, model, this);1079 this.__kb.path = options.path;1080 kb.Factory.useOptionsOrCreate(options, this, options.path);1081 _mdl = _wrappedKey(this, '_mdl', ko.observable());1082 this.model = ko.dependentObservable({1083 read: function() {1084 _mdl();1085 return kb.utils.wrappedObject(_this);1086 },1087 write: function(new_model) {1088 var event_watcher, missing;1089 if (kb.utils.wrappedObject(_this) === new_model) {1090 return;1091 }1092 if (_this.__kb_null) {1093 !new_model || _throwUnexpected(_this, 'model set on shared null');1094 return;1095 }1096 kb.utils.wrappedObject(_this, new_model);1097 event_watcher = kb.utils.wrappedEventWatcher(_this);1098 if (!event_watcher) {1099 _mdl(new_model);1100 return;1101 }1102 event_watcher.emitter(new_model);1103 if (!(_this.__kb.keys || !new_model || !new_model.attributes)) {1104 missing = _.difference(_.keys(new_model.attributes), _.keys(_this.__kb.model_keys));1105 if (missing) {1106 _this._createObservables(new_model, missing);1107 }1108 }1109 _mdl(new_model);1110 }1111 });1112 event_watcher = kb.utils.wrappedEventWatcher(this, new kb.EventWatcher(model, this, {1113 emitter: this.model1114 }));1115 if (options.requires && _.isArray(options.requires)) {1116 keys = _.clone(options.requires);1117 }1118 if (this.__kb.internals) {1119 keys = keys ? _.union(keys, this.__kb.internals) : _.clone(this.__kb.internals);1120 }1121 if (options.keys) {1122 if (_.isArray(options.keys)) {1123 this.__kb.keys = options.keys;1124 keys = keys ? _.union(keys, options.keys) : _.clone(options.keys);1125 } else {1126 mapped_keys = {};1127 _ref = options.keys;1128 for (vm_key in _ref) {1129 mapping_info = _ref[vm_key];1130 mapped_keys[_.isString(mapping_info) ? mapping_info : (mapping_info.key ? mapping_info.key : vm_key)] = true;1131 }1132 this.__kb.keys = _.keys(mapped_keys);1133 }1134 } else {1135 bb_model = event_watcher.emitter();1136 if (bb_model && bb_model.attributes) {1137 attribute_keys = _.keys(bb_model.attributes);1138 keys = keys ? _.union(keys, attribute_keys) : attribute_keys;1139 }1140 }1141 if (keys && this.__kb.excludes) {1142 keys = _.difference(keys, this.__kb.excludes);1143 }1144 if (_.isObject(options.keys) && !_.isArray(options.keys)) {1145 this._mapObservables(model, options.keys);1146 }1147 if (_.isObject(options.requires) && !_.isArray(options.requires)) {1148 this._mapObservables(model, options.requires);1149 }1150 !options.mappings || this._mapObservables(model, options.mappings);1151 !keys || this._createObservables(model, keys);1152 !kb.statistics || kb.statistics.register('ViewModel', this);1153 }1154 ViewModel.prototype.destroy = function() {1155 var vm_key;1156 if (this.__kb.view_model !== this) {1157 for (vm_key in this.__kb.vm_keys) {1158 this.__kb.view_model[vm_key] = null;1159 }1160 }1161 this.__kb.view_model = null;1162 kb.releaseKeys(this);1163 kb.utils.wrappedDestroy(this);1164 return !kb.statistics || kb.statistics.unregister('ViewModel', this);1165 };1166 ViewModel.prototype.shareOptions = function() {1167 return {1168 store: kb.utils.wrappedStore(this),1169 factory: kb.utils.wrappedFactory(this)1170 };1171 };1172 ViewModel.prototype._createObservables = function(model, keys) {1173 var create_options, key, vm_key, _i, _len;1174 create_options = {1175 store: kb.utils.wrappedStore(this),1176 factory: kb.utils.wrappedFactory(this),1177 path: this.__kb.path,1178 event_watcher: kb.utils.wrappedEventWatcher(this)1179 };1180 for (_i = 0, _len = keys.length; _i < _len; _i++) {1181 key = keys[_i];1182 vm_key = this.__kb.internals && _.contains(this.__kb.internals, key) ? "_" + key : key;1183 if (this[vm_key]) {1184 continue;1185 }1186 this.__kb.vm_keys[vm_key] = true;1187 this.__kb.model_keys[key] = true;1188 create_options.key = key;1189 this[vm_key] = this.__kb.view_model[vm_key] = kb.observable(model, create_options, this);1190 }1191 };1192 ViewModel.prototype._mapObservables = function(model, mappings) {1193 var create_options, mapping_info, vm_key;1194 create_options = {1195 store: kb.utils.wrappedStore(this),1196 factory: kb.utils.wrappedFactory(this),1197 path: this.__kb.path,1198 event_watcher: kb.utils.wrappedEventWatcher(this)1199 };1200 for (vm_key in mappings) {1201 mapping_info = mappings[vm_key];1202 if (this[vm_key]) {1203 continue;1204 }1205 mapping_info = _.isString(mapping_info) ? {1206 key: mapping_info1207 } : _.clone(mapping_info);1208 mapping_info.key || (mapping_info.key = vm_key);1209 this.__kb.vm_keys[vm_key] = true;1210 this.__kb.model_keys[mapping_info.key] = true;1211 this[vm_key] = this.__kb.view_model[vm_key] = kb.observable(model, _.defaults(mapping_info, create_options), this);1212 }1213 };1214 return ViewModel;1215})();1216kb.viewModel = function(model, options, view_model) {1217 return new kb.ViewModel(model, options, view_model);1218};1219kb.observables = function(model, binding_info, view_model) {1220 _legacyWarning('kb.observables', '0.16.0', 'Please use kb.viewModel instead');1221 return new kb.ViewModel(model, binding_info, view_model);1222};1223/*1224 knockback-collection-observable.js1225 (c) 2011, 2012 Kevin Malakoff.1226 Knockback.CollectionObservable is freely distributable under the MIT license.1227 See the following for full license details:1228 https://github.com/kmalakoff/knockback/blob/master/LICENSE1229*/1230COMPARE_EQUAL = 0;1231COMPARE_ASCENDING = -1;1232COMPARE_DESCENDING = 1;1233kb.compare = function(value_a, value_b) {1234 if (_.isString(value_a)) {1235 return value_a.localeCompare(value_b);1236 }1237 if (_.isString(value_b)) {1238 return value_b.localeCompare(value_a);1239 }1240 if (typeof value_a !== "object") {1241 return (value_a === value_b ? COMPARE_EQUAL : (value_a < value_b ? COMPARE_ASCENDING : COMPARE_DESCENDING));1242 }1243 if (value_a === value_b) {1244 return COMPARE_EQUAL;1245 } else {1246 if (value_a < value_b) {1247 return COMPARE_ASCENDING;1248 } else {1249 return COMPARE_DESCENDING;1250 }1251 }1252};1253kb.CollectionObservable = (function() {1254 CollectionObservable.extend = Backbone.Model.extend;1255 function CollectionObservable(collection, options) {1256 var create_options, observable,1257 _this = this;1258 !collection || (collection instanceof Backbone.Collection) || _throwUnexpected(this, 'not a collection');1259 options || (options = {});1260 observable = kb.utils.wrappedObservable(this, ko.observableArray([]));1261 observable.__kb_is_co = true;1262 this.in_edit = 0;1263 this.__kb || (this.__kb = {});1264 this.__kb._onCollectionChange = _.bind(this._onCollectionChange, this);1265 options = collapseOptions(options);1266 if (options.sort_attribute) {1267 this._comparator = ko.observable(this._attributeComparator(options.sort_attribute));1268 } else {1269 if (options.sorted_index) {1270 _legacyWarning('sortedIndex no longer supported', '0.16.7', 'please use comparator instead');1271 }1272 this._comparator = ko.observable(options.comparator);1273 }1274 if (options.filters) {1275 this._filters = ko.observableArray(_.isArray(options.filters) ? options.filters : options.filters ? [options.filters] : void 0);1276 } else {1277 this._filters = ko.observableArray([]);1278 }1279 create_options = this.create_options = {1280 store: kb.Store.useOptionsOrCreate(options, collection, observable)1281 };1282 this.path = options.path;1283 create_options.factory = kb.utils.wrappedFactory(observable, this._shareOrCreateFactory(options));1284 create_options.path = kb.utils.pathJoin(options.path, 'models');1285 create_options.creator = create_options.factory.creatorForPath(null, create_options.path);1286 if (create_options.creator) {1287 this.models_only = create_options.creator.models_only;1288 }1289 observable.destroy = _.bind(this.destroy, this);1290 observable.shareOptions = _.bind(this.shareOptions, this);1291 observable.filters = _.bind(this.filters, this);1292 observable.comparator = _.bind(this.comparator, this);1293 observable.sortAttribute = _.bind(this.sortAttribute, this);1294 observable.viewModelByModel = _.bind(this.viewModelByModel, this);1295 observable.hasViewModels = _.bind(this.hasViewModels, this);1296 this._collection = ko.observable(collection);1297 observable.collection = this.collection = ko.dependentObservable({1298 read: function() {1299 return _this._collection();1300 },1301 write: function(new_collection) {1302 var previous_collection;1303 if ((previous_collection = _this._collection()) === new_collection) {1304 return;1305 }1306 if (previous_collection) {1307 previous_collection.unbind('all', _this.__kb._onCollectionChange);1308 }1309 if (new_collection) {1310 new_collection.bind('all', _this.__kb._onCollectionChange);1311 }1312 return _this._collection(new_collection);1313 }1314 });1315 if (collection) {1316 collection.bind('all', this.__kb._onCollectionChange);1317 }1318 this._mapper = ko.dependentObservable(function() {1319 var comparator, current_collection, filters, models, view_models;1320 comparator = _this._comparator();1321 filters = _this._filters();1322 current_collection = _this._collection();1323 if (_this.in_edit) {1324 return;1325 }1326 observable = kb.utils.wrappedObservable(_this);1327 if (current_collection) {1328 models = current_collection.models;1329 }1330 if (!models || (current_collection.models.length === 0)) {1331 view_models = [];1332 } else {1333 if (filters.length) {1334 models = _.filter(models, function(model) {1335 return !_this._modelIsFiltered(model);1336 });1337 }1338 if (comparator) {1339 view_models = _.map(models, function(model) {1340 return _this._createViewModel(model);1341 }).sort(comparator);1342 } else {1343 if (_this.models_only) {1344 view_models = filters.length ? models : models.slice();1345 } else {1346 view_models = _.map(models, function(model) {1347 return _this._createViewModel(model);1348 });1349 }1350 }1351 }1352 _this.in_edit++;1353 observable(view_models);1354 return _this.in_edit--;1355 });1356 observable.subscribe(_.bind(this._onObservableArrayChange, this));1357 !kb.statistics || kb.statistics.register('CollectionObservable', this);1358 return observable;1359 }1360 CollectionObservable.prototype.destroy = function() {1361 var array, collection, observable;1362 observable = kb.utils.wrappedObservable(this);1363 collection = this._collection();1364 if (collection) {1365 collection.unbind('all', this.__kb._onCollectionChange);1366 array = observable();1367 array.splice(0, array.length);1368 }1369 this._mapper.dispose();1370 this._mapper = null;1371 kb.release(this._filters);1372 this._comparator(null);1373 this.collection.dispose();1374 observable.collection = this.collection = null;1375 observable.collection = null;1376 kb.utils.wrappedDestroy(this);1377 return !kb.statistics || kb.statistics.unregister('CollectionObservable', this);1378 };1379 CollectionObservable.prototype.shareOptions = function() {1380 var observable;1381 observable = kb.utils.wrappedObservable(this);1382 return {1383 store: kb.utils.wrappedStore(observable),1384 factory: kb.utils.wrappedFactory(observable)1385 };1386 };1387 CollectionObservable.prototype.filters = function(filters) {1388 if (filters) {1389 return this._filters(_.isArray(filters) ? filters : [filters]);1390 } else {1391 return this._filters([]);1392 }1393 };1394 CollectionObservable.prototype.comparator = function(comparator) {1395 return this._comparator(comparator);1396 };1397 CollectionObservable.prototype.sortedIndex = function() {1398 return _legacyWarning('sortedIndex no longer supported', '0.16.7', 'please use comparator instead');1399 };1400 CollectionObservable.prototype.sortAttribute = function(sort_attribute) {1401 return this._comparator(sort_attribute ? this._attributeComparator(sort_attribute) : null);1402 };1403 CollectionObservable.prototype.viewModelByModel = function(model) {1404 var id_attribute;1405 if (this.models_only) {1406 return null;1407 }1408 id_attribute = model.hasOwnProperty(model.idAttribute) ? model.idAttribute : 'cid';1409 return _.find(kb.utils.wrappedObservable(this)(), function(test) {1410 return test.__kb.object[id_attribute] === model[id_attribute];1411 });1412 };1413 CollectionObservable.prototype.hasViewModels = function() {1414 return !this.models_only;1415 };1416 CollectionObservable.prototype._shareOrCreateFactory = function(options) {1417 var absolute_models_path, existing_creator, factories, factory;1418 absolute_models_path = kb.utils.pathJoin(options.path, 'models');1419 factories = options.factories;1420 if ((factory = options.factory)) {1421 if ((existing_creator = factory.creatorForPath(null, absolute_models_path)) && (!factories || (factories['models'] === existing_creator))) {1422 if (!factories) {1423 return factory;1424 }1425 if (factory.hasPathMappings(factories, options.path)) {1426 return factory;1427 }1428 }1429 }1430 factory = new kb.Factory(options.factory);1431 if (factories) {1432 factory.addPathMappings(factories, options.path);1433 }1434 if (!factory.creatorForPath(null, absolute_models_path)) {1435 if (options.hasOwnProperty('models_only')) {1436 if (options.models_only) {1437 factory.addPathMapping(absolute_models_path, {1438 models_only: true1439 });1440 } else {1441 factory.addPathMapping(absolute_models_path, kb.ViewModel);1442 }1443 } else if (options.view_model) {1444 factory.addPathMapping(absolute_models_path, options.view_model);1445 } else if (options.create) {1446 factory.addPathMapping(absolute_models_path, {1447 create: options.create1448 });1449 } else {1450 factory.addPathMapping(absolute_models_path, kb.ViewModel);1451 }1452 }1453 return factory;1454 };1455 CollectionObservable.prototype._onCollectionChange = function(event, arg) {1456 var collection, comparator, observable, view_model;1457 if (this.in_edit) {1458 return;1459 }1460 switch (event) {1461 case 'reset':1462 case 'resort':1463 this._collection.notifySubscribers(this._collection());1464 break;1465 case 'new':1466 case 'add':1467 if (this._modelIsFiltered(arg)) {1468 return;1469 }1470 observable = kb.utils.wrappedObservable(this);1471 collection = this._collection();1472 if ((view_model = this.viewModelByModel(arg))) {1473 return;1474 }1475 view_model = this._createViewModel(arg);1476 this.in_edit++;1477 if ((comparator = this._comparator())) {1478 observable().push(view_model);1479 observable.sort(comparator);1480 } else {1481 observable.splice(collection.indexOf(arg), 0, view_model);1482 }1483 this.in_edit--;1484 break;1485 case 'remove':1486 case 'destroy':1487 this._onModelRemove(arg);1488 break;1489 case 'change':1490 if (this._modelIsFiltered(arg)) {1491 this._onModelRemove(arg);1492 } else {1493 view_model = this.viewModelByModel(arg);1494 if (view_model) {1495 if ((comparator = this._comparator())) {1496 observable = kb.utils.wrappedObservable(this);1497 this.in_edit++;1498 observable.sort(comparator);1499 this.in_edit--;1500 }1501 } else {1502 this._onCollectionChange('add', arg);1503 }1504 }1505 }1506 };1507 CollectionObservable.prototype._onModelRemove = function(model) {1508 var observable, view_model;1509 view_model = this.models_only ? model : this.viewModelByModel(model);1510 if (!view_model) {1511 return;1512 }1513 observable = kb.utils.wrappedObservable(this);1514 this.in_edit++;1515 observable.remove(view_model);1516 return this.in_edit--;1517 };1518 CollectionObservable.prototype._onObservableArrayChange = function(models_or_view_models) {1519 var collection, has_filters, model, models, observable, view_model, view_models, _i, _len,1520 _this = this;1521 if (this.in_edit) {1522 return;1523 }1524 (this.models_only && (!models_or_view_models.length || kb.utils.hasModelSignature(models_or_view_models[0]))) || (!this.models_only && (!models_or_view_models.length || (_.isObject(models_or_view_models[0]) && !kb.utils.hasModelSignature(models_or_view_models[0])))) || _throwUnexpected(this, 'incorrect type passed');1525 observable = kb.utils.wrappedObservable(this);1526 collection = this._collection();1527 has_filters = this._filters().length;1528 if (!collection) {1529 return;1530 }1531 view_models = models_or_view_models;1532 if (this.models_only) {1533 if (has_filters) {1534 models = _.filter(models_or_view_models, function(model) {1535 return !_this._modelIsFiltered(model);1536 });1537 }1538 } else {1539 !has_filters || (view_models = []);1540 models = [];1541 for (_i = 0, _len = models_or_view_models.length; _i < _len; _i++) {1542 view_model = models_or_view_models[_i];1543 model = kb.utils.wrappedObject(view_model);1544 if (has_filters) {1545 if (this._modelIsFiltered(model)) {1546 continue;1547 }1548 view_models.push(view_model);1549 }1550 this.create_options.store.findOrReplace(model, this.create_options.creator, view_model);1551 models.push(model);1552 }1553 }1554 this.in_edit++;1555 (models_or_view_models.length === view_models.length) || observable(view_models);1556 _.isEqual(collection.models, models) || collection.reset(models);1557 this.in_edit--;1558 };1559 CollectionObservable.prototype._attributeComparator = function(sort_attribute) {1560 var modelAttributeCompare;1561 modelAttributeCompare = function(model_a, model_b) {1562 var attribute_name;1563 attribute_name = _unwrapObservable(sort_attribute);1564 return kb.compare(model_a.get(attribute_name), model_b.get(attribute_name));1565 };1566 return (this.models_only ? modelAttributeCompare : function(model_a, model_b) {1567 return modelAttributeCompare(kb.utils.wrappedModel(model_a), kb.utils.wrappedModel(model_b));1568 });1569 };1570 CollectionObservable.prototype._createViewModel = function(model) {1571 if (this.models_only) {1572 return model;1573 } else {1574 return this.create_options.store.findOrCreate(model, this.create_options);1575 }1576 };1577 CollectionObservable.prototype._modelIsFiltered = function(model) {1578 var filter, filters, _i, _len;1579 filters = this._filters();1580 for (_i = 0, _len = filters.length; _i < _len; _i++) {1581 filter = filters[_i];1582 filter = _unwrapObservable(filter);1583 if (((typeof filter === 'function') && filter(model)) || (model && (model.id === filter))) {1584 return true;1585 }1586 }1587 return false;1588 };1589 return CollectionObservable;1590})();1591kb.collectionObservable = function(collection, options) {1592 return new kb.CollectionObservable(collection, options);1593};1594/*1595 knockback-inject.js1596 (c) 2011, 2012 Kevin Malakoff.1597 Knockback.Inject is freely distributable under the MIT license.1598 See the following for full license details:1599 https://github.com/kmalakoff/knockback/blob/master/LICENSE1600*/1601ko.bindingHandlers['inject'] = {1602 'init': function(element, value_accessor, all_bindings_accessor, view_model) {1603 return kb.Inject.inject(_unwrapObservable(value_accessor()), view_model, element, value_accessor, all_bindings_accessor);1604 }1605};1606kb.Inject = (function() {1607 function Inject() {}1608 Inject.inject = function(data, view_model, element, value_accessor, all_bindings_accessor, nested) {1609 var inject, result, wrapper;1610 inject = function(data) {1611 var key, target, value;1612 if (_.isFunction(data)) {1613 view_model = new data(view_model, element, value_accessor, all_bindings_accessor);1614 kb.releaseOnNodeRemove(view_model, element);1615 } else {1616 if (data.view_model) {1617 view_model = new data.view_model(view_model, element, value_accessor, all_bindings_accessor);1618 kb.releaseOnNodeRemove(view_model, element);1619 }1620 for (key in data) {1621 value = data[key];1622 if (key === 'view_model') {1623 continue;1624 }1625 if (key === 'create') {1626 value(view_model, element, value_accessor, all_bindings_accessor);1627 } else if (_.isObject(value) && !_.isFunction(value)) {1628 target = nested || (value && value.create) ? {} : view_model;1629 view_model[key] = kb.Inject.inject(value, target, element, value_accessor, all_bindings_accessor, true);1630 } else {1631 view_model[key] = value;1632 }1633 }1634 }1635 return view_model;1636 };1637 if (nested) {1638 return inject(data);1639 } else {1640 result = (wrapper = ko.dependentObservable(function() {1641 return inject(data);1642 }))();1643 wrapper.dispose();1644 return result;1645 }1646 };1647 Inject.injectViewModels = function(root) {1648 var afterBinding, app, beforeBinding, data, expression, findElements, options, results, _i, _len;1649 results = [];1650 findElements = function(el) {1651 var attr, child_el, _i, _len, _ref;1652 if (!el.__kb_injected) {1653 if (el.attributes && (attr = _.find(el.attributes, function(attr) {1654 return attr.name === 'kb-inject';1655 }))) {1656 el.__kb_injected = true;1657 results.push({1658 el: el,1659 view_model: {},1660 binding: attr.value1661 });1662 }1663 }1664 _ref = el.childNodes;1665 for (_i = 0, _len = _ref.length; _i < _len; _i++) {1666 child_el = _ref[_i];1667 findElements(child_el);1668 }1669 };1670 findElements(root || document);1671 for (_i = 0, _len = results.length; _i < _len; _i++) {1672 app = results[_i];1673 if (expression = app.binding) {1674 (expression.search(/[:]/) < 0) || (expression = "{" + expression + "}");1675 data = (new Function("", "return ( " + expression + " )"))();1676 data || (data = {});1677 (!data.options) || (options = data.options, delete data.options);1678 options || (options = {});1679 app.view_model = kb.Inject.inject(data, app.view_model, app.el, null, null, true);1680 afterBinding = app.view_model.afterBinding || options.afterBinding;1681 beforeBinding = app.view_model.beforeBinding || options.beforeBinding;1682 }1683 if (beforeBinding) {1684 beforeBinding(app.view_model, app.el, options);1685 }1686 kb.applyBindings(app.view_model, app.el, options);1687 if (afterBinding) {1688 afterBinding(app.view_model, app.el, options);1689 }1690 }1691 return results;1692 };1693 return Inject;1694})();1695kb.injectViewModels = kb.Inject.injectViewModels;1696if (this.$) {1697 this.$(function() {1698 return kb.injectViewModels();1699 });1700} else {1701 (onReady = function() {1702 if (document.readyState !== "complete") {1703 return setTimeout(onReady, 0);1704 }1705 return kb.injectViewModels();1706 })();1707}1708; return kb;});...

Full Screen

Full Screen

step1.js

Source:step1.js Github

copy

Full Screen

1import React, { Component } from 'react';2import {CardBody, Col, Row, FormGroup, Label, Input, TabPane, TabContent, Button } from 'reactstrap';3import Select from 'react-select';4class Step1 extends Component {5 constructor(props) {6 super(props);7 this.state = {8 noRegisterFaskesKb: null,9 hidden_noRegisterFaskesKb: false,10 noJaringanJejaring: null,11 jenisFaskesKb: [12 {value: '1', label: 'STATIS'},13 {value: '2', label: 'BERGERAK'},14 ],15 select1: null,16 show_jenisFaskesKb: [],17 hidden_jenisFaskesKb: true,18 tingkatFaskesKb : [19 {value: '11', label: 'FKRTL', kd_jenisFaskesKb: '1' },20 {value: '12', label: 'FKTP', kd_jenisFaskesKb: '1' },21 {value: '13', label: 'JARINGAN', kd_jenisFaskesKb: '2' },22 {value: '14', label: 'JEJARING', kd_jenisFaskesKb: '2' },23 {value: '15', label: 'MUYAN', kd_jenisFaskesKb: '3'},24 {value: '16', label: 'KAPAL LAUT', kd_jenisFaskesKb: '3'},25 ],26 select2: null,27 show_tingkatFaskesKb: [],28 hidden_tingkatFaskesKb: true,29 tingkatPelayanan: [30 {value: '21', label: 'KLINIK UTAMA', kd_tingkatFaskesKb: '11' },31 {value: '22', label: 'RS UMUM', kd_tingkatFaskesKb: '11'},32 {value: '23', label: 'RS KHUSUS', kd_tingkatFaskesKb: '11'},33 {value: '24', label: 'PUSKESMAS', kd_tingkatFaskesKb: '12'},34 {value: '25', label: 'PRAKTIK DOKTER', kd_tingkatFaskesKb: '12'},35 {value: '26', label: 'KLINIK PRATAMA', kd_tingkatFaskesKb: '12'},36 {value: '27', label: 'RS TIPE D PRATAMA', kd_tingkatFaskesKb: '12'},37 {value: '28', label: 'PUSTU', kd_tingkatFaskesKb: '13'},38 {value: '29', label: 'PUSLING', kd_tingkatFaskesKb: '13'},39 {value: '30', label: 'POSKESDES/POLINDES', kd_tingkatFaskesKb: '13'},40 {value: '31', label: 'PRAKTEK BIDAN', kd_tingkatFaskesKb: '14'},41 ],42 select3: null,43 show_tingkatPelayanan: [],44 hidden_tingkatPelayanan: true,45 select4: null,46 statusKepemilikan : [],47 hidden_statusKepemilikan: true,48 show_kbPerusahaan: [{ value: 'ya', label: 'Ya' }, { value: 'tidak', label: 'TIDAK' },],49 kbPerusahaan: null,50 hidden_kbPerusahaan: true,51 show_pkbrs: [{ value: 'ya', label: 'Ya' },{ value: 'tidak', label: 'TIDAK' },],52 pkbrs: null,53 hidden_pkbrs: true,54 kerjasamaBpjs: [{ value: 'ya', label: 'Ya' },{ value: 'tidak', label: 'TIDAK' },],55 kerjasamaBpjsLsngTdk: [],56 selKerjasamaBpjs: true,57 valKerjasamaBpjs: null,58 selKerjasamaBpjsLsngTdk: true,59 valKerjasamaBpjsLsngTdk: null,60 activeTab: '',61 62 }63 }64 65 // input nomor faskes kb66 inputFaskeskb = (e) => {67 if(e.target.value){68 e.target.value = Math.max(0, parseInt(e.target.value) ).toString().slice(0,3)69 this.setState({70 noRegisterFaskesKb: e.target.value,71 show_jenisFaskesKb: this.state.jenisFaskesKb.filter(item => item.value === '1'),72 hidden_jenisFaskesKb: false, select1: null, select2: null, select3: null, select4: null,73 show_tingkatFaskesKb: [], show_tingkatPelayanan: [], statusKepemilikan : [],74 hidden_tingkatFaskesKb: true, hidden_tingkatPelayanan: true, hidden_statusKepemilikan: true,75 kerjasamaBpjsLsngTdk: [], selKerjasamaBpjsLsngTdk: true, valKerjasamaBpjs: null, 76 valKerjasamaBpjsLsngTdk: null, selKerjasamaBpjs: true, activeTab: ''77 })78 }79 else{80 this.setState({81 show_jenisFaskesKb: [], select1: null, hidden_jenisFaskesKb: true, 82 show_tingkatFaskesKb: [], select2: null, hidden_tingkatFaskesKb: true,83 show_tingkatPelayanan: [], select3: null, hidden_tingkatPelayanan: true,84 select4: null, statusKepemilikan : [], hidden_statusKepemilikan: true, kbPerusahaan: null, pkbrs: null,85 kerjasamaBpjsLsngTdk: [], selKerjasamaBpjsLsngTdk: true, valKerjasamaBpjs: null, 86 valKerjasamaBpjsLsngTdk: null, selKerjasamaBpjs: true, activeTab: ''87 })88 }89 }90 91 // input jaringan jejaring92 JaringanJejaring = (e) => {93 if(e.target.value){94 e.target.value = Math.max(0, parseInt(e.target.value) ).toString().slice(0,2)95 this.setState({96 hidden_noRegisterFaskesKb: true,97 noJaringanJejaring: e.target.value,98 show_jenisFaskesKb: this.state.jenisFaskesKb.filter(item => item.value === '1'),99 hidden_jenisFaskesKb: false, select1: null, select2: null, select3: null, select4: null,100 show_tingkatFaskesKb: [], show_tingkatPelayanan: [], statusKepemilikan : [],101 hidden_tingkatFaskesKb: true, hidden_tingkatPelayanan: true, hidden_statusKepemilikan: true,102 kerjasamaBpjsLsngTdk: [], selKerjasamaBpjsLsngTdk: true, valKerjasamaBpjs: null, 103 valKerjasamaBpjsLsngTdk: null, selKerjasamaBpjs: true, activeTab: ''104 })105 }106 else {107 this.setState({108 hidden_noRegisterFaskesKb: false, noJaringanJejaring: null,109 select1: null, show_tingkatFaskesKb: [], select2: null, hidden_tingkatFaskesKb: true,110 show_tingkatPelayanan: [], statusKepemilikan : [], select3: null, hidden_tingkatPelayanan: true, select4: null,111 hidden_statusKepemilikan: true, kbPerusahaan: null, pkbrs: null,112 kerjasamaBpjsLsngTdk: [], selKerjasamaBpjsLsngTdk: true, valKerjasamaBpjs: null, 113 valKerjasamaBpjsLsngTdk: null, selKerjasamaBpjs: true, activeTab: ''114 115 116 })117 }118 }119 // Jenis Faskes KB120 changeSel1 = (e) => {121 if(e){122 if(this.state.noRegisterFaskesKb){123 if(this.state.noJaringanJejaring){124 this.setState({125 show_tingkatFaskesKb: this.state.tingkatFaskesKb.filter(item => item.kd_jenisFaskesKb === '2'),126 hidden_tingkatFaskesKb: false, hidden_tingkatPelayanan: true, select1: e, select2: null, select3: null127 })128 }129 else {130 this.setState({131 show_tingkatFaskesKb: this.state.tingkatFaskesKb.filter(item => item.kd_jenisFaskesKb === '1'),132 hidden_tingkatFaskesKb: false, hidden_tingkatPelayanan: true, select1: e, select2: null, select3: null133 })134 }135 }136 137 } else {138 this.setState({139 show_tingkatFaskesKb: [], hidden_tingkatFaskesKb: true, hidden_tingkatPelayanan: true, select1: null, select2: null, select3: null,140 select4: null, hidden_statusKepemilikan: true, kbPerusahaan: null, pkbrs: null,141 kerjasamaBpjsLsngTdk: [], selKerjasamaBpjsLsngTdk: true, valKerjasamaBpjs: null, 142 valKerjasamaBpjsLsngTdk: null, selKerjasamaBpjs: true, activeTab: '', hidden_pkbrs: true, hidden_kbPerusahaan: true,143 })144 }145 }146 // Jenis tinggkat faskes kb147 changeSel2 = (e) => {148 if (e) {149 if(e.kd_jenisFaskesKb === '1' || e.kd_jenisFaskesKb === '2'){150 this.setState({151 show_tingkatPelayanan: this.state.tingkatPelayanan.filter(item => item.kd_tingkatFaskesKb === e.value),152 hidden_tingkatPelayanan: false, select2: e, select3: null153 })154 } else {155 this.setState({156 show_tingkatPelayanan: [], select2: e, select3: null, select4: null, hidden_statusKepemilikan: true,157 kbPerusahaan: null, pkbrs: null, 158 }) 159 }160 }161 else {162 this.setState({163 show_tingkatPelayanan: [], select2: null, hidden_tingkatPelayanan: true, select3: null, select4: null, 164 hidden_statusKepemilikan: true, kbPerusahaan: null, pkbrs: null,165 kerjasamaBpjsLsngTdk: [], selKerjasamaBpjsLsngTdk: true, valKerjasamaBpjs: null, 166 valKerjasamaBpjsLsngTdk: null, selKerjasamaBpjs: true, activeTab: '', hidden_pkbrs: true, hidden_kbPerusahaan: true,167 })168 }169 }170 // Jenis tingkat pelayan171 changeSel3 = (e) => {172 if(e){173 if(e.value === '21'){174 this.setState({175 statusKepemilikan: [{value: '', label: 'BUMN/BUMD'}, {value: '', label: 'SWASTA'},{value: '', label: 'LSOM'},],176 select3: e, hidden_statusKepemilikan: false, 177 })178 }179 else if(e.value === '22' || e.value === '23'){180 this.setState({181 statusKepemilikan: [{value: '', label: 'KEMENKES PUSAT'}, {value: '', label: 'DINKES PROVINSI'},182 {value: '', label: 'DINKES KAB/KOTA'}, {value: '', label: 'TNI'}, {value: '', label: 'POLRI'},183 {value: '', label: 'BUMN/BUMD'}, {value: '', label: 'SWASTA'}, {value: '', label: 'LSOM'},],184 select3: e, hidden_statusKepemilikan: false, 185 })186 }187 else if (e.value === '24') {188 this.setState({189 statusKepemilikan: [{value: '', label: 'DINKES KABUPATEN/KOTA'}], select3: e, hidden_statusKepemilikan: false,190 })191 }192 else if (e.value === '25'){193 this.setState({194 statusKepemilikan: [{value: '', label: 'SWASTA'}], select3: e, hidden_statusKepemilikan: false,195 })196 }197 else if (e.value === '26'){198 this.setState({199 statusKepemilikan: [{value: '', label: 'KEMENKES PUSAT'}, {value: '', label: 'DINKES PROVINSI'}, 200 {value: '', label: 'DINKES KAB/KOTA'},{value: '', label: 'TNI'}, {value: '', label: 'POLRI'}, 201 {value: '', label: 'BUMN/BUMD'}, {value: '', label: 'SWASTA'}, {value: '', label: 'LSOM'},],202 select3: e, hidden_statusKepemilikan: false,203 })204 205 }206 else if (e.value === '27'){207 this.setState({208 statusKepemilikan: [{value: '', label: 'KEMENKES PUSAT'}, {value: '', label: 'DINKES PROVINSI'}, 209 {value: '', label: 'DINKES KAB/KOTA'},{value: '', label: 'TNI'}, {value: '', label: 'POLRI'}, 210 {value: '', label: 'BUMN/BUMD'}, {value: '', label: 'SWASTA'}, {value: '', label: 'LSOM'},],211 select3: e, hidden_statusKepemilikan: false,212 })213 }214 else if (e.value === '28' || e.value === '29' || e.value === '30') {215 this.setState({216 statusKepemilikan: [{value: '', label: 'DINKES KAB/KOTA'}], select3: e, hidden_statusKepemilikan: false,217 })218 }219 else if (e.value === '31') {220 this.setState({221 statusKepemilikan: [{value: '', label: 'SWASTA'}], select3: e, hidden_statusKepemilikan: false,222 })223 }224 }225 else {226 this.setState({227 statusKepemilikan: [], select3: null, select4: null, hidden_statusKepemilikan: true, kbPerusahaan: null, pkbrs: null,228 kerjasamaBpjsLsngTdk: [], selKerjasamaBpjsLsngTdk: true, valKerjasamaBpjs: null, 229 valKerjasamaBpjsLsngTdk: null, selKerjasamaBpjs: true, activeTab: '', hidden_pkbrs: true, hidden_kbPerusahaan: true,230 })231 }232 }233 changeSel4 = (e) => {234 if(e){235 if(this.state.select3.value === '21'){236 this.setState({237 select4: e, kbPerusahaan: [{ value: 'tidak', label: 'TIDAK' }], pkbrs: [{ value: 'tidak', label: 'TIDAK' }],238 selKerjasamaBpjs: false239 })240 }241 else if (this.state.select3.value === '22' || this.state.select3.value === '23'){242 this.setState({243 select4: e, 244 kbPerusahaan: [{ value: 'tidak', label: 'TIDAK' }], 245 // pkbrs: [{ value: 'ya', label: 'Ya' }],246 hidden_pkbrs: false,247 // selKerjasamaBpjs: false248 })249 }250 else if(this.state.select3.value === '24'){251 this.setState({252 select4: e, kbPerusahaan: [{ value: 'tidak', label: 'TIDAK' }], pkbrs: [{ value: 'tidak', label: 'TIDAK' }],253 selKerjasamaBpjs: false254 })255 }256 else if(this.state.select3.value === '25'){257 this.setState({258 select4: e, kbPerusahaan: [{ value: 'tidak', label: 'TIDAK' }], pkbrs: [{ value: 'tidak', label: 'TIDAK' }],259 selKerjasamaBpjs: false260 })261 }262 else if(this.state.select3.value === '26'){263 // if(e.label === 'KEMENKES PUSAT' || e.label === 'DINKES PROVINSI' || e.label === 'DINKES KAB/KOTA' || e.label === 'TNI' || e.label === 'POLRI'){264 this.setState({265 select4: e, 266 // kbPerusahaan: [{ value: 'tidak', label: 'TIDAK' }], 267 pkbrs: [{ value: 'tidak', label: 'TIDAK' }],268 hidden_kbPerusahaan: false,269 })270 // }271 // else if(e.label === 'BUMN/BUMD' || e.label === 'SWASTA' || e.label === 'LSOM'){272 // this.setState({273 // select4: e, kbPerusahaan: [{ value: 'ya', label: 'Ya' }], pkbrs: [{ value: 'tidak', label: 'TIDAK' }],274 // selKerjasamaBpjs: false275 // })276 // }277 }278 else if(this.state.select3.value === '27'){279 this.setState({280 select4: e, 281 kbPerusahaan: [{ value: 'tidak', label: 'TIDAK' }], 282 // pkbrs: [{ value: 'ya', label: 'Ya' }],283 hidden_pkbrs: false,284 })285 } 286 else if(this.state.select3.value === '28' || this.state.select3.value === '29' || this.state.select3.value === '30') {287 this.setState({288 select4: e, kbPerusahaan: [{ value: 'tidak', label: 'TIDAK' }], pkbrs: [{ value: 'tidak', label: 'TIDAK' }],289 selKerjasamaBpjs: false290 })291 }292 else if(this.state.select3.value === '31'){293 this.setState({294 select4: e, kbPerusahaan: [{ value: 'tidak', label: 'TIDAK' }], pkbrs: [{ value: 'tidak', label: 'TIDAK' }],295 selKerjasamaBpjs: false296 })297 }298 }299 else {300 this.setState({301 select4: null, kbPerusahaan: null, pkbrs: null, 302 kerjasamaBpjsLsngTdk: [], selKerjasamaBpjsLsngTdk: true, valKerjasamaBpjs: null, 303 valKerjasamaBpjsLsngTdk: null, selKerjasamaBpjs: true, hidden_pkbrs: true, hidden_kbPerusahaan: true, activeTab: ''304 })305 }306 }307 // selKerjasamaBpjs: true,308 // selKerjasamaBpjsLsngTdk: true,309 changeKbPerusahaan = (e) => {310 if(e){311 if(this.state.select3.value === '26'){312 this.setState({313 kbPerusahaan: e, selKerjasamaBpjs: false314 })315 }316 }317 else {318 this.setState({319 kbPerusahaan: [], selKerjasamaBpjs: true320 })321 }322 }323 changeSelPkbrs = (e) => {324 if(e){325 if(this.state.select3.value === '22' || this.state.select3.value === '23') {326 this.setState({327 pkbrs: e, selKerjasamaBpjs: false328 })329 }330 else if(this.state.select3.value === '27') {331 this.setState({332 pkbrs: e, selKerjasamaBpjs: false333 })334 }335 }336 else{337 this.setState({338 pkbrs: [], selKerjasamaBpjs: true, selKerjasamaBpjsLsngTdk: true, kerjasamaBpjsLsngTdk: [],339 valKerjasamaBpjs: null, valKerjasamaBpjsLsngTdk: null, activeTab: ''340 })341 }342 console.log(e)343 }344 option4 = (e) => {345 // console.log(e.value)346 if(e){347 if(e.value === 'ya'){348 if(this.state.noJaringanJejaring){349 this.setState({350 kerjasamaBpjsLsngTdk: [{ value: 'tidak_langsung', label: 'Tidak Langsung' }], selKerjasamaBpjsLsngTdk: false, valKerjasamaBpjs: e351 })352 }353 else if (this.state.noRegisterFaskesKb) {354 this.setState({355 kerjasamaBpjsLsngTdk: [{ value: 'langsung', label: 'Langsung' }], selKerjasamaBpjsLsngTdk: false, valKerjasamaBpjs: e356 })357 }358 }359 else if(e.value === 'tidak') {360 this.setState({361 kerjasamaBpjsLsngTdk: [], selKerjasamaBpjsLsngTdk: true, valKerjasamaBpjs: e, valKerjasamaBpjsLsngTdk: null, activeTab: ''362 })363 }364 }365 else{366 this.setState({367 kerjasamaBpjsLsngTdk: [], selKerjasamaBpjsLsngTdk: true, valKerjasamaBpjs: null, valKerjasamaBpjsLsngTdk: null, activeTab: ''368 })369 }370 }371 option5 = (e) => {372 if (e === null){373 this.setState({374 activeTab: '', valKerjasamaBpjsLsngTdk: null375 })376 } else if (e.value === 'langsung'){377 this.setState({378 activeTab: '1', valKerjasamaBpjsLsngTdk: e379 })380 } else if (e.value === 'tidak_langsung'){381 this.setState({382 activeTab: '2', valKerjasamaBpjsLsngTdk: e383 })384 }385 }386 render() {387 return (388 <div>389 <Row>390 <Col sm="12">391 <Row>392 <Col md="3"></Col>393 394 <Col md="6" style={{ textAlign: 'center' }}>395 <CardBody>396 <h6>KARTU PENDAFTARAN TEMPAT PELAYANAN KB</h6>397 <Row>398 <Col md="3" xs="6" style={{ textAlign: 'center' }} >399 <Row>400 <Input style={{ marginRight: '5px', textAlign: 'center' }} type="read-only" id="text-input" name="text-input" value={this.props.kd_prov} disabled/>401 </Row>402 <Row >403 <Col md="12" style={{ textAlign: 'center' }}>404 <Label>Kode Provinsi</Label>405 </Col>406 </Row>407 </Col>408 <Col md="3" xs="6">409 <Row>410 <Input style={{ marginRight: '5px', textAlign: 'center' }} type="read-only" id="text-input" name="text-input" value={this.props.kd_kab} disabled/>411 </Row>412 <Row>413 <Col md="12" style={{ textAlign: 'center' }}>414 <Label>Kode Kabupaten/Kota</Label>415 </Col>416 </Row>417 </Col>418 <Col md="3" xs="6">419 <Row>420 <Input type="number" 421 // onInput = {(e) =>{422 // e.target.value = Math.max(0, parseInt(e.target.value) ).toString().slice(0,3)423 // }}424 onInput={this.inputFaskeskb}425 disabled={this.state.hidden_noRegisterFaskesKb}426 style={{ marginRight: '5px', textAlign: 'center' }} id="text-input" name="text-input" />427 </Row>428 <Row>429 <Col md="12" style={{ textAlign: 'center' }}>430 <Label>No. Register Faskes KB</Label>431 </Col>432 </Row>433 </Col>434 <Col md="3" xs="6">435 <Row>436 <Input type="number" 437 // onInput = {(e) =>{438 // e.target.value = Math.max(0, parseInt(e.target.value) ).toString().slice(0,2)439 // }}440 onInput={this.JaringanJejaring}441 style={{ marginRight: '5px', textAlign: 'center' }} id="text-input" name="text-input"/>442 </Row>443 <Row>444 <Col md="12" style={{ textAlign: 'center' }}>445 <Label>No. Jaringan/Jejaring Faskes KB</Label>446 </Col>447 </Row>448 </Col>449 </Row>450 </CardBody>451 </Col>452 <Col md="3"></Col>453 </Row>454 <CardBody className="card-body-nopad">455 <h6>I. Identitas </h6>456 <div style={{position:'absolute', right: '20px', marginTop:'-30px', fontSize:'12px'}}>{this.props.currentStep}/{this.props.totalSteps}</div>457 <FormGroup>458 <Row>459 <Col md="4">460 <Label className="labelForm">1. Nama Tempat Pelayan KB</Label>461 </Col>462 <Col md="4">463 <Input type="text" id="text-input" name="text-input" />464 </Col>465 </Row>466 <Row>467 <Col md="12">468 <Label style={{ marginTop: '10px' }} className="labelForm">2. Alamat</Label>469 <Row>470 <Col md="4" xs="12" style={{ paddingTop: '10px' }}>471 <Label className="labelForm">a. Jalan :</Label>472 </Col>473 <Col md="4" style={{ paddingTop: '10px' }}>474 <Input type="text" id="text-input" name="text-input" />475 </Col>476 <Col md="2" xs="6" style={{ paddingTop: '10px' }}>477 <Row>478 <Col md="3" xs="4"><Label className="labelForm">RT</Label></Col>479 <Col md="9" xs="8"><Input type="read-only" id="text-input" name="text-input" value={this.props.rt} /></Col>480 </Row>481 </Col>482 <Col md="2" xs="6" style={{ paddingTop: '10px' }}>483 <Row>484 <Col md="3" xs="4"><Label className="labelForm">RW</Label></Col>485 <Col md="9" xs="8"><Input type="read-only" id="text-input" name="text-input" value={this.props.rw} /></Col>486 </Row>487 </Col>488 </Row>489 <Row>490 <Col md="4" style={{marginTop:'10px'}}>491 <Label>b. Desa/Kelurahan :</Label>492 </Col>493 <Col md="7" xs="9" style={{marginTop:'10px'}}>494 <Input type="text" id="text-input" name="text-input" value={this.props.desa} />495 </Col>496 <Col md="1" xs="3" style={{marginTop:'10px'}}>497 <Input type="text" id="text-input" name="text-input" value={this.props.kd_des} />498 </Col>499 </Row>500 <Row>501 <Col md="4" style={{marginTop:'10px'}}>502 <Label>c. Kecamatan :</Label>503 </Col>504 <Col md="7" xs="9" style={{marginTop:'10px'}}>505 <Input type="text" id="text-input" name="text-input" value={this.props.kecamatan} />506 </Col>507 <Col md="1" xs="3" style={{marginTop:'10px'}}>508 <Input type="text" id="text-input" name="text-input" value={this.props.kd_kec} />509 </Col>510 </Row>511 <Row>512 <Col md="4" style={{marginTop:'10px'}}>513 <Label>d. Kabupaten :</Label>514 </Col>515 <Col md="7" xs="9" style={{marginTop:'10px'}}>516 <Input type="text" id="text-input" name="text-input" value={this.props.kabupaten} />517 </Col>518 <Col md="1" xs="3" style={{marginTop:'10px'}}>519 <Input type="text" id="text-input" name="text-input" value={this.props.kd_kab} />520 </Col>521 </Row>522 <Row>523 <Col md="4" style={{marginTop:'10px'}}>524 <Label>e. Provinsi :</Label>525 </Col>526 <Col md="7" xs="9" style={{marginTop:'10px'}}>527 <Input type="text" id="text-input" name="text-input" value={this.props.provinsi} />528 </Col>529 <Col md="1" xs="3" style={{marginTop:'10px'}}>530 <Input type="text" id="text-input" name="text-input" value={this.props.kd_prov} />531 </Col>532 </Row>533 </Col>534 </Row>535 <Row style={{ paddingTop: '20px' }}>536 <Col md="4" style={{ paddingTop: '10px' }}>537 <Label>3. Jenis</Label>538 </Col>539 <Col md="2" style={{ paddingTop: '10px' }}>540 <Select options={this.state.show_jenisFaskesKb} onChange={this.changeSel1} placeholder="Jenis Faskes KB" value={this.state.select1} isDisabled={this.state.hidden_jenisFaskesKb} isClearable />541 </Col>542 <Col md="2" style={{ paddingTop: '10px' }}>543 <Select options={this.state.show_tingkatFaskesKb} onChange={this.changeSel2} placeholder="Jenis Tingkat Faskes KB" value={this.state.select2} isDisabled={this.state.hidden_tingkatFaskesKb} isClearable />544 </Col>545 <Col md="2" style={{ paddingTop: '10px' }}>546 <Select options={this.state.show_tingkatPelayanan} onChange={this.changeSel3} placeholder="Jenis Tingkat Pelayanan" value={this.state.select3} isDisabled={this.state.hidden_tingkatPelayanan} isClearable />547 </Col>548 </Row>549 <Row style={{ marginTop: '15px' }}>550 <Col md='4' style={{ paddingTop: '10px' }}>551 <Label>4. Kepemilikan</Label>552 </Col>553 <Col md="2" style={{ paddingTop: '10px' }}>554 <Select options={this.state.statusKepemilikan} onChange={this.changeSel4} value={this.state.select4} isDisabled={this.state.hidden_statusKepemilikan} placeholder="Status Kepemilikan" isClearable />555 </Col>556 </Row>557 <Row style={{ marginTop: '15px' }}>558 <Col md='4' style={{ paddingTop: '10px' }}>559 <Label>5. Apakah faskes KB termasuk pada:</Label>560 </Col>561 <Col md="1" style={{ paddingTop: '10px' }}>562 <Label>KB Perusahaan</Label>563 </Col>564 <Col md="2" style={{ paddingTop: '10px' }}>565 <Select options={this.state.show_kbPerusahaan} isDisabled={this.state.hidden_kbPerusahaan} onChange={this.changeKbPerusahaan} value={this.state.kbPerusahaan} isClearable />566 </Col>567 <Col md="1" style={{ paddingTop: '10px' }}>568 <Label>PKBRS</Label>569 </Col>570 <Col md="2" style={{ paddingTop: '10px' }}>571 <Select options={this.state.show_pkbrs} isDisabled={this.state.hidden_pkbrs} onChange={this.changeSelPkbrs} value={this.state.pkbrs} isClearable />572 </Col>573 </Row>574 <Row style={{ marginTop: '15px' }}>575 <Col md="4" xs="12" style={{ paddingTop: '10px' }}>576 <Label>6. Kerjasama Dengan BPJS Kesehatan </Label>577 <Label style={{ paddingLeft: '10px'}}>(pilih Ya atau Tidak, jika Ya, maka pilih Langsung atau Tidak Langsung, selanjutnya isi No. PKS, masa berlaku PKS dan no. registernya pada BPJS Kesehatan)</Label>578 </Col>579 <Col md="2" xs="6" style={{ paddingTop: '10px' }}>580 <Select options={this.state.kerjasamaBpjs} isDisabled={this.state.selKerjasamaBpjs} value={this.state.valKerjasamaBpjs} onChange={this.option4} isClearable /> 581 </Col>582 <Col md="2" xs="6" style={{ paddingTop: '10px' }}>583 <Select options={this.state.kerjasamaBpjsLsngTdk} isDisabled={this.state.selKerjasamaBpjsLsngTdk} value={this.state.valKerjasamaBpjsLsngTdk} onChange={this.option5} isClearable /> 584 </Col>585 </Row>586 <TabContent style={{ border: 'none' }} activeTab={this.state.activeTab}>587 <TabPane tabId="1">588 <Row style={{ marginTop: '5px' }}>589 <Col md="4"></Col>590 <Col md="4">591 <Label>Langsung</Label>592 <Row style={{ marginTop: '15px' }}>593 <Col md="4">594 <Label>No. PKS : </Label>595 </Col>596 <Col md="5">597 <Input type="text" id="text-input" name="text-input" />598 </Col>599 </Row>600 <Row style={{ marginTop: '15px' }}>601 <Col md="4">602 <Label>Masa Berlaku Awal : </Label>603 </Col>604 <Col md="5">605 <Input type="date" id="text-input" name="text-input" />606 </Col>607 </Row>608 <Row style={{ marginTop: '15px' }}>609 <Col md="4">610 <Label>Masa Berlaku Akhir : </Label>611 </Col>612 <Col md="5">613 <Input type="date" id="text-input" name="text-input" />614 </Col>615 </Row>616 <Row style={{ marginTop: '15px' }}>617 <Col md="4">618 <Label>No. Register : </Label>619 </Col>620 <Col md="5">621 <Input type="text" id="text-input" name="text-input" />622 </Col>623 </Row>624 </Col>625 </Row>626 </TabPane>627 <TabPane tabId="2">628 <Row style={{ marginTop: '5px' }}>629 <Col md="4"></Col>630 <Col md="4">631 <Label>Tidak Langsung</Label>632 <Row style={{ marginTop: '15px' }}>633 <Col md="4">634 <Label>No. PKS : </Label>635 </Col>636 <Col md="5">637 <Input type="text" id="text-input" name="text-input" />638 </Col>639 </Row>640 <Row style={{ marginTop: '15px' }}>641 <Col md="4">642 <Label>Masa Berlaku Awal : </Label>643 </Col>644 <Col md="5">645 <Input type="date" id="text-input" name="text-input" />646 </Col>647 </Row>648 <Row style={{ marginTop: '15px' }}>649 <Col md="4">650 <Label>Masa Berlaku Akhir : </Label>651 </Col>652 <Col md="5">653 <Input type="date" id="text-input" name="text-input" />654 </Col>655 </Row>656 </Col>657 </Row>658 </TabPane>659 </TabContent>660 </FormGroup>661 </CardBody>662 </Col>663 </Row>664 <div style={{display:'flex', justifyContent:'space-between'}}>665 <Button className="btn btn-warning" onClick={this.props.buttonBack}>Sebelumnya</Button>666 <Button className="btn btn-info" onClick={this.props.nextStep}>Selanjutnya</Button>667 </div>668 </div>669 )670 }671}...

Full Screen

Full Screen

routes.js

Source:routes.js Github

copy

Full Screen

1import React from 'react';2import CreatePPLKB from './views/Pages/dallap/sdm/pplkb/create';3const Dashboard = React.lazy(() => import('./views/Dashboard'));4const Icon = React.lazy(() => import('./views/Base/Icon'));5const Table = React.lazy(() => import('./views/Base/Table'));6// YAN KB PELKON7const Pendaftaran = React.lazy(() => import('./views/Pages/yankbpelkon/pendaftaran/index'));8const CreateYankbpelkon = React.lazy(() => import('./views/Pages/yankbpelkon/pendaftaran/create/create'));9const LihatYankbpelkon = React.lazy(() => import('./views/Pages/yankbpelkon/pendaftaran/lihat/lihat'));10const EditYankbpelkon = React.lazy(() => import('./views/Pages/yankbpelkon/pendaftaran/edit/edit'));11const RegistrasiYAN = React.lazy(() => import('./views/Pages/yankbpelkon/registrasi/index'));12const CreateRegistrasi = React.lazy(() => import('./views/Pages/yankbpelkon/registrasi/create/create'));13const EditRegistrasi = React.lazy(() => import('./views/Pages/yankbpelkon/registrasi/edit/edit'));14const LihatRegistrasi = React.lazy(() => import('./views/Pages/yankbpelkon/registrasi/lihat/lihat'));15const MutasiAlokon = React.lazy(() => import('./views/Pages/yankbpelkon/mutasiAlokon'));16const CreateMutasiAlokon = React.lazy(() => import('./views/Pages/yankbpelkon/mutasiAlokon/create/create'));17const EditMutasiAlokon = React.lazy(() => import('./views/Pages/yankbpelkon/mutasiAlokon/edit/edit'));18const LihatMutasiAlokon = React.lazy(() => import('./views/Pages/yankbpelkon/mutasiAlokon/lihat/lihat'));19// Dallap Laporan20const DallapLaporan = React.lazy(() => import('./views/Pages/dallap/report/index'))21const DetailDallap = React.lazy(() => import('./views/Pages/dallap/report/detail'))22const DetailDallapProvinsi = React.lazy(() => import('./views/Pages/dallap/report/provinsi'))23const DetailDallapKabupaten = React.lazy(() => import('./views/Pages/dallap/report/kabupaten'))24const BulanTable1 = React.lazy(() => import('./views/Pages/dallap/report/bulanTable1/detail'))25const BulanTable1Provinsi = React.lazy(() => import('./views/Pages/dallap/report/bulanTable1/provinsi'))26const BulanTable1Kabupaten = React.lazy(() => import('./views/Pages/dallap/report/bulanTable1/kabupaten'))27const BulanTable2 = React.lazy(() => import('./views/Pages/dallap/report/bulanTable2/detail'))28const BulanTable2Provinsi = React.lazy(() => import('./views/Pages/dallap/report/bulanTable2/provinsi'))29const BulanTable2Kabupaten = React.lazy(() => import('./views/Pages/dallap/report/bulanTable2/kabupaten'))30const BulanTable3 = React.lazy(() => import('./views/Pages/dallap/report/bulanTable3/detail'))31const BulanTable3Provinsi = React.lazy(() => import('./views/Pages/dallap/report/bulanTable3/provinsi'))32const BulanTable3Kabupaten = React.lazy(() => import('./views/Pages/dallap/report/bulanTable3/kabupaten'))33// YANKB Laporan34const YanKBLaporan = React.lazy(() => import('./views/Pages/yankbpelkon/report/index'))35const DetailYankb = React.lazy(() => import('./views/Pages/yankbpelkon/report/detail'))36const DetailYankbProvinsi = React.lazy(() => import('./views/Pages/yankbpelkon/report/provinsi'))37const DetailYankbKabupaten = React.lazy(() => import('./views/Pages/yankbpelkon/report/kabupaten'))38const BulanTable1YanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/bulanTable1/detail'))39const BulanTable1ProvinsiYanb = React.lazy(() => import('./views/Pages/yankbpelkon/report/bulanTable1/provinsi'))40const BulanTable1KabupatenYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/bulanTable1/kabupaten'))41const BulanTable2YanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/bulanTable2/detail'))42const BulanTable2ProvinsiYanb = React.lazy(() => import('./views/Pages/yankbpelkon/report/bulanTable2/provinsi'))43const BulanTable2KabupatenYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/bulanTable2/kabupaten'))44const BulanTable3YanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/bulanTable3/detail'))45const BulanTable3ProvinsiYanb = React.lazy(() => import('./views/Pages/yankbpelkon/report/bulanTable3/provinsi'))46const BulanTable3KabupatenYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/bulanTable3/kabupaten'))47const TahunTable2YanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable2/detail'))48const TahunTable2ProvinsiYanb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable2/provinsi'))49const TahunTable2KabupatenYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable2/kabupaten'))50const TahunTable3YanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable3/detail'))51const TahunTable3ProvinsiYanb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable3/provinsi'))52const TahunTable3KabupatenYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable3/kabupaten'))53const TahunTable4YanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable4/detail'))54const TahunTable4ProvinsiYanb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable4/provinsi'))55const TahunTable4KabupatenYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable4/kabupaten'))56const TahunTable4BYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable4B/detail'))57const TahunTable4BProvinsiYanb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable4B/provinsi'))58const TahunTable4BKabupatenYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable4B/kabupaten'))59const TahunTable5AYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable5A/detail'))60const TahunTable5AProvinsiYanb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable5A/provinsi'))61const TahunTable5AKabupatenYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable5A/kabupaten'))62const TahunTable5BYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable5B/detail'))63const TahunTable5BProvinsiYanb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable5B/provinsi'))64const TahunTable5BKabupatenYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable5B/kabupaten'))65const TahunTable5CYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable5C/detail'))66const TahunTable5CProvinsiYanb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable5C/provinsi'))67const TahunTable5CKabupatenYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable5C/kabupaten'))68const TahunTable8AYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable8A/detail'))69const TahunTable8AProvinsiYanb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable8A/provinsi'))70const TahunTable8AKabupatenYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable8A/kabupaten'))71const TahunTable8BYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable8B/detail'))72const TahunTable8BProvinsiYanb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable8B/provinsi'))73const TahunTable8BKabupatenYanKb = React.lazy(() => import('./views/Pages/yankbpelkon/report/tahunTable8B/kabupaten'))74// Sumber Daya Manusia75const PPLKB = React.lazy(() => import('./views/Pages/dallap/sdm/pplkb'));76const PKB = React.lazy(() => import('./views/Pages/dallap/sdm/pkb/index'));77const CreatePKB = React.lazy(() => import('./views/Pages/dallap/sdm/pkb/create'));78const PPKBD = React.lazy(() => import('./views/Pages/dallap/sdm/ppkbd/index'));79const CreatePPKBD = React.lazy(() => import('./views/Pages/dallap/sdm/ppkbd/create'));80const SubPPKBD = React.lazy(() => import('./views/Pages/dallap/sdm/subPpkbd'));81const KelompokKB = React.lazy(() => import('./views/Pages/dallap/sdm/kelompokKb'));82const PUSDAK = React.lazy(() => import('./views/Pages/dallap/sdm/pusdak'));83// Sarana84const BPKB = React.lazy(() => import('./views/Pages/dallap/sarana/bpkb'));85const PendaftaranMPC = React.lazy(() => import('./views/Pages/dallap/sarana/mpc'));86const PendaftaranMUPEN = React.lazy(() => import('./views/Pages/dallap/sarana/mupen'));87const Penyuluhan = React.lazy(() => import('./views/Pages/dallap/sarana/penyuluhan'));88const RegistrasiMPC = React.lazy(() => import('./views/Pages/dallap/sarana/rog-mpc'));89const RegistrasiMUPEN = React.lazy(() => import('./views/Pages/dallap/sarana/rog-mupen'));90// Sarana91const KelompokBKB = React.lazy(() => import('./views/Pages/dallap/kelompok/kelompok_bkb'));92const RegisterBKB = React.lazy(() => import('./views/Pages/dallap/kelompok/register_bkb'));93// Administrasi94const Umfaskes = React.lazy(() => import('./views/Pages/administrasi/Umfaskes'));95// const MasterFormula = React.lazy(() => import('./views/Master/Formula/Formula'));96// const MasterUser = React.lazy(() => import('./views/Master/User/User'));97// const MasterMenu = React.lazy(() => import('./views/Master/Menu/Menu'));98// const Daily = React.lazy(() => import('./views/Transaction/Planning/Daily'));99// const Dds = React.lazy(() => import('./views/Transaction/Planning/Dds'));100// const SampleColor = React.lazy(() => import('./views/Transaction/Planning/SampleColor'));101// const Po = React.lazy(() => import('./views/Report/Po'));102// const Performance = React.lazy(() => import('./views/Report/Performance'));103// const Monthly = React.lazy(() => import('./views/Report/Monthly'));104// const Yearly = React.lazy(() => import('./views/Report/Yearly'));105// https://github.com/ReactTraining/react-router/tree/master/packages/react-router-config106const routes = [107 { path: '/beranda', exact: true, name: 'Beranda', component: Dashboard},108 // { path: '/beranda', name: 'Beranda', component: Dashboard },109 { path: '/icon', name: 'Icon', component: Icon },110 { path: '/table', name: 'Sample Table', component: Table },111 // { path: '/planning', exact: true, name: 'Planning', component: Daily },112 // { path: '/planning/dp', name: 'Distribution Plan', component: Daily },113 // { path: '/planning/dds', name: 'Daily Distribution Schedule', component: Dds },114 // { path: '/planning/samplecolor', name: 'Sample Color', component: SampleColor },115 // { path: '/report', exact: true, name: 'Report', component: Po },116 // { path: '/report/po', name: 'PO Completeness', component: Po },117 // { path: '/report/performance', name: 'Distribution Performance', component: Performance },118 // { path: '/report/monthly', name: 'Monthly View', component: Monthly },119 // { path: '/report/yearly', name: 'Yearly View', component: Yearly },120 // { path: '/master', exact: true, name: 'Master Data', component: MasterFormula },121 // { path: '/master/formula', name: 'Formula', component: MasterFormula },122 // { path: '/master/user', name: 'User', component: MasterUser },123 // { path: '/master/menu', name: 'Menu', component: MasterMenu },124 // { path: '/um', exact: true, name: 'User Management', component: MasterUser },125 // Start Router Project126 //YAN KB / PELKON127 { path: '/pendaftaran', exact: true, name: 'Pendaftaran Tempat Pelayanan KB', component: Pendaftaran },128 { path: '/pendaftaran/create', name: 'Tambah', component: CreateYankbpelkon },129 { path: '/pendaftaran/lihat', name: 'lihat', component: LihatYankbpelkon },130 { path: '/pendaftaran/edit', name: 'edit', component: EditYankbpelkon },131 { path: '/register', exact: true, name: 'Register Pelayanan KB', component: RegistrasiYAN },132 { path: '/register/create', name: 'Tambah', component: CreateRegistrasi },133 { path: '/register/edit', name: 'Edit', component: EditRegistrasi },134 { path: '/register/lihat', name: 'Lihat', component: LihatRegistrasi },135 { path: '/alokon', exact: true, name: 'Mutasi Alokon', component: MutasiAlokon },136 { path: '/alokon/create', name: 'Tambah', component: CreateMutasiAlokon },137 { path: '/alokon/edit', name: 'Edit', component: EditMutasiAlokon },138 { path: '/alokon/lihat', name: 'Lihat', component: LihatMutasiAlokon },139 //Sumber Daya Manusia140 { path: '/sdm', exact: true, name: 'Sumber Daya Manusia', component: PPLKB },141 { path: '/sdm/pplkb', exact: true, name: 'Pendaftaran PPLKB', component: PPLKB },142 { path: '/sdm/pplkb/create', name: 'Tambah', component: CreatePPLKB },143 { path: '/sdm/pkb', exact: true, name: 'Pendaftaran PKB/PLKB', component: PKB },144 { path: '/sdm/pkb/create', name: 'Tambah', component: CreatePKB },145 { path: '/sdm/ppkbd', exact: true, name: 'Pendaftaran PPKBD', component: PPKBD },146 { path: '/sdm/ppkbd/create', name: 'Tambah', component: CreatePPKBD },147 { path: '/sdm/subPpkbd', name: 'Pendaftaran Sub PPKBD', component: SubPPKBD },148 { path: '/sdm/kelompokKb', name: 'Pendaftaran Kelompok KB', component: KelompokKB },149 { path: '/sdm/pusdak', name: 'Register PUSDAK', component: PUSDAK },150 //Sarana151 { path: '/sarana', exact: true, name: 'SARANA', component: BPKB },152 { path: '/sarana/bpkb', name: 'Pendaftaran BP KB', component: BPKB },153 { path: '/sarana/penyuluhan', name: 'Register Kegiatan Penyuluhan', component: Penyuluhan },154 { path: '/sarana/mupen', name: 'Pendaftaran MUPEN', component: PendaftaranMUPEN },155 { path: '/sarana/mpc', name: 'Pendaftaran MPC', component: PendaftaranMPC },156 { path: '/sarana/rog-mupen', name: 'Register Operasional Gerak MUPEN', component: RegistrasiMUPEN },157 { path: '/sarana/rog-mpc', name: 'Register Operasional Gerak MPC', component: RegistrasiMPC },158 //Kelompok Kegiatan159 { path: '/kegiatan', exact: true, name: 'Kelompok Kegiatan', component: KelompokBKB },160 { path: '/kegiatan/kelompok_bkb', name: 'Kelompok BKB', component: KelompokBKB },161 { path: '/kegiatan/register_bkb', name: 'Register Kegiatan BKB', component: RegisterBKB },162 //Report163 { path: '/lap/dallap', exact: true, name: 'Laporan Dallap', component: DallapLaporan },164 { path: '/lap/DetailDallap', exact: true, name: 'Detail Laporan Dallap', component: DetailDallap },165 { path: '/lap/DetailDallap/provinsi', exact: true, name: 'Detail Laporan Provinsi', component: DetailDallapProvinsi },166 { path: '/lap/DetailDallap/kabupaten', exact: true, name: 'Detail Laporan Kabupaten', component: DetailDallapKabupaten },167 //DallapReport168 { path: '/lap/DetailDallap/table1', exact: true, name: 'Wilayah institusi KB di lapangan', component: BulanTable1 },169 { path: '/lap/DetailDallap/table1/provinsi', exact: true, name: '', component: BulanTable1Provinsi },170 { path: '/lap/DetailDallap/table1/kabupaten', exact: true, name: '', component: BulanTable1Kabupaten },171 { path: '/lap/DetailDallap/table2', exact: true, name: 'Frekuensi Operasional Mupen Provinsi', component: BulanTable2 },172 { path: '/lap/DetailDallap/table2/provinsi', exact: true, name: '', component: BulanTable2Provinsi },173 { path: '/lap/DetailDallap/table2/kabupaten', exact: true, name: '', component: BulanTable2Kabupaten },174 { path: '/lap/DetailDallap/table3', exact: true, name: 'Frekuensi Operasional Mupen Kab/Kota', component: BulanTable3 },175 { path: '/lap/DetailDallap/table3/provinsi', exact: true, name: '', component: BulanTable3Provinsi },176 { path: '/lap/DetailDallap/table3/kabupaten', exact: true, name: '', component: BulanTable3Kabupaten },177 //YankbReport178 { path: '/lap/DetailYankb/table1', exact: true, name: 'Cakupan tempat pelayanan KB', component: BulanTable1YanKb },179 { path: '/lap/DetailYankb/table1/provinsi', exact: true, name: '', component: BulanTable1ProvinsiYanb },180 { path: '/lap/DetailYankb/table1/kabupaten', exact: true, name: '', component: BulanTable1KabupatenYanKb },181 { path: '/lap/DetailYankb/bulan/table2', exact: true, name: 'Hasil Pelayanan KB Baru Dan Daftar Ulang', component: BulanTable2YanKb },182 { path: '/lap/DetailYankb/bulan/table2/provinsi', exact: true, name: '', component: BulanTable2ProvinsiYanb },183 { path: '/lap/DetailYankb/bulan/table2/kabupaten', exact: true, name: '', component: BulanTable2KabupatenYanKb },184 { path: '/lap/DetailYankb/bulan/table3', exact: true, name: 'Pencapaian Peserta KB Baru Berdasarkan Metode Kontrasepsi', component: BulanTable3YanKb },185 { path: '/lap/DetailYankb/bulan/table3/provinsi', exact: true, name: '', component: BulanTable3ProvinsiYanb },186 { path: '/lap/DetailYankb/bulan/table3/kabupaten', exact: true, name: '', component: BulanTable3KabupatenYanKb },187 { path: '/lap/DetailYankb/tahun/table2', exact: true, name: 'Tempat pelayanan KB Pemerintah', component: TahunTable2YanKb },188 { path: '/lap/DetailYankb/tahun/table2/provinsi', exact: true, name: '', component: TahunTable2ProvinsiYanb },189 { path: '/lap/DetailYankb/tahun/table2/kabupaten', exact: true, name: '', component: TahunTable2KabupatenYanKb },190 { path: '/lap/DetailYankb/tahun/table3', exact: true, name: 'Tempat pelayanan KB Swasta', component: TahunTable3YanKb },191 { path: '/lap/DetailYankb/tahun/table3/provinsi', exact: true, name: '', component: TahunTable3ProvinsiYanb },192 { path: '/lap/DetailYankb/tahun/table3/kabupaten', exact: true, name: '', component: TahunTable3KabupatenYanKb },193 { path: '/lap/DetailYankb/tahun/table4', exact: true, name: 'Tempat pelayanan KB Pemerintah Berdasarkan Kepemilikan', component: TahunTable4YanKb },194 { path: '/lap/DetailYankb/tahun/table4/provinsi', exact: true, name: '', component: TahunTable4ProvinsiYanb },195 { path: '/lap/DetailYankb/tahun/table4/kabupaten', exact: true, name: '', component: TahunTable4KabupatenYanKb },196 { path: '/lap/DetailYankb/tahun/table4B', exact: true, name: 'Tempat pelayanan KB Swasta Berdasarkan Kepemilikan', component: TahunTable4BYanKb },197 { path: '/lap/DetailYankb/tahun/table4B/provinsi', exact: true, name: '', component: TahunTable4BProvinsiYanb },198 { path: '/lap/DetailYankb/tahun/table4B/kabupaten', exact: true, name: '', component: TahunTable4BKabupatenYanKb },199 { path: '/lap/DetailYankb/tahun/table5A', exact: true, name: 'Tempat pelayanan KB Swasta Berdasarkan Kepemilikan', component: TahunTable5AYanKb },200 { path: '/lap/DetailYankb/tahun/table5A/provinsi', exact: true, name: '', component: TahunTable5AProvinsiYanb },201 { path: '/lap/DetailYankb/tahun/table5A/kabupaten', exact: true, name: '', component: TahunTable5AKabupatenYanKb },202 { path: '/lap/DetailYankb/tahun/table5B', exact: true, name: 'YANKB Laporan Tempat Pelayanan KB Pemerintah Berdasarkan Status Kerjasama Dengan BPJS Kesehatan', component: TahunTable5BYanKb },203 { path: '/lap/DetailYankb/tahun/table5B/provinsi', exact: true, name: '', component: TahunTable5BProvinsiYanb },204 { path: '/lap/DetailYankb/tahun/table5B/kabupaten', exact: true, name: '', component: TahunTable5BKabupatenYanKb },205 { path: '/lap/DetailYankb/tahun/table5C', exact: true, name: 'YANKB Laporan Tempat Pelayanan KB Pemerintah Berdasarkan Status Kerjasama Dengan BPJS Kesehatan', component: TahunTable5CYanKb },206 { path: '/lap/DetailYankb/tahun/table5C/provinsi', exact: true, name: '', component: TahunTable5CProvinsiYanb },207 { path: '/lap/DetailYankb/tahun/table5C/kabupaten', exact: true, name: '', component: TahunTable5CKabupatenYanKb },208 { path: '/lap/DetailYankb/tahun/table8A', exact: true, name: 'Tempat Pelayanan KB Berdasarkan Klasifikasi Pelayanan KB', component: TahunTable8AYanKb },209 { path: '/table8A/provinsi', exact: true, name: 'Detail Laporan YAN KB / Tempat Pelayanan KB Berdasarkan Klasifikasi Pelayanan KB', component: TahunTable8AProvinsiYanb },210 { path: '/table8A/kabupaten', exact: true, name: 'Detail Laporan YAN KB / Tempat Pelayanan KB Berdasarkan Klasifikasi Pelayanan KB', component: TahunTable8AKabupatenYanKb },211 { path: '/lap/DetailYankb/tahun/table8B', exact: true, name: 'Faskes KB Berdasarkan Status Kerjasama Dengan BPJS Kesehatan Dan Klasifikasi KB', component: TahunTable8BYanKb },212 { path: '/table8B/provinsi', exact: true, name: 'Detail Laporan YAN KB / Faskes KB Berdasarkan Status Kerjasama Dengan BPJS Kesehatan Dan Klasifikasi KB', component: TahunTable8BProvinsiYanb },213 { path: '/table8B/kabupaten', exact: true, name: 'Detail Laporan YAN KB / Faskes KB Berdasarkan Status Kerjasama Dengan BPJS Kesehatan Dan Klasifikasi KB', component: TahunTable8BKabupatenYanKb },214 { path: '/lap/yankb', exact: true, name: 'Laporan YAN KB', component: YanKBLaporan },215 { path: '/lap/DetailYankb', exact: true, name: 'Detail Laporan YAN KB', component: DetailYankb },216 { path: '/lap/DetailYankb/provinsi', exact: true, name: 'Laporan YAN KB Provinsi', component: DetailYankbProvinsi },217 { path: '/lap/DetailYankb/kabupaten', exact: true, name: 'Laporan YAN KB Kabupaten', component: DetailYankbKabupaten },218 //Administrasi219 { path: '/adm/umfaskes', exact: true, name: 'User Manajemen Faskes', component: Umfaskes },220];...

Full Screen

Full Screen

EntityInfo.js

Source:EntityInfo.js Github

copy

Full Screen

1function EntityInfo(cnt_id){2 this.cnt_id = cnt_id;3 this.container = $(cnt_id);4 this.legend="Entity Info";5 this.info_list = $(document.createElement("ul"));6 this.gender_list = {'M':'Male','F':'Female','U':'Unknown','O':'Others'};7 this.group_btn = null;8 this.kb_row = null;9 this.kb_row_pos = 0;10 this.kb_toggle_btn =$(document.createElement("button")).addClass("btn dropdown-toggle").attr("data-toggle","dropdown").text("0/0"); 11 this.kb_toggle_menu = $(document.createElement("ul")).addClass("dropdown-menu");12 this.carousel = new function(){};13 this.column_ext = null;14 this.kb_row_select = {};15 this.kb_row_select_id = null;16 this.isCoref = false;17};18EntityInfo.prototype.init = function(carousel){19 if(carousel != undefined){20 this.carousel = carousel; 21 }22 23 this.group_btn = $(document.createElement("div")).addClass("btn-group").append(24 $(document.createElement("button")).addClass("btn").text("<").click($.proxy(this.listPrev, this)),25 this.kb_toggle_btn,26 $(document.createElement("button")).addClass("btn").text(">").click($.proxy(this.listNext, this)),27 this.kb_toggle_menu28 );29 this.container.append(30 $(document.createElement("div")).addClass("page-header").append(31 $(document.createElement("span")).text(this.legend),32 $(document.createElement("div")).addClass("pull-right").append(33 this.group_btn 34 )35 ),36 37 this.info_list38 );39 40 this.group_btn.hide();41};42 43EntityInfo.prototype.clear = function(){44 this.info_list.empty();45 this.group_btn.hide();46};47EntityInfo.prototype.setColumnExtension = function(ext){48 if(ext != null && ext!= undefined){49 this.column_ext = ext;50 }else{51 this.column_ext = null;52 };53};54EntityInfo.prototype.listNext = function(){55 //console.log((this.kb_row_pos -1) % this.kb_row.length);56 this.kb_row_pos = (this.kb_row_pos + 1) % this.kb_row.length;57 //console.log(this.kb_row_pos);58 this._update(this.kb_row[this.kb_row_pos]);59 this.kb_toggle_btn.text((this.kb_row_pos + 1)+"/"+this.kb_row.length);60 this.group_btn.show();61};62EntityInfo.prototype.listPrev = function(){63 //console.log((this.kb_row_pos -1) % this.kb_row.length);64 this.kb_row_pos = (this.kb_row_pos -1) < 0 ? this.kb_row.length-1 : ((this.kb_row_pos -1) % this.kb_row.length);65 //console.log(this.kb_row_pos);66 this._update(this.kb_row[this.kb_row_pos]);67 this.kb_toggle_btn.text((this.kb_row_pos + 1)+"/"+this.kb_row.length);68 this.group_btn.show();69};70EntityInfo.prototype.listSelect = function(event){71 var element = event.target;72 this.kb_row_pos = parseInt($(element).attr("data-position"));73 this._update(this.kb_row[this.kb_row_pos]);74 this.kb_toggle_btn.text((this.kb_row_pos + 1)+"/"+this.kb_row.length);75 this.group_btn.show();76};77EntityInfo.prototype.getChanges = function(){78 return this.kb_row_select;79};80EntityInfo.prototype.update = function(kb_item, isCoref){81 this.clear();82 this.isCoref = isCoref;83 //console.log(kb_item);84 this.group_btn.hide();85 if(Array.isArray(kb_item)){86 this.kb_row = kb_item;87 this.kb_row_pos = 0;88 this.kb_row_select_id = String(this.kb_row[0]["id"].replace(":","-"));89 if(this.kb_row_select.hasOwnProperty(this.kb_row_select_id)){90 this.kb_row_pos = this.kb_row_select[this.kb_row_select_id];91 }92 93 this.kb_toggle_btn.text((this.kb_row_pos+1)+"/"+this.kb_row.length);94 this.kb_toggle_menu.empty();95 for(var i in kb_item){96 var txt = this.getBestTextField(kb_item[i]);97 98 this.kb_toggle_menu.append(99 $(document.createElement("li")).append(100 $(document.createElement("a")).attr({"href":"#","data-position":i}).text(txt).click($.proxy(this.listSelect,this))101 )102 );103 }104 105 this._update(this.kb_row[this.kb_row_pos]);106 this.group_btn.show();107 }else{108 this.kb_row_select_id = null;109 this._update(kb_item);110 111 }112};113EntityInfo.prototype.getBestTextField = function(kb_item){114 var fields = ["preferred term","name","display term","hidden text"];115 var field = "";116 var text = "";117 for(var i in fields){118 field = fields[i];119 if(kb_item[field] != "" && kb_item[field] != undefined){120 text = kb_item[field];121 break;122 }123 }124 125 return text;126 127};128EntityInfo.prototype._update = function(kb_row){129 this.clear();130 var data="";131 var prefix = null;132 var ext = null;133 if(this.column_ext != null){134 prefix = kb_row["id"].split(":")[0];135 if(this.column_ext.hasOwnProperty(prefix)){136 ext = this.column_ext[prefix];137 138 }139 }140 141 if(this.kb_row_select_id != null){142 this.kb_row_select[this.kb_row_select_id] = this.kb_row_pos;143 }144 //this.carousel.update(kb_row);145 for(var i in kb_row){146 liitem = $(document.createElement('li'));147 if(kb_row[i] == "" || i.endsWith("escaped") || i == "hidden text" || i == "hidden rows"){148 continue;149 }else if(ext != null && ext.hasOwnProperty(i)){150 var data = (ext[i]["data"] == '') ? kb_row[i] : ext[i]["data"]+kb_row[i];151 152 if(ext[i]["type"] == "url"){153 liitem.append($(document.createElement('b')).text(i + ": "));154 liitem.append($(document.createElement('a')).attr('href',data).text(kb_row[i]));155 }else if(ext[i]["type"] == "image"){156 liitem.append($(document.createElement('b')).text(i + ": "));157 liitem.append(kb_row[i].join(", "));158 this.carousel.addImages(kb_row[i], ext[i]["data"]);159 }160 }else if(i == "type"){161 liitem.append($(document.createElement('b')).text(i + ": "));162 var text = (this.isCoref == true) ? kb_row[i]+(" (coref)") : kb_row[i];163 liitem.append(text);164 }else if(i.endsWith("url")){165 liitem.append($(document.createElement('b')).text(i + ": "));166 liitem.append($(document.createElement('a')).attr('href',kb_row[i]).text(kb_row[i]));167 }else if(i == "ulan id"){168 liitem.append($(document.createElement('b')).text(i + ": "));169 liitem.append($(document.createElement('a')).attr('href','http://www.getty.edu/vow/ULANFullDisplay?find=&role=&nation=&subjectid='+kb_row[i]).text(kb_row[i]));170 }else if(i == "image"){171 liitem.append($(document.createElement('b')).text(i + ": "));172 liitem.append(kb_row[i].join(", "));173 }else if(i == "geonames id"){174 liitem.append($(document.createElement('b')).text(i + ": "));175 liitem.append($(document.createElement('a')).attr('href','http://www.geonames.org/'+kb_row[i]).text(kb_row[i]));176 }else if(i == "feature code"){177 liitem.append($(document.createElement('b')).text(i + ": ")); 178 liitem.append(kb_row[i][1]+ " ("+ kb_row[i][0]+ ")"); 179 }else{180 if(Array.isArray(kb_row[i])){181 data = kb_row[i].join("; ");182 if(i == "timezone"){183 data = "UTC"+data;184 }else if(i == "freebase types"){185 //console.log(data);186 data = Array();187 for (index = 0; index < kb_row[i].length; index++) {188 item = kb_row[i][index];189 data.push($(document.createElement('a')).attr("href", item.substring(1, item.length-1)).text(item));190 data.push("; ");191 //console.log(item.substring(1, item.length-1));192 }193 data.pop();194 liitem.append($(document.createElement('b')).text(i + ": "));195 liitem.append(data);196 this.info_list.append(liitem);197 continue;198 }199 }else{200 data = kb_row[i];201 if(i == "gender"){202 data = this.gender_list[data];203 }204 205 }206 liitem.append($(document.createElement('b')).text(i + ": "));207 //liitem.append(i + ": " + data);208 209 d = data.replace(/\\n/g, '<br />');210 d = d.replace(/_/g, ' ');211 var r = /\\u([\d\w]{4})/gi;212 d = d.replace(r, function (match, grp) {213 return String.fromCharCode(parseInt(grp, 16)); } );214 d = unescape(d);215 liitem.append(d);216 }217 this.info_list.append(liitem);218 }219};220String.prototype.endsWith = function(suffix) {221 return this.indexOf(suffix, this.length - suffix.length) !== -1;...

Full Screen

Full Screen

file-upload.js

Source:file-upload.js Github

copy

Full Screen

1KB.component('file-upload', function (containerElement, options) {2 var inputFileElement = null;3 var dropzoneElement = null;4 var files = [];5 var currentFileIndex = 0;6 function onProgress(e) {7 if (e.lengthComputable) {8 var progress = e.loaded / e.total;9 var percentage = Math.floor(progress * 100);10 KB.find('#file-progress-' + currentFileIndex).attr('value', progress);11 KB.find('#file-percentage-' + currentFileIndex).replaceText('(' + percentage + '%)');12 }13 }14 function onError() {15 var errorElement = KB.dom('div').addClass('file-error').text(options.labelUploadError).build();16 KB.find('#file-item-' + currentFileIndex).add(errorElement);17 }18 function onServerError(response) {19 var errorElement = KB.dom('div').addClass('file-error').text(response.message).build();20 KB.find('#file-item-' + currentFileIndex).add(errorElement);21 KB.trigger('modal.stop');22 }23 function onComplete() {24 currentFileIndex++;25 if (currentFileIndex < files.length) {26 KB.http.uploadFile(options.url, files[currentFileIndex], options.csrf, onProgress, onComplete, onError, onServerError);27 } else {28 KB.trigger('modal.stop');29 KB.trigger('modal.hide');30 var alertElement = KB.dom('div')31 .addClass('alert')32 .addClass('alert-success')33 .text(options.labelSuccess)34 .build();35 var buttonElement = KB.dom('button')36 .attr('type', 'button')37 .addClass('btn')38 .addClass('btn-blue')39 .click(onCloseWindow)40 .text(options.labelCloseSuccess)41 .build();42 KB.dom(dropzoneElement).replace(KB.dom('div').add(alertElement).add(buttonElement).build());43 }44 }45 function onCloseWindow() {46 window.location.reload();47 }48 function onSubmit() {49 currentFileIndex = 0;50 uploadFiles();51 }52 function onFileChange() {53 for (var i = 0; i < inputFileElement.files.length; i++) {54 files.push(inputFileElement.files[i]);55 }56 showFiles();57 }58 function onClickFileBrowser() {59 files = [];60 currentFileIndex = 0;61 inputFileElement.click();62 }63 function onDragOver(e) {64 e.stopPropagation();65 e.preventDefault();66 }67 function onDrop(e) {68 e.stopPropagation();69 e.preventDefault();70 for (var i = 0; i < e.dataTransfer.files.length; i++) {71 files.push(e.dataTransfer.files[i]);72 }73 showFiles();74 }75 function uploadFiles() {76 if (files.length > 0) {77 KB.http.uploadFile(options.url, files[currentFileIndex], options.csrf, onProgress, onComplete, onError, onServerError);78 }79 }80 function showFiles() {81 if (files.length > 0) {82 KB.trigger('modal.enable');83 KB.dom(dropzoneElement)84 .empty()85 .add(buildFileListElement());86 } else {87 KB.trigger('modal.disable');88 KB.dom(dropzoneElement)89 .empty()90 .add(buildInnerDropzoneElement());91 }92 }93 function buildFileInputElement() {94 return KB.dom('input')95 .attr('id', 'file-input-element')96 .attr('type', 'file')97 .attr('name', 'files[]')98 .attr('multiple', true)99 .on('change', onFileChange)100 .hide()101 .build();102 }103 function buildInnerDropzoneElement() {104 var dropzoneLinkElement = KB.dom('a')105 .attr('href', '#')106 .text(options.labelChooseFiles)107 .click(onClickFileBrowser)108 .build();109 return KB.dom('div')110 .attr('id', 'file-dropzone-inner')111 .text(options.labelDropzone + ' ' + options.labelOr + ' ')112 .add(dropzoneLinkElement)113 .build();114 }115 function buildDropzoneElement() {116 var dropzoneElement = KB.dom('div')117 .attr('id', 'file-dropzone')118 .add(buildInnerDropzoneElement())119 .build();120 dropzoneElement.ondragover = onDragOver;121 dropzoneElement.ondrop = onDrop;122 dropzoneElement.ondragover = onDragOver;123 return dropzoneElement;124 }125 function buildFileListItem(index) {126 var isOversize = false;127 var progressElement = KB.dom('progress')128 .attr('id', 'file-progress-' + index)129 .attr('value', 0)130 .build();131 var percentageElement = KB.dom('span')132 .attr('id', 'file-percentage-' + index)133 .text('(0%)')134 .build();135 var deleteElement = KB.dom('span')136 .attr('id', 'file-delete-' + index)137 .html('<a href="#"><i class="fa fa-trash fa-fw"></i></a>')138 .on('click', function () {139 files.splice(index, 1);140 KB.find('#file-item-' + index).remove();141 showFiles();142 })143 .build();144 var itemElement = KB.dom('li')145 .attr('id', 'file-item-' + index)146 .add(deleteElement)147 .add(progressElement)148 .text(' ' + files[index].name + ' ')149 .add(percentageElement);150 if (files[index].size > options.maxSize) {151 itemElement.add(KB.dom('div').addClass('file-error').text(options.labelOversize).build());152 isOversize = true;153 }154 if (isOversize) {155 KB.trigger('modal.disable');156 }157 return itemElement.build();158 }159 function buildFileListElement() {160 var fileListElement = KB.dom('ul')161 .attr('id', 'file-list')162 .build();163 for (var i = 0; i < files.length; i++) {164 fileListElement.appendChild(buildFileListItem(i));165 }166 return fileListElement;167 }168 this.render = function () {169 KB.on('modal.submit', onSubmit);170 KB.on('modal.close', function () {171 KB.removeListener('modal.submit', onSubmit);172 });173 inputFileElement = buildFileInputElement();174 dropzoneElement = buildDropzoneElement();175 containerElement.appendChild(inputFileElement);176 containerElement.appendChild(dropzoneElement);177 };...

Full Screen

Full Screen

modal.js

Source:modal.js Github

copy

Full Screen

1(function () {2 var isOpen = false;3 function onOverlayClick(e) {4 if (e.target.matches('#modal-overlay')) {5 e.stopPropagation();6 e.preventDefault();7 destroy();8 }9 }10 function onCloseButtonClick() {11 KB.trigger('modal.close');12 }13 function onFormSubmit() {14 KB.trigger('modal.loading');15 submitForm();16 }17 function getForm() {18 return document.querySelector('#modal-content form:not(.js-modal-ignore-form)');19 }20 function submitForm() {21 var form = getForm();22 if (form) {23 var url = form.getAttribute('action');24 if (url) {25 KB.http.postForm(url, form).success(function (response) {26 KB.trigger('modal.stop');27 if (response) {28 replace(response);29 } else {30 destroy();31 }32 }).error(function (response) {33 KB.trigger('modal.stop');34 if (response.hasOwnProperty('message')) {35 window.alert(response.message);36 }37 });38 }39 }40 }41 function afterRendering() {42 var formElement = KB.find('#modal-content form');43 if (formElement) {44 formElement.on('submit', onFormSubmit, false);45 }46 var autoFocusElement = document.querySelector('#modal-content input[autofocus]');47 if (autoFocusElement) {48 autoFocusElement.focus();49 }50 KB.render();51 _KB.datePicker();52 _KB.autoComplete();53 _KB.tagAutoComplete();54 _KB.get('Task').onPopoverOpened();55 KB.trigger('modal.afterRender');56 }57 function replace(html) {58 var contentElement = KB.find('#modal-content');59 if (contentElement) {60 contentElement.replace(KB.dom('div')61 .attr('id', 'modal-content')62 .html(html)63 .build()64 );65 afterRendering();66 }67 }68 function create(html, width, overlayClickDestroy) {69 var closeButtonElement = KB.dom('a')70 .attr('href', '#')71 .attr('id', 'modal-close-button')72 .html('<i class="fa fa-times"></i>')73 .click(onCloseButtonClick)74 .build();75 var headerElement = KB.dom('div')76 .attr('id', 'modal-header')77 .add(closeButtonElement)78 .build();79 var contentElement = KB.dom('div')80 .attr('id', 'modal-content')81 .html(html)82 .build();83 var boxElement = KB.dom('div')84 .attr('id', 'modal-box')85 .style('width', width)86 .add(headerElement)87 .add(contentElement)88 .build();89 var overlayElement = KB.dom('div')90 .attr('id', 'modal-overlay')91 .add(boxElement)92 .build();93 if (overlayClickDestroy) {94 overlayElement.addEventListener('click', onOverlayClick, false);95 }96 document.body.appendChild(overlayElement);97 afterRendering();98 }99 function destroy() {100 isOpen = false;101 var overlayElement = KB.find('#modal-overlay');102 if (overlayElement) {103 KB.trigger('modal.beforeDestroy');104 overlayElement.remove();105 }106 }107 function getWidth(size) {108 var viewport = KB.utils.getViewportSize();109 if (viewport.width < 700) {110 return '99%';111 }112 switch (size) {113 case 'large':114 return viewport.width < 1350 ? '98%' : '1350px';115 case 'medium':116 return viewport.width < 1024 ? '70%' : '1024px';117 }118 return viewport.width < 800 ? '75%' : '800px';119 }120 KB.on('modal.close', function () {121 destroy();122 });123 KB.on('modal.submit', function () {124 submitForm();125 });126 KB.modal = {127 open: function (url, size, overlayClickDestroy) {128 KB.trigger('modal.open');129 _KB.get('Dropdown').close();130 destroy();131 if (typeof overlayClickDestroy === 'undefined') {132 overlayClickDestroy = true;133 }134 KB.http.get(url).success(function (response) {135 isOpen = true;136 create(response, getWidth(size), overlayClickDestroy);137 });138 },139 close: function () {140 destroy();141 },142 isOpen: function () {143 return isOpen;144 },145 replace: function (url) {146 KB.http.get(url).success(function (response) {147 replace(response);148 });149 },150 getForm: getForm,151 submitForm: submitForm152 };...

Full Screen

Full Screen

keyboard-shortcuts.js

Source:keyboard-shortcuts.js Github

copy

Full Screen

1KB.keyboardShortcuts = function () {2 function goToLink (selector) {3 if (! KB.modal.isOpen()) {4 var element = KB.find(selector);5 if (element !== null) {6 window.location = element.attr('href');7 }8 }9 }10 function submitForm() {11 if (KB.modal.isOpen()) {12 KB.modal.submitForm();13 } else {14 var forms = $("form");15 if (forms.length == 1) {16 forms.submit();17 } else if (forms.length > 1) {18 if (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA') {19 $(document.activeElement).parents("form").submit();20 }21 }22 }23 }24 KB.onKey('?', function () {25 if (! KB.modal.isOpen()) {26 KB.modal.open(KB.find('body').data('keyboardShortcutUrl'));27 }28 });29 KB.onKey('Escape', function () {30 if (! KB.exists('#suggest-menu')) {31 KB.trigger('modal.close');32 _KB.get("Dropdown").close();33 }34 }, true);35 KB.onKey('Enter', submitForm, true, true);36 KB.onKey('Enter', submitForm, true, false, true);37 KB.onKey('b', function () {38 if (! KB.modal.isOpen()) {39 KB.trigger('board.selector.open');40 }41 });42 if (KB.exists('#board')) {43 KB.onKey('c', function () {44 if (! KB.modal.isOpen()) {45 _KB.get('BoardHorizontalScrolling').toggle();46 }47 });48 KB.onKey('s', function () {49 if (! KB.modal.isOpen()) {50 _KB.get('BoardCollapsedMode').toggle();51 }52 });53 KB.onKey('n', function () {54 if (! KB.modal.isOpen()) {55 KB.modal.open(KB.find('#board').data('taskCreationUrl'), 'large', false);56 }57 });58 }59 if (KB.exists('#task-view')) {60 KB.onKey('e', function () {61 if (! KB.modal.isOpen()) {62 KB.modal.open(KB.find('#task-view').data('editUrl'), 'large', false);63 }64 });65 KB.onKey('c', function () {66 if (! KB.modal.isOpen()) {67 KB.modal.open(KB.find('#task-view').data('commentUrl'), 'medium', false);68 }69 });70 KB.onKey('s', function () {71 if (! KB.modal.isOpen()) {72 KB.modal.open(KB.find('#task-view').data('subtaskUrl'), 'medium', false);73 }74 });75 KB.onKey('l', function () {76 if (! KB.modal.isOpen()) {77 KB.modal.open(KB.find('#task-view').data('internalLinkUrl'), 'medium', false);78 }79 });80 }81 KB.onKey('f', function () {82 if (! KB.modal.isOpen()) {83 KB.focus('#form-search');84 }85 });86 KB.onKey('r', function () {87 if (! KB.modal.isOpen()) {88 var reset = $(".filter-reset").data("filter");89 var input = $("#form-search");90 input.val(reset);91 $("form.search").submit();92 }93 });94 KB.onKey('v+o', function () {95 goToLink('a.view-overview');96 });97 KB.onKey('v+b', function () {98 goToLink('a.view-board');99 });100 KB.onKey('v+l', function () {101 goToLink('a.view-listing');102 });...

Full Screen

Full Screen

test_formatFileSize.js

Source:test_formatFileSize.js Github

copy

Full Screen

1/* This Source Code Form is subject to the terms of the Mozilla Public2 * License, v. 2.0. If a copy of the MPL was not distributed with this3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */4/*5 * Tests for the formatFileSize method.6 */7load("../../../../mailnews/resources/logHelper.js");8load("../../../../mailnews/resources/asyncTestUtils.js");9var gStringBundle = Services.strings.createBundle(10 "chrome://messenger/locale/messenger.properties");11var gMessenger = Cc["@mozilla.org/messenger;1"]12 .createInstance(Ci.nsIMessenger);13function isDigit(c) {14 return "0123456789".indexOf(c) != -1;15}16function test_formatFileSize(aArgs) {17 const strings = { b: "byteAbbreviation2",18 kb: "kiloByteAbbreviation2",19 mb: "megaByteAbbreviation2",20 gb: "gigaByteAbbreviation2" };21 let actual = gMessenger.formatFileSize(aArgs.bytes, aArgs.useKB);22 let expected = gStringBundle.GetStringFromName(strings[aArgs.units])23 .replace("%.*f", aArgs.mantissa);24 // If the actual string contains a non-numeric character at the position25 // where we'd expect a decimal separator, assume it is a localized separator26 // and just convert it to a dot for easy comparing.27 let separatorPos = aArgs.mantissa.indexOf(".");28 if (!isDigit(actual.charAt(separatorPos)))29 actual = actual.substring(0, separatorPos) + "." + actual.substr(separatorPos + 1);30 do_check_eq(actual, expected);31}32/* ===== Driver ===== */33var test_data = [34 { bytes: 0, useKB: false, mantissa: "0", units: "b" },35 { bytes: 1, useKB: false, mantissa: "1", units: "b" },36 { bytes: 10, useKB: false, mantissa: "10", units: "b" },37 { bytes: 999, useKB: false, mantissa: "999", units: "b" },38 { bytes: 1000, useKB: false, mantissa: "1.0", units: "kb" },39 { bytes: 1024, useKB: false, mantissa: "1.0", units: "kb" },40 { bytes: 10*1024, useKB: false, mantissa: "10.0", units: "kb" },41 { bytes: 999*1024, useKB: false, mantissa: "999", units: "kb" },42 { bytes: 1000*1024, useKB: false, mantissa: "1.0", units: "mb" },43 { bytes: 1024*1024, useKB: false, mantissa: "1.0", units: "mb" },44 { bytes: 10*1024*1024, useKB: false, mantissa: "10.0", units: "mb" },45 { bytes: 999*1024*1024, useKB: false, mantissa: "999", units: "mb" },46 { bytes: 1000*1024*1024, useKB: false, mantissa: "1.0", units: "gb" },47 { bytes: 1024*1024*1024, useKB: false, mantissa: "1.0", units: "gb" },48 { bytes: 10*1024*1024*1024, useKB: false, mantissa: "10.0", units: "gb" },49 { bytes: 999*1024*1024*1024, useKB: false, mantissa: "999", units: "gb" },50 { bytes: 1000*1024*1024*1024, useKB: false, mantissa: "1000", units: "gb" },51 { bytes: 0, useKB: true, mantissa: "0", units: "kb" },52 { bytes: 1, useKB: true, mantissa: "0.1", units: "kb" },53 { bytes: 500, useKB: true, mantissa: "0.5", units: "kb" },54 { bytes: 999, useKB: true, mantissa: "1.0", units: "kb" },55];56var tests = [57 parameterizeTest(test_formatFileSize, test_data)58];59function run_test() {60 async_run_tests(tests);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.keyboard.press('ArrowUp');7 await page.keyboard.press('ArrowDown');8 await page.keyboard.press('ArrowLeft');9 await page.keyboard.press('ArrowRight');10 await page.keyboard.press('Enter');11 await page.keyboard.press('Tab');12 await page.keyboard.press('Backspace');13 await page.keyboard.press('Delete');14 await page.keyboard.press('Escape');15 await page.keyboard.press('PageUp');16 await page.keyboard.press('PageDown');17 await page.keyboard.press('Home');18 await page.keyboard.press('End');19 await page.keyboard.press('Insert');20 await page.keyboard.press('F1');21 await page.keyboard.press('F2');22 await page.keyboard.press('F3');23 await page.keyboard.press('F4');24 await page.keyboard.press('F5');25 await page.keyboard.press('F6');26 await page.keyboard.press('F7');27 await page.keyboard.press('F8');28 await page.keyboard.press('F9');29 await page.keyboard.press('F10');30 await page.keyboard.press('F11');31 await page.keyboard.press('F12');32 await page.keyboard.press('Meta');33 await page.keyboard.press('Control');34 await page.keyboard.press('Alt');35 await page.keyboard.press('Shift');36 await page.keyboard.press(' ');37 await page.keyboard.press('!');38 await page.keyboard.press('"');39 await page.keyboard.press('#');40 await page.keyboard.press('$');41 await page.keyboard.press('%');42 await page.keyboard.press('&');43 await page.keyboard.press('\'');44 await page.keyboard.press('(');45 await page.keyboard.press(')');46 await page.keyboard.press('*');47 await page.keyboard.press('+');48 await page.keyboard.press(',');49 await page.keyboard.press('-');50 await page.keyboard.press('.');51 await page.keyboard.press('/');52 await page.keyboard.press('0');53 await page.keyboard.press('1');54 await page.keyboard.press('2');55 await page.keyboard.press('3');56 await page.keyboard.press('4');57 await page.keyboard.press('5');58 await page.keyboard.press('6');59 await page.keyboard.press('7');60 await page.keyboard.press('8');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.keyboard.press('KeyK');7 await page.screenshot({ path: 'example.png' });8 await browser.close();9})();10const { chromium } = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const context = await browser.newContext();14 const page = await context.newPage();15 await page.keyboard.press('KeyK');16 await page.screenshot({ path: 'example.png' });17 await browser.close();18})();19const { chromium } = require('playwright');20(async () => {21 const browser = await chromium.launch();22 const context = await browser.newContext();23 const page = await context.newPage();24 await page.keyboard.press('KeyK');25 await page.screenshot({ path: 'example.png' });26 await browser.close();27})();28const { chromium } = require('playwright');29(async () => {30 const browser = await chromium.launch();31 const context = await browser.newContext();32 const page = await context.newPage();33 await page.keyboard.press('KeyK');34 await page.screenshot({ path: 'example.png' });35 await browser.close();36})();37const { chromium } = require('playwright');38(async () => {39 const browser = await chromium.launch();40 const context = await browser.newContext();41 const page = await context.newPage();42 await page.keyboard.press('KeyK');43 await page.screenshot({ path: 'example.png' });44 await browser.close();45})();46const { chromium } = require('playwright');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.keyboard.press('ArrowLeft');7 await browser.close();8})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const {chromium} = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.keyboard.press('a');7 await page.keyboard.press('b');8 await page.keyboard.press('c');9 await page.keyboard.press('Enter');10 await browser.close();11})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const {chromium} = require('playwright');2(async () => {3 const browser = await chromium.launch({headless: false});4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.keyboard.press('a');7 await page.keyboard.press('b');8 await page.keyboard.press('c');9 await page.keyboard.press('d');10 await page.keyboard.press('e');11 await page.keyboard.press('f');12 await page.keyboard.press('g');13 await page.keyboard.press('h');14 await page.keyboard.press('i');15 await page.keyboard.press('j');16 await page.keyboard.press('k');17 await page.keyboard.press('l');18 await page.keyboard.press('m');19 await page.keyboard.press('n');20 await page.keyboard.press('o');21 await page.keyboard.press('p');22 await page.keyboard.press('q');23 await page.keyboard.press('r');24 await page.keyboard.press('s');25 await page.keyboard.press('t');26 await page.keyboard.press('u');27 await page.keyboard.press('v');28 await page.keyboard.press('w');29 await page.keyboard.press('x');30 await page.keyboard.press('y');31 await page.keyboard.press('z');

Full Screen

Using AI Code Generation

copy

Full Screen

1const {chromium, devices} = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext({5 geolocation: {longitude: 12.492507, latitude: 41.889938},6 });7 const page = await context.newPage();8 await page.waitForSelector('text="Your location"');9 const element = await page.$('text="Your location"');10 await element.scrollIntoViewIfNeeded();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Playwright } = require('playwright-core');2module.exports = async function() {3 const playwright = new Playwright();4 const browser = await playwright.chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.keyboard.press('Tab');8 await page.keyboard.press('Enter');9 await browser.close();10}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.keyboard.press('Control+T');7 await page.keyboard.press('Control+L');8 await page.keyboard.press('Enter');9 await page.waitForTimeout(2000);10 await browser.close();11})();12page.keyboard.press()13page.keyboard.type()14browser.close()15browser.newContext()16page.goto()17page.waitForTimeout()18require()

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal 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