How to use arrange method in stryker-parent

Best JavaScript code snippet using stryker-parent

arrange-module.js

Source:arrange-module.js Github

copy

Full Screen

1var arrangeModule = slidesApp.module('ArrangeModule', function (ArrangeModule, slidesApp, Backbone, Marionette, $, _) {2 ArrangeModule.startWithParent = false;3 ArrangeModule.subAction = 'default';4 ArrangeModule.sortableEnabled = true;5 ArrangeModule.dragStarted = false;6 ArrangeModule.isChanged = false;7 ArrangeModule.slideOrder =[];8 var getSlideId = function($el){9 return parseInt($el.attr('id').slice($el.attr('id').indexOf('_') + 1));10 };11 ArrangeModule.View = Marionette.ItemView.extend({12 template: '#arrangeTemplate',13 id: 'arrangeSlides'14 });15 var arrangeView = new ArrangeModule.View();16 ArrangeModule.tileListView = Marionette.ItemView.extend({17 tagName: 'td',18 template: '#arrangeListTemplate',19 className: 'tileListTemp js-sortable-slide-list'20 });21 ArrangeModule.tileView = Marionette.ItemView.extend({22 template: '#arrangeTileTemplate',23 className: 'slides-arrange-tile js-slides-arrange-tile text-center',24 events: {25 'mouseover': 'onMouseOver',26 'mouseout': 'onMouseOut',27 'click .js-arrange-tile-cover': 'onClick',28 'click .js-arrange-tile-preview': 'goToSlide',29 'click .js-arrange-tile-edit': 'editSlide',30 'click .js-arrange-tile-delete': 'deleteSlide',31 'click .js-arrange-tile-select': 'selectSlide'32 },33 onRender: function(){34 this.$('.valamis-tooltip')35 .tooltip({36 placement: 'right',37 trigger: 'manual'38 })39 .bind('mouseenter', function(){40 $(this).tooltip('show');41 var tooltip = $(this).data('bs.tooltip').$tip;42 tooltip43 .css({44 whiteSpace: 'nowrap',45 left: '+=20'46 });47 })48 .bind('mouseleave', function(){49 $(this).tooltip('hide');50 })51 .parent().css('position','relative');52 },53 onMouseOver: function (e) {54 if( _.indexOf(['select','select-incorrect'], arrangeModule.subAction) > -1 ) {55 this.$('.js-arrange-tile-controls > div').addClass('hidden');56 this.$('.js-arrange-tile-controls').find('.js-arrange-tile-select').parent().removeClass('hidden');57 this.$('.js-arrange-tile-controls').show();58 $('#arrangeContainer .js-slides-arrange-tile').removeClass('arrange-tile-active');59 this.$el.addClass('arrange-tile-active');60 }61 else{62 this.$('.js-arrange-tile-controls').show();63 }64 },65 onMouseOut: function (e) {66 this.$('.js-arrange-tile-controls').hide();67 },68 onClick: function (e) {69 if( !ArrangeModule.dragStarted ){70 if( $(e.target).is('.arrange-tile-cover') && _.indexOf(['select','select-incorrect'], arrangeModule.subAction) > -1 ){71 this.selectSlide();72 } else {73 this.goToSlide();74 }75 }76 },77 goToSlide: function (e) {78 if(e) e.preventDefault();79 var slideId = getSlideId(this.$el);80 slidesApp.switchMode('preview', false, slideId);81 },82 editSlide: function (e) {83 if(e) e.preventDefault();84 var slideId = getSlideId(this.$el);85 slidesApp.switchMode('edit', false, slideId);86 },87 deleteSlide: function (e) {88 if(e) e.preventDefault();89 var slides = slidesApp.slideCollection.where({toBeRemoved: false});90 if(slides.length > 1) {91 var slideId = getSlideId(this.$el);92 var slideModel = slidesApp.getSlideModel(slideId);93 slideModel.set('toBeRemoved', true);94 }95 },96 selectSlide: function(e){97 if(e) e.preventDefault();98 var slideId = getSlideId(this.$el),99 selectedEntityId = slidesApp.selectedItemView.model.id || slidesApp.selectedItemView.model.get('tempId'),100 linkTypeName = window.editorMode == 'arrange:select' ? 'correctLinkedSlideId' : 'incorrectLinkedSlideId';101 slidesApp.getSlideElementModel(selectedEntityId).set(linkTypeName, slideId);102 slidesApp.newValue = { linkType: linkTypeName, linkedSlideId: slideId };103 slidesApp.execute('action:push');104 slidesApp.switchMode('edit');105 }106 });107 ArrangeModule.slideThumbnailView = Marionette.ItemView.extend({108 template: '#slideThumbnailTemplate',109 className: 'slides-thumbnail js-slides-thumbnail'110 });111 ArrangeModule.initSortable = function(elem) {112 if( !ArrangeModule.sortableEnabled ){113 return;114 }115 elem.sortable({116 placeholder: 'slides-arrange-placeholder',117 revert: true,118 delay: 50,119 sort: function(e, ui) {120 var placeholderBackground = $('<div></div>').css({121 'width': '196px',122 'height': '146px'123 });124 $(ui.placeholder).html('');125 $(ui.placeholder).append(placeholderBackground);126 $(ui.placeholder).addClass('slides-arrange-placeholder');127 },128 start: function(e, ui) {129 ArrangeModule.slideSourceList = $(e.currentTarget);130 ArrangeModule.dragStarted = true;131 },132 stop: function(e, ui) {133 $(ui.placeholder).html('');134 $(ui.placeholder).removeClass('slides-arrange-placeholder');135 ArrangeModule.dragStarted = false;136 },137 update: function(e, ui) {138 if(ui.sender === null) {139 ArrangeModule.updateSlideRefs();140 ArrangeModule.initDraggable();141 slidesApp.slideSetModel.set('slideOrder', ArrangeModule.slideOrder);142 }143 ArrangeModule.isChanged = true;144 }145 }).disableSelection();146 var connectWithClass = (slidesApp.slideSetModel.get('topDownNavigation'))147 ? '.js-sortable-slide-list'148 : '.js-sortable-slide-list.empty-arrange-list';149 elem.sortable('option', 'connectWith', connectWithClass);150 };151 ArrangeModule.manageSortableLists = function() {152 if(ArrangeModule.slideSourceList && ArrangeModule.slideSourceList.children().length === 0) {153 if(ArrangeModule.slideSourceList.prev().children().length === 0)154 ArrangeModule.slideSourceList.prev().remove();155 ArrangeModule.slideSourceList.remove();156 }157 // If the target list was empty before current item appeared in it158 if(ArrangeModule.slideTargetList.children().length === 1) {159 ArrangeModule.slideTargetList.removeClass('empty-arrange-list');160 var $prevElements = ArrangeModule.slideTargetList.prev();161 if ($prevElements.length === 0 || $prevElements.children().length > 0) {162 var arrangeList = new ArrangeModule.tileListView().render().$el;163 arrangeList.addClass('empty-arrange-list');164 arrangeList.insertBefore(ArrangeModule.slideTargetList);165 ArrangeModule.initSortable(arrangeList);166 }167 var $nextElements = ArrangeModule.slideTargetList.next();168 if ($nextElements.length === 0 || $nextElements.children().length > 0) {169 var arrangeList = new ArrangeModule.tileListView().render().$el;170 arrangeList.addClass('empty-arrange-list');171 arrangeList.insertAfter(ArrangeModule.slideTargetList);172 ArrangeModule.initSortable(arrangeList);173 }174 }175 };176 ArrangeModule.createSortableLists = function() {177 // Create a sortable list for each stack of slides178 $('.slides > section').each(function() {179 var arrangeList = new ArrangeModule.tileListView().render().$el;180 $('#arrangeSlides tr:first').append(arrangeList);181 $(this).find('> section').each(function() {182 if(!$(this).attr('id')) return;183 ArrangeModule.renderSlide(parseInt($(this).attr('id').slice(6)), arrangeList)184 });185 ArrangeModule.initSortable(arrangeList);186 // Create an empty sortable list after each list187 ArrangeModule.createEmptyList(arrangeList);188 });189 ArrangeModule.createFirstEmptyList();190 if($('.js-slides-arrange-tile').length == 1)191 $('.js-arrange-tile-delete').hide();192 slidesApp.vent.trigger('arrange-module-ready');193 };194 ArrangeModule.renderSortableLists = function (slideOrder) {195 var $firstTr = $('#arrangeSlides tr:first');196 $firstTr.empty();197 _.each(slideOrder, function (ids) {198 var arrangeList = new ArrangeModule.tileListView().render().$el;199 $firstTr.append(arrangeList);200 _.each(ids, function (id) {201 ArrangeModule.renderSlide(id, arrangeList)202 });203 ArrangeModule.initSortable(arrangeList);204 ArrangeModule.createEmptyList(arrangeList);205 });206 ArrangeModule.createFirstEmptyList();207 if ($('.js-slides-arrange-tile').length == 1)208 $('.js-arrange-tile-delete').hide();209 slidesApp.vent.trigger('arrange-module-ready');210 };211 ArrangeModule.renderSlide = function(slideId, arrangeList){212 var arrangeTile = new ArrangeModule.tileView({ id: 'slidesArrangeTile_' + slideId }).render().$el;213 arrangeList.append(arrangeTile);214 // Create a thumbnail for the slide215 var slideThumbnail = new ArrangeModule.slideThumbnailView().render().$el;216 ArrangeModule.changeFont(slideId, slideThumbnail);217 slideThumbnail.find('section').show().removeAttr('aria-hidden');//show if hidden218 ArrangeModule.changeBackgroundColor(slideId, slideThumbnail);219 ArrangeModule.changeBackgroundImage(slideId, slideThumbnail);220 slideThumbnail.insertBefore(arrangeTile.find('.js-arrange-tile-controls'));221 };222 ArrangeModule.createEmptyList = function(arrangeList) {223 arrangeList = new ArrangeModule.tileListView().render().$el;224 arrangeList.addClass('empty-arrange-list');225 $('#arrangeSlides tr:first').append(arrangeList);226 ArrangeModule.initSortable(arrangeList);227 };228 ArrangeModule.createFirstEmptyList = function() {229 var firstList = new ArrangeModule.tileListView().render().$el;230 firstList.addClass('empty-arrange-list');231 firstList.insertBefore($('.js-sortable-slide-list').first());232 ArrangeModule.initSortable(firstList);233 };234 ArrangeModule.changeBackgroundColor = function (slideId, slideThumbnail) {235 var thumbnail = slideThumbnail || $('#arrangeContainer #slidesArrangeTile_' + slideId + ' .slides-thumbnail');236 var slide = $('#slide_' + slideId);237 var bgColor = slide.attr('data-background-color');238 thumbnail.css({239 'background-color': bgColor240 });241 };242 ArrangeModule.changeBackgroundImage = function (slideId, slideThumbnail) {243 var thumbnail = slideThumbnail || $('#arrangeContainer #slidesArrangeTile_' + slideId + ' .slides-thumbnail');244 var slide = $('#slide_' + slideId);245 var bgImage = slide.attr('data-background-image');246 var bgSize = slide.attr('data-background-size');247 thumbnail.css({248 'background-image': (bgImage) ? 'url("' + bgImage + '")' : '',249 'background-size': (bgImage) ? bgSize : '',250 'background-repeat': (bgImage) ? 'no-repeat' : '',251 'background-position': (bgImage) ? 'center' : ''252 });253 };254 ArrangeModule.changeFont = function (slideId, slideThumbnail) {255 var thumbnail = slideThumbnail || $('#arrangeContainer #slidesArrangeTile_' + slideId + ' .slides-thumbnail');256 var slide = $('#slide_' + slideId);257 thumbnail.find('section').remove();258 slide.clone().attr('id', 'slideThumbnail_' + slideId).appendTo(thumbnail);259 };260 ArrangeModule.updateSlideRefs = function() {261 var lists = $('.js-sortable-slide-list:has(>div)'), i = 0, j = 0;262 ArrangeModule.slideOrder = [];263 lists.each(function() {264 j = 0;265 var list = $(this);266 var listOrder = [];267 list.find('.js-slides-arrange-tile').each(function() {268 var listElement = $(this),269 listElementId = parseInt(listElement.attr('id').slice(listElement.attr('id').indexOf('_') + 1)),270 slideModel = slidesApp.getSlideModel(listElementId),271 topListElement = listElement.prev(),272 leftListElement = listElement.parent().prevAll('.js-sortable-slide-list:has(>div)').first().children().first(),273 topListElementId = topListElement.length > 0274 ? getSlideId(topListElement)275 : undefined,276 leftListElementId = leftListElement.length > 0277 ? getSlideId(leftListElement)278 : undefined;279 listOrder.push(listElementId);280 if(slideModel){281 //Only top row slides can have left one and we set them later282 slideModel.unset('leftSlideId', { silent: true });283 slideModel.unset('topSlideId', { silent: true });284 if(topListElementId)285 slideModel.set('topSlideId', topListElementId, {silent: true});286 if(j === 0) {287 // If it is a slide from the top row (where slides CAN refer to the left)288 if(leftListElementId) {289 slideModel.set('leftSlideId', leftListElementId, {silent: true});290 }291 }292 }293 j++;294 });295 i++;296 ArrangeModule.slideOrder.push(listOrder)297 });298 if($('.js-slides-arrange-tile').length == 1)299 $('.js-arrange-tile-delete').hide();300 else301 $('.js-arrange-tile-delete').show();302 };303 ArrangeModule.initDraggable = function() {304 var $arrangeContainer = $('#arrangeContainer');305 var $arrangeSlides= $('#arrangeSlides');306 var $arrangeSlideTable = $arrangeSlides.find('table');307 $arrangeContainer.find('table').css('width', 'auto');308 var sortableListContainerWidth = $arrangeContainer.width(),309 sortableListContainerHeight = $arrangeContainer.height();310 var sortableListTableWidth = Math.max($arrangeSlideTable.width(), $arrangeContainer.width()),311 sortableListTableHeight = $arrangeSlideTable.height();312 var containmentStartX = 0 - Math.abs(sortableListContainerWidth - sortableListTableWidth),313 containmentStartY = 0 - Math.abs(sortableListContainerHeight - sortableListTableHeight),314 containmentEndX = 0,315 containmentEndY = 0,316 scrollTop = $( document ).scrollTop();317 if(sortableListTableWidth < sortableListContainerWidth) {318 containmentStartX = Math.abs(sortableListContainerWidth - sortableListTableWidth) / 2;319 containmentEndX = containmentStartX;320 }321 if(sortableListTableHeight < sortableListContainerHeight) {322 containmentStartY = containmentEndY = 0;323 }324 containmentEndY += $('.js-slides-editor-topbar').outerHeight();325 containmentStartY += scrollTop + lessonStudio.fixedSizes.TOPBAR_HEIGHT;326 containmentEndY += scrollTop;327 if(sortableListTableWidth > sortableListContainerWidth || sortableListTableHeight > sortableListContainerHeight) {328 if(!$arrangeSlides.data('uiDraggable')){329 $arrangeSlides.draggable();330 }331 $arrangeSlides332 .draggable("option", "containment", [ containmentStartX, containmentStartY, containmentEndX, containmentEndY ]);333 }334 };335 ArrangeModule.onSlidesUpdated = function(){336 _.defer(function(){337 $('#arrangeSlides tr:first').empty();338 ArrangeModule.createSortableLists();339 });340 };341 ArrangeModule.onSlidesOrderUpdated = function() {342 if (slidesApp.slideSetModel.get('slideOrder')) {343 ArrangeModule.renderSortableLists(slidesApp.slideSetModel.get('slideOrder'));344 } else {345 $('#arrangeSlides tr:first').empty();346 ArrangeModule.createSortableLists();347 }348 };349 ArrangeModule.onSlideRemove = function(model, toBeRemoved){350 if( toBeRemoved ) {351 var listElement = jQueryValamis('#slidesArrangeTile_' + model.getId());352 if (listElement.siblings().length === 0) {353 listElement.parent().prev().remove();354 listElement.parent().remove();355 }356 listElement.remove();357 } else {358 //When undo action complete359 slidesApp.historyManager360 .once('undo:after', arrangeModule.onSlidesUpdated, arrangeModule);361 }362 };363 ArrangeModule.onStart = function(){364 var arrangeModule = this;365 setTimeout(function() {366 valamisApp.execute('notify', 'info', Valamis.language['lessonModeSwitchingLabel'], { 'timeOut': '0', 'extendedTimeOut': '0' });367 }, 0);368 setTimeout(function() {369 $arrangeContainer = $('#arrangeContainer');370 slidesApp.vent.on('arrange-module-ready', function(){371 setTimeout(function () {372 $arrangeContainer.show();373 $arrangeContainer.prevAll().hide();374 valamisApp.execute('notify', 'clear');375 arrangeModule.initDraggable();376 }, 0);377 });378 $arrangeContainer.append(arrangeView.render().el);379 var $parent = $(window.parent);380 $arrangeContainer.height($parent.height() - $('.js-slides-editor-topbar').outerHeight());381 $arrangeContainer.width($parent.width());382 //TODO remove it383 //$('body').css('background-color', '#f2f2f2');384 arrangeModule.subAction = window.editorMode && window.editorMode.indexOf(':') > -1385 ? _.last(window.editorMode.split(':'))386 : 'default';387 arrangeModule.sortableEnabled = _.indexOf(['select', 'select-incorrect'], arrangeModule.subAction) == -1;388 arrangeModule.createSortableLists();389 }, 500);390 slidesApp.slideSetModel391 .on('change:slideOrder', arrangeModule.onSlidesOrderUpdated, arrangeModule);392 slidesApp.slideCollection393 .on('change:toBeRemoved', arrangeModule.onSlideRemove, arrangeModule);394 arrangeModule.isChanged = false;395 };396 ArrangeModule.onStop = function(){397 var arrangeModule = this;398 slidesApp.vent.off('arrange-module-ready');399 arrangeModule.updateSlideRefs();400 window.editorMode = null;401 arrangeModule.isChanged = false;402 $('#arrangeContainer').hide();403 slidesApp.slideSetModel404 .off('change:slideOrder', arrangeModule.onSlidesOrderUpdated);405 slidesApp.slideCollection406 .off('change:toBeRemoved', arrangeModule.onSlideRemove);407 if(slidesApp.historyManager){408 slidesApp.historyManager.off('undo:after', arrangeModule.onSlidesUpdated);409 }410 }...

Full Screen

Full Screen

arrange_fields_dialog.js

Source:arrange_fields_dialog.js Github

copy

Full Screen

1// This script is always meant to be loaded in conjunction with arrange_fields.js.2// It contains the functions dealing with jquery dialogs, which, because of their3// size, makes more sense to have in its own script file.4// This script will be making use of global variables defined in arrange_fields.js.5// Make sure it is loaded *after* arrange_fields.js.6 Drupal.behaviors.arrangeFieldsDialogStartup = {7 attach: function (context, settings) {8 9 //Set up the config dialog....10 jQuery("#arrange-fields-config-dialog").dialog({11 autoOpen: false,12 height: 300,13 width: 300,14 buttons: {15 "Apply" : function() {16 arrangeFieldsApplyDialogConfigChanges();17 },18 "Cancel" : function() { jQuery(this).dialog("close"); }19 } 20 });21 22 //Set up the markup dialog....23 jQuery("#arrange-fields-markup-dialog").dialog({24 autoOpen: false,25 height: 400,26 width: 400,27 buttons: {28 "Apply" : function() {29 arrangeFieldsApplyDialogMarkupChanges();30 },31 "Cancel" : function() { jQuery(this).dialog("close"); } 32 } 33 });34 35 } 36 };37 38 39 /**40 * We are opening the config dialog. Let's reset the values41 *42 **/ 43 function arrangeFieldsDialogConfigureField(field, fieldType) {44 var dia = jQuery("#arrange-fields-config-dialog");45 dia.dialog("option", "title", "Configure " + field);46 47 arrangeFieldsDialogConfigField = field;48 var fieldId = "edit-" + field + "-draggable-wrapper";49 // if this is a fieldset, the fieldId is slightly different.50 if (fieldType == "fieldset") {51 fieldId = "edit-" + field + "-fieldset-draggable-wrapper";52 }53 arrangeFieldsDialogConfigFieldId = fieldId;54 arrangeFieldsDialogConfigFieldType = fieldType;55 56 // Is this field in the dialog config obj yet?57 if (arrangeFieldsDialogConfigObj[fieldId] == null) {58 arrangeFieldsDialogConfigObj[fieldId] = new Object();59 }60 61 // Make sure the properties have initial, non-null values.62 if (arrangeFieldsDialogConfigObj[fieldId]["wrapperHeight"] == null) {63 arrangeFieldsDialogConfigObj[fieldId]["wrapperHeight"] = "";64 }65 if (arrangeFieldsDialogConfigObj[fieldId]["wrapperWidth"] == null) {66 arrangeFieldsDialogConfigObj[fieldId]["wrapperWidth"] = "";67 }68 if (arrangeFieldsDialogConfigObj[fieldId]["labelDisplay"] == null) {69 arrangeFieldsDialogConfigObj[fieldId]["labelDisplay"] = "";70 }71 if (arrangeFieldsDialogConfigObj[fieldId]["labelVerticalAlign"] == null) {72 arrangeFieldsDialogConfigObj[fieldId]["labelVerticalAlign"] = "";73 }74 75 76 // Let's reset the inputs in the dialog to use whatever is in the77 // config obj.78 dia.find("input[name=af-dialog-width]").val(arrangeFieldsDialogConfigObj[fieldId]["wrapperWidth"]);79 dia.find("input[name=af-dialog-height]").val(arrangeFieldsDialogConfigObj[fieldId]["wrapperHeight"]);80 dia.find("input[name=af-dialog-label-display]").each(function() {81 if (jQuery(this).val() == arrangeFieldsDialogConfigObj[fieldId]["labelDisplay"]82 || jQuery(this).val() == arrangeFieldsDialogConfigObj[fieldId]["labelDisplay"] + "-block") {83 jQuery(this).attr("checked", "checked");84 }85 });86 87 88 // Should we hide the label config controls (based on what field type this is)?89 if (fieldType == "vertical_tabs" || fieldType == "fieldset") {90 jQuery("#arrange-fields-config-dialog-labels").hide();91 }92 else {93 jQuery("#arrange-fields-config-dialog-labels").show();94 }95 96 97 dia.dialog('open');98 }99 100 101 102 /**103 * Apply the changes the user has entered into the config dialog.104 **/105 function arrangeFieldsApplyDialogConfigChanges() {106 var dia = jQuery("#arrange-fields-config-dialog");107 108 var wrapperWidth = dia.find("input[name=af-dialog-width]").val();109 var wrapperHeight = dia.find("input[name=af-dialog-height]").val();110 var labelDisplay = dia.find("input[name=af-dialog-label-display]:checked").val();111 112 // Remove trouble characters, if they exist.113 wrapperWidth = wrapperWidth.replace(";", "");114 wrapperHeight = wrapperHeight.replace(";", "");115 116 // Save these values to the config obj117 var field = arrangeFieldsDialogConfigField;118 var fieldId = arrangeFieldsDialogConfigFieldId;119 var fieldType = arrangeFieldsDialogConfigFieldType;120 121 arrangeFieldsDialogConfigObj[fieldId]["wrapperWidth"] = wrapperWidth;122 arrangeFieldsDialogConfigObj[fieldId]["wrapperHeight"] = wrapperHeight;123 if (wrapperWidth == "") { wrapperWidth = "auto"; }124 if (wrapperHeight == "") { wrapperHeight = "auto"; }125 126 if (fieldType != "vertical_tabs" && fieldType != "fieldset") {127 arrangeFieldsDialogConfigObj[fieldId]["labelDisplay"] = labelDisplay;128 if (labelDisplay == "") { labelDisplay = "block"; } 129 }130 131 // Let's actually affect these changes on the page.132 jQuery("#" + fieldId).css("width", wrapperWidth);133 jQuery("#" + fieldId).css("height", wrapperHeight);134 135 136 var valign = "top";137 // Because of the way IE handles inline-block displays with radio buttons,138 // we have to change inline-block to simply inline for radios and checkboxes.139 // Isn't IE great?140 var radioDisplay = labelDisplay;141 if (labelDisplay == "inline-block") { 142 radioDisplay = "inline"; 143 }144 if (radioDisplay == "block") {145 // Unset the style for radio buttons/checkboxes, so it goes back to default146 radioDisplay = "";147 }148 149 var boolRadio = false;150 151 // Grab all the sibling elements under the wrapper and make them152 // have this display property.153 jQuery("#" + fieldId + " .form-item").children(":not(.description)").each(function() {154 155 // If these are radios/checkboxes, then also apply this style to the div's there.156 jQuery("#" + fieldId + " .form-item .form-radios, #" + fieldId + " .form-item .form-checkboxes").children().each(function () {157 jQuery(this).css("display", radioDisplay);158 valign = "middle";159 boolRadio = true;160 });161 162 if (!boolRadio) {163 jQuery(this).css("display", labelDisplay);164 }165 else { // we are dealing with radio buttons or checkboxes.166 jQuery(this).css("display", radioDisplay);167 arrangeFieldsDialogConfigObj[fieldId]["labelDisplay"] = radioDisplay;168 }169 170 });171 172 // Make the label look right... 173 jQuery("#" + fieldId + " .form-item label").css("vertical-align", valign);174 175 176 arrangeFieldsDialogConfigObj[fieldId]["labelVerticalAlign"] = valign;177 178 dia.dialog('close');179 }180 181 182 /**183 * This function opens the dialog to let us edit a particular markup element.184 **/185 function arrangeFieldsDialogEditMarkup(markupId) {186 var dia = jQuery("#arrange-fields-markup-dialog");187 188 // Make sure we have properties have initial, non-null values.189 if (arrangeFieldsDialogMarkupObj[markupId] == null) {190 arrangeFieldsDialogMarkupObj[markupId] = new Object();191 }192 if (arrangeFieldsDialogMarkupObj[markupId]["markupBody"] == null) {193 arrangeFieldsDialogMarkupObj[markupId]["markupBody"] = "";194 }195 if (arrangeFieldsDialogMarkupObj[markupId]["wrapperStyle"] == null) {196 arrangeFieldsDialogMarkupObj[markupId]["wrapperStyle"] = "";197 }198 if (arrangeFieldsDialogMarkupObj[markupId]["zIndex"] == null) {199 arrangeFieldsDialogMarkupObj[markupId]["zIndex"] = "201";200 }201 202 203 // Clear or re-load the dialog's inputs with values from our204 // obj.205 dia.find("textarea[name=af-markup-body]").val(arrangeFieldsUnconvertUnsafeChars(arrangeFieldsDialogMarkupObj[markupId]["markupBody"]));206 dia.find("input[name=af-wrapper-style]").val(arrangeFieldsUnconvertUnsafeChars(arrangeFieldsDialogMarkupObj[markupId]["wrapperStyle"]));207 dia.find("input[name=af-markup-z-index]").each(function() {208 if (jQuery(this).val() == arrangeFieldsDialogMarkupObj[markupId]["zIndex"]) {209 jQuery(this).attr("checked", "checked");210 }211 });212 213 214 arrangeFieldsDialogMarkupId = markupId;215 dia.dialog('open'); 216 }217 218 219 /**220 * Applies the changes from the markup dialog.221 **/222 function arrangeFieldsApplyDialogMarkupChanges() {223 var dia = jQuery("#arrange-fields-markup-dialog");224 225 var markupId = arrangeFieldsDialogMarkupId;226 227 if (markupId == "new") {228 // This is a new field! So, create a random ID for it.229 markupId = "markup_element_" + arrangeFieldsRandomString();230 arrangeFieldsDialogMarkupObj[markupId] = new Object();231 232 // Create this element on the form itself, as a draggable, resizable div.233 // Give it a random-ish top and left position, so if you add several at a time,234 // they won't all be on top of each other.235 var ptop = 10 + Math.floor(Math.random() * 20);236 var pleft = 10 + Math.floor(Math.random() * 20);237 238 var newElements = "<div class='draggable-form-item arrange-fields-draggable-markup' id='" + markupId + "' style='top: " + ptop + "px; left: " + pleft + "px; z-index: 201;'>";239 newElements += "<div class='arrange-fields-control-handle arrange-fields-control-handle-markup'><span class='arrange-fields-handle-region'> &nbsp; &nbsp; </span>";240 newElements += " <a href='javascript: arrangeFieldsDialogEditMarkup(\"" + markupId + "\");' class='arrange-fields-config-markup-link' title='Configure this markup'>&nbsp;</a>";241 newElements += "</div>";242 newElements += "<div class='arrange-fields-markup-body form-item' id='" + markupId + "_body'></div>";243 newElements += "</div>";244 245 jQuery(".arrange-fields-container").append(newElements);246 247 // Now, make the new element draggable.248 // This is the same code from arrange_fields.js.249 jQuery(".arrange-fields-container #" + markupId).draggable({250 stop: function(event, ui) { arrangeFieldsRepositionToGrid(false); },251 containment: ".arrange-fields-container", 252 scroll: true,253 grid : [10,10],254 start: function(event, ui) {arrangeFieldsDragging = true;},255 stop: function(event, ui) {arrangeFieldsDragging = false;} 256 });257 258 259 // Let's also make it resizable.260 jQuery(".arrange-fields-container #" + markupId).resizable(); 261 262 263 // Add in the hide/show behavior for the handle...264 jQuery(".arrange-fields-container #" + markupId).bind("mouseenter", function(event) {265 var hand = jQuery(this).find(".arrange-fields-control-handle");266 if (arrangeFieldsDragging != true) {267 jQuery(hand).show();268 }269 });270 271 jQuery(".arrange-fields-container #" + markupId).bind("mouseleave", function(event) {272 var hand = jQuery(this).find(".arrange-fields-control-handle");273 if (arrangeFieldsDragging != true) {274 jQuery(hand).hide();275 }276 });277 278 // Snap everything back to the grid.279 arrangeFieldsRepositionToGrid();280 281 }282 283 284 var markupBody = dia.find("textarea[name=af-markup-body]").val();285 var safeMarkupBody = arrangeFieldsConvertUnsafeChars(markupBody);286 287 var wrapperStyle = dia.find("input[name=af-wrapper-style]").val();288 var safeWrapperStyle = arrangeFieldsConvertUnsafeChars(wrapperStyle);289 290 var zIndex = dia.find("input[name=af-markup-z-index]:checked").val();291 292 // Save into the obj.293 arrangeFieldsDialogMarkupObj[markupId]["markupBody"] = safeMarkupBody;294 arrangeFieldsDialogMarkupObj[markupId]["wrapperStyle"] = safeWrapperStyle;295 arrangeFieldsDialogMarkupObj[markupId]["zIndex"] = zIndex;296 297 // Apply it to the page.298 jQuery(".arrange-fields-container #" + markupId + "_body").html(markupBody);299 var tempStyle = jQuery(".arrange-fields-container #" + markupId).attr("style");300 jQuery(".arrange-fields-container #" + markupId).attr("style", tempStyle + " ; " + wrapperStyle);301 jQuery(".arrange-fields-container #" + markupId).css("z-index", zIndex);302 303 dia.dialog('close'); 304 }305 306 307 function arrangeFieldsDialogMarkupDelete() {308 var x = confirm("Are you sure you wish to delete this markup element? This action cannot be undone.");309 if (!x) {return;}310 311 var markupId = arrangeFieldsDialogMarkupId;312 // Remove it from our object.313 arrangeFieldsDialogMarkupObj[markupId] = null;314 315 // Also, remove it from the page!316 jQuery(".arrange-fields-container #" + markupId).remove();317 318 var dia = jQuery("#arrange-fields-markup-dialog");319 dia.dialog('close');320 321 }322 323 /**324 * Replace "unsafe" characters with codes which we can decode later.325 * I am trying to make the codes random enough so that no one would actually326 * have typed them into the field.327 **/328 function arrangeFieldsConvertUnsafeChars(str) {329 330 // Must use regex with the "g" to replace all occurances (like in PHP)331 str = str.replace(/,/g, "_~!co%~_");332 str = str.replace(/;/g, "_~!sc%~_");333 str = str.replace(/'/g, "_~!sq%~_"); //'334 str = str.replace(/"/g, "_~!dq%~_"); //"335 str = str.replace(/\n/g, "_~!nl%~_");336 337 338 return str;339 }340 341 /**342 * The opposite of ConvertUnsafeChars343 **/344 function arrangeFieldsUnconvertUnsafeChars(str) {345 346 // Must use regex with the "g" to replace all occurances (like in PHP)347 str = str.replace(/_~!co%~_/g, ",");348 str = str.replace(/_~!sc%~_/g, ";");349 str = str.replace(/_~!sq%~_/g, "'");350 str = str.replace(/_~!dq%~_/g, '"');351 str = str.replace(/_~!nl%~_/g, "\n");352 353 return str;354 }355 356 357 function arrangeFieldsRandomString() {358 var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";359 var length = 10;360 var randomstring = '';361 for (var i = 0; i < length; i++) {362 var rnum = Math.floor(Math.random() * chars.length);363 randomstring += chars.substring(rnum,rnum+1);364 }365 return randomstring;366 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var parent = require('stryker-parent');2var child = require('stryker-child');3var child2 = require('stryker-child2');4var child3 = require('stryker-child3');5var child4 = require('stryker-child4');6var child5 = require('stryker-child5');7var child6 = require('stryker-child6');8var child7 = require('stryker-child7');9var child8 = require('stryker-child8');10var child9 = require('stryker-child9');11var child10 = require('stryker-child10');12var child11 = require('stryker-child11');13var child12 = require('stryker-child12');14var child13 = require('stryker-child13');15var child14 = require('stryker-child14');16var child15 = require('stryker-child15');17var child16 = require('stryker-child16');18var child17 = require('stryker-child17');19var child18 = require('stryker-child18');20var child19 = require('stryker-child19');21var child20 = require('stryker-child20');22var child21 = require('stryker-child21');23var child22 = require('stryker-child22');24var child23 = require('stryker-child23');25var child24 = require('stryker-child24');26var child25 = require('stryker-child25');27var child26 = require('stryker-child26');28var child27 = require('stryker-child27');29var child28 = require('stryker-child28');30var child29 = require('stryker-child29');31var child30 = require('stryker-child30');32var child31 = require('stryker-child31');33var child32 = require('stryker-child32');34var child33 = require('stryker-child33');35var child34 = require('stryker-child34');36var child35 = require('stryker-child35');37var child36 = require('stryker-child36');38var child37 = require('stryker-child37');39var child38 = require('stryker-child38');40var child39 = require('stryker-child39');41var child40 = require('stryker-child40');42var child41 = require('stryker-child41');43var child42 = require('stryker-child42');44var child43 = require('stryker-child43');45var child44 = require('stryker-child44');46var child45 = require('stryker

Full Screen

Using AI Code Generation

copy

Full Screen

1const { arrange } = require('stryker-parent');2describe('My test', () => {3 arrange(() => {4 });5 it('should do something', () => {6 });7});8const { arrange } = require('stryker-parent');9describe('My test', () => {10 arrange(() => {11 });12 it('should do something', () => {13 });14});15const { arrange } = require('stryker-parent');16describe('My test', () => {17 arrange(() => {18 });19 it('should do something', () => {20 });21});22const { arrange } = require('stryker-parent');23describe('My test', () => {24 arrange(() => {25 });26 it('should do something', () => {27 });28});29const { arrange } = require('stryker-parent');30describe('My test', () => {31 arrange(() => {32 });33 it('should do something', () => {34 });35});36const { arrange } = require('stryker-parent');37describe('My test', () => {38 arrange(() => {39 });40 it('should do something', () => {41 });42});43const { arrange } = require('stryker-parent');44describe('My test', () => {45 arrange(() => {46 });47 it('should do something', () => {48 });49});50const { arrange } = require('stryker-parent');51describe('My test',

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerParent = require('stryker-parent');2const strykerConfig = strykerParent.arrange({3});4module.exports = strykerConfig;5module.exports = require('./test.js');6{7}8import * as strykerParent from 'stryker-parent';9export = strykerParent.arrange({10});11const strykerParent = require('stryker-parent');12const strykerConfig = strykerParent.arrange({13 jest: {14 config: require('./jest.config.js')15 }16});17module.exports = strykerConfig;18module.exports = require('./test.js');19{20}21import * as strykerParent from 'stryker-parent';22export = strykerParent.arrange({23 jest: {24 config: require('./jest.config.js')25 }26});27const strykerParent = require('stryker-parent');28const strykerConfig = strykerParent.arrange({

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = {2 arrange: function(){3 },4 act: function(){5 },6 assert: function(){7 }8};9module.exports = strykerParent;10const mockery = require('mockery');11mockery.enable({12});13mockery.registerMock('request', {14 get: function (url, callback) {15 callback(null, null, {statusCode: 200});16 }17});18mockery.registerAllowable('../src/MyModule');19const MyModule = require('../src/MyModule');20MyModule.getSomething();21 at Object.registerAllowable (node_modules/mockery/lib/mockery.js:132:23)22 at Context.<anonymous> (test/MyModule.spec.js:10:0)23const sinon = require('sinon');24const request = require('request');25const chai = require('chai');26const expect = chai.expect;27const MyModule = require('../src/MyModule');28describe('MyModule', function () {29 describe('getSomething', function () {30 it('should call the callback',

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2var fs = require('fs');3var path = require('path');4var config = require('./stryker.conf.js');5var files = fs.readdirSync(path.join(__dirname, 'src'));6var filesToMutate = files.map(function (file) {7 return path.join(__dirname, 'src', file);8});9var filesToMutate = filesToMutate.concat(['test.js']);10config.mutate = filesToMutate;11var mutationTestReport = stryker.arrange(config);12console.log(mutationTestReport);13module.exports = function (config) {14 config.set({15 karma: {16 config: {17 }18 }19 });20};21function sum(a, b) {22 return a + b;23}24module.exports = sum;25function sub(a, b) {26 return a - b;27}28module.exports = sub;29var sum = require('./src/sum.js');30var sub = require('./src/sub.js');31describe('sum', function () {32 it('should be able to add two numbers', function () {33 expect(sum(1, 2)).toBe(3);34 });35});36describe('sub', function () {37 it('should be able to subtract two numbers', function () {38 expect(sub(1, 2)).toBe(-1);39 });40});41{ files: 42 [ { name: 'src/sum.js',43 source: 'function sum(a, b) {\n return a + b;\n}\nmodule.exports = sum;\n',44 included: true },45 { name: 'src/sub.js',46 source: 'function sub(a, b) {\n return a - b;\n}\nmodule.exports = sub;\n',47 included: true },48 { name: 'test.js',49 source: 'var sum = require(\'./src/sum.js\');\nvar sub = require(\'./src/sub.js\');\

Full Screen

Using AI Code Generation

copy

Full Screen

1const { arrange } = require('stryker-parent');2const { expect } = require('chai');3describe('test', () => {4 arrange(() => {5 const foo = 'bar';6 });7 it('should be able to use foo', () => {8 expect(foo).eq('bar');9 });10});11const { arrange } = require('stryker-parent');12const { expect } = require('chai');13describe('test', () => {14 arrange(() => {15 const foo = 'bar';16 });17 it('should be able to use foo', () => {18 expect(foo).eq('bar');19 });20});21const { arrange } = require('stryker-parent');22const { expect } = require('chai');23describe('test', () => {24 arrange(() => {25 const foo = 'bar';26 });27 it('should be able to use foo', () => {28 expect(foo).eq('bar');29 });30});31const { arrange } = require('stryker-parent');32const { expect } = require('chai');33describe('test', () => {34 arrange(() => {35 const foo = 'bar';36 });37 it('should be able to use foo', () => {38 expect(foo).eq('bar');39 });40});41const { arrange } = require('stryker-parent');42const { expect } = require('chai');43describe('test', () => {44 arrange(() => {45 const foo = 'bar';46 });47 it('should be able to use foo', () => {48 expect(foo).eq('bar');49 });50});51const { arrange } = require('stryker-parent');52const { expect } = require('chai');53describe('test', () => {54 arrange(() => {55 const foo = 'bar';56 });57 it('should be able to use foo', () => {58 expect(foo).eq('bar');59 });60});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { arrange } = require('stryker-parent');2describe('test', () => {3 it('should arrange', () => {4 arrange();5 });6});7[2018-11-27 18:22:20.791] [INFO] SandboxPool - Creating 1 test runners (based on CPU count)8[2018-11-27 18:22:20.792] [INFO] Sandbox - Starting initial test run in sandbox { path: 'C:\\Users\\user\\AppData\\Local\\Temp\\stryker\\sandbox-7d6b5f6a5a6c4a6f', timeout: 5000 }

Full Screen

Using AI Code Generation

copy

Full Screen

1var arrange = require('stryker-parent').arrange;2arrange('test.js', function (arrange) {3 arrange.set('foo', 'bar');4 arrange.set('bar', 'baz');5});6var arrange = require('stryker-parent').arrange;7arrange('test.js', function (arrange) {8 arrange.set('foo', 'bar');9 arrange.set('bar', 'baz');10});11var arrange = require('stryker-parent').arrange;12arrange('test.js', function (arrange) {13 arrange.set('foo', 'bar');14 arrange.set('bar', 'baz');15});16var arrange = require('stryker-parent').arrange;17arrange('test.js', function (arrange) {18 arrange.set('foo', 'bar');19 arrange.set('bar', 'baz');20});21var arrange = require('stryker-parent').arrange;22arrange('test.js', function (arrange) {23 arrange.set('foo', 'bar');24 arrange.set('bar', 'baz');25});26var arrange = require('stryker-parent').arrange;27arrange('test.js', function (arrange) {28 arrange.set('foo', 'bar');29 arrange.set('bar', 'baz');30});

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerParent = require('stryker-parent');2const strykerConfig = strykerParent.configs.base();3const customConfig = {4};5module.exports = strykerConfig(customConfig);6{7 "scripts": {8 },9 "devDependencies": {10 }11}

Full Screen

Automation Testing Tutorials

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

LambdaTest Learning Hubs:

YouTube

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

Run stryker-parent automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful