How to use trigger method in locust

Best Python code snippet using locust

script.js

Source:script.js Github

copy

Full Screen

1/* 2 * Модуль подключается на странице настроек плагина.3 */4var triggerGuarantee = (function () {5 return {6 lang: [], // локаль плагина 7 supportCkeditor: null,8 init: function () {9 // установка локали плагина 10 admin.ajaxRequest({11 mguniqueurl: "action/seLocalesToPlug",12 pluginName: 'trigger-guarantee'13 },14 function (response) {15 triggerGuarantee.lang = response.data;16 });17 $('.admin-center').on('click', '.section-trigger-guarantee .add-new-button', function () {18 triggerGuarantee.showModal('add');19 });20 $('.admin-center').on('click', '.section-trigger-guarantee .choose-icon', function () {21 if ($(this).hasClass('opend')) {22 $('.section-trigger-guarantee .font-awesome-icons').toggle();23 } else {24 $(this).addClass('opend');25 triggerGuarantee.showIcons();26 }27 });28// $('.admin-center').on('mouseover', '.section-trigger-guarantee .font-awesome-icons span .fa', function() {29// $(this).addClass('fa-3x');30// });31// $('.admin-center').on('mouseleave', '.section-trigger-guarantee .font-awesome-icons span .fa', function() {32// $(this).removeClass('fa-3x');33// });34 $('.admin-center').on('click', '.section-trigger-guarantee .font-awesome-icons .fa', function () {35 var className = $(this).attr('class');36 $('.section-trigger-guarantee .add-trigger-element .img').html('<i class="' + className + ' fa-4x"></i>');37 $('.section-trigger-guarantee #add-plug-modal input[name="icon"] ').val(className);38 $('.section-trigger-guarantee .font-awesome-icons').slideUp();39 });40 $('.admin-center').on('click', '.section-trigger-guarantee #add-plug-modal .save-button', function () {41 var id = $(this).data('id');42 triggerGuarantee.saveField(id);43 });44 if ($('.section-trigger-guarantee .trigger-guarantee-elements tr').length > 0) {45 $('.section-trigger-guarantee .trigger-guarantee-save').show();46 }47 $('.admin-center').on('click', '.section-trigger-guarantee .save-button.trigger', function () {48 if ($('.section-trigger-guarantee table .trigger-guarantee-elements tr').length > 0) {49 var id = $(this).attr('id');50 var next_id = $(this).data('nextid');51 triggerGuarantee.saveTrigger(id, next_id);52 } else {53 admin.indication('error', 'Необходимо добавить элементы!');54 return false;55 }56 });57 // изменени внешнего вида элементов триггеров58 $('.admin-center').on('change', '.section-trigger-guarantee .list-option input, .list-option select', function () {59 triggerGuarantee.applySettings();60 })61 // Выбор картинки62 $('.admin-center').on('click', '.section-trigger-guarantee .browseImage', function () {63 admin.openUploader('triggerGuarantee.getImage');64 });65 $('.admin-center').on('click', '.section-trigger-guarantee .open-trigger', function () {66 if ($(this).parents('li').hasClass('is-active')) {67 return true;68 } else {69 var id = $(this).attr('id');70 $(this).parents('ul').find('li').removeClass('is-active');71 $(this).parents('li').addClass('is-active');72 triggerGuarantee.clearTrigger();73 if (id) {74 admin.ajaxRequest({75 mguniqueurl: "action/getTrigger",76 pluginHandler: 'trigger-guarantee', // плагин для обработки запроса77 id: id,78 },79 function (response) {80 triggerGuarantee.fillFieldTrigger(response.data);81 }82 );83 }84 }85 });86 // Выводит модальное окно для редактирования87 $('.admin-center').on('click', '.section-trigger-guarantee .trigger-guarantee-elements .edit-row', function () {88 var id = $(this).data('id');89 triggerGuarantee.showModal('edit', id, 0);90 });91 // выбор элемента из существующих92 $('.admin-center').on('click', '.section-trigger-guarantee .add-exist-button', function () {93 $('.widget-table-wrapper .trigger-guarantee-all-elements').show();94 $('html, body').animate({scrollTop: $('.trigger-guarantee-all-elements').offset().top - 100}, 800);95 });96 // выбор закрыть таблицу с существующими элементами97 $('.admin-center').on('click', '.section-trigger-guarantee .close-trigger-table', function () {98 $('.widget-table-wrapper .trigger-guarantee-all-elements').slideUp(400);99 });100 // выбор элемента из таблицы101 $('.admin-center').on('click', '.section-trigger-guarantee .trigger-guarantee-tbody .trigger-item', function () {102 var id = $(this).parents('tr').data('id');103 var parent = $(this).parents('tr').find('.parent').data('parent');104 $('.widget-table-wrapper .trigger-guarantee-all-elements').hide();105 triggerGuarantee.showModal('edit', id, parent);106 })107 // удаление елемента из триггера108 $('.admin-center').on('click', '.section-trigger-guarantee .trigger-guarantee-elements .delete-row', function () {109 var id = $(this).data('id');110 if (id) {111 if (confirm('Удалить элемент триггера?')) {112 admin.ajaxRequest({113 mguniqueurl: "action/deleteElement", // действия для выполнения на сервере114 pluginHandler: 'trigger-guarantee', // плагин для обработки запроса115 id: id116 },117 function (response) {118 admin.indication(response.status, response.msg);119 if (response.status == 'success') {120 $('.section-trigger-guarantee .trigger-guarantee-elements tr[data-id=' + id + ']').remove();121 $('.section-trigger-guarantee .trigger-guarantee-table tr[data-id=' + id + ']').remove();122 }123 })124 }125 }126 });127 // удаление всего триггера128 $('.admin-center').on('click', '.section-trigger-guarantee .delete-trigger', function () {129 var id = $(this).data('id');130 if (id) {131 if (confirm('Удалить триггер и все его элементы?')) {132 admin.ajaxRequest({133 mguniqueurl: "action/deleteTrigger", // действия для выполнения на сервере134 pluginHandler: 'trigger-guarantee', // плагин для обработки запроса135 id: id136 },137 function (response) {138 admin.indication(response.status, response.msg);139 if (response.status == 'success') {140 admin.refreshPanel();141 }142 })143 }144 }145 });146 },147 /* открывает модальное окно 148 * @param {type} type -тип окна, для редактирования или для добавления149 * @param {type} id - номер записи, которая открыта на редактирование150 * @returns {undefined}151 */152 showModal: function (type, id, parent) {153 switch (type) {154 case 'add':155 {156 triggerGuarantee.clearField();157 break;158 }159 case 'edit':160 {161 try {162 if (CKEDITOR.instances['html_content']) {163 CKEDITOR.instances['html_content'].destroy();164 }165 } catch (e) {166 }167 triggerGuarantee.clearField();168 triggerGuarantee.fillField(id, parent);169 break;170 }171 default:172 {173 break;174 }175 }176 admin.openModal($('#add-plug-modal'));177 $('textarea[data-name=html_content]').ckeditor();178 },179 /**180 * Очистка модального окна181 */182 clearField: function () {183 $('.section-trigger-guarantee #add-plug-modal .save-button').data('id', '');184 $('.section-trigger-guarantee textarea[data-name=html_content]').val('');185 $('.section-trigger-guarantee .add-trigger-element img').removeAttr('src');186 $('.section-trigger-guarantee .add-trigger-element .img').html('');187 $('.section-trigger-guarantee #add-plug-modal input[name="icon"] ').val('');188 triggerGuarantee.supportCkeditor = '';189 },190 /**191 * Заполнение модального окна данными из БД192 * @param {type} id193 * @returns {undefined}194 */195 fillField: function (id, parent) {196 admin.ajaxRequest({197 mguniqueurl: "action/getEntity", // действия для выполнения на сервере198 pluginHandler: 'trigger-guarantee', // плагин для обработки запроса199 id: id // id записи200 },201 function (response) {202 triggerGuarantee.supportCkeditor = response.data.text;203 if (parent == '0') {204 $('.section-trigger-guarantee #add-plug-modal .save-button').data('id', response.data.id);205 }206 $('.section-trigger-guarantee #add-plug-modal .img').html(response.data.icon)207 $('.section-trigger-guarantee #add-plug-modal input[name="icon"] ').val(response.data.icon); 208 $('.section-trigger-guarantee #add-plug-modal textarea[data-name=html_content]').ckeditor(function () {209 this.setData(triggerGuarantee.supportCkeditor);210 }); 211 }212 );213 },214 /**215 * загружает иконки из font-awesome216 */217 showIcons: function () {218 admin.ajaxRequest({219 mguniqueurl: "action/getIcons", // действия для выполнения на сервере220 pluginHandler: 'trigger-guarantee' // плагин для обработки запроса221 },222 function (response) {223 $('.section-trigger-guarantee .font-awesome-icons').append(response.data);224 $('.section-trigger-guarantee .font-awesome-icons').show();225 }226 );227 },228 /**229 * Сохранение данных из модального окна230 * @param {type} id231 * @returns {undefined}232 */233 saveField: function (id) {234 $('.section-trigger-guarantee .add-trigger-element .img').attr('alt', 'tempAlt');235 var text = $('.section-trigger-guarantee .add-trigger-element textarea[data-name=html_content]').val();236 var icon = $('.section-trigger-guarantee .add-trigger-element .img').html().replace('alt="tempAlt"', 'alt="'+text+'"').replace("alt='tempAlt'", "alt='"+text+"'");237 var parent = $('.section-trigger-guarantee .add-new-button').attr('id');238 admin.ajaxRequest({239 mguniqueurl: "action/saveEntity", // действия для выполнения на сервере240 pluginHandler: 'trigger-guarantee', // плагин для обработки запроса241 id: id,242 text: text,243 icon: icon,244 parent: parent ? parent : 0,245 },246 function (response) {247 admin.indication(response.status, response.msg);248 var elem = '<tr data-id=' + response.data.row.id + '>\249 <td >\250 <div class="trigger-item">\251 <span class="trigger-icon">' + icon + '</span>\252 <span class="trigger-text">' + text + '</span>\253 </div>\254 </td>\255 <td class="actions">\256 <ul class="action-list">\257 <li class="mover"\258 data-id="' + response.data.row.id + '">\259 <a href="javascript:void(0);"><i class="fa fa-arrows ui-sortable-handle"></i></a>\260 </li>\261 <li class="edit-row"\262 data-id="' + response.data.row.id + '">\263 <a class="tool-tip-bottom fa fa-pencil" href="javascript:void(0);"\264 title="' + triggerGuarantee.lang['EDIT'] + '"></a>\265 </li>\266 <li class="delete-row"\267 data-id="' + response.data.row.id + '">\268 <a class="tool-tip-bottom fa fa-trash" href="javascript:void(0);"\269 title="' + triggerGuarantee.lang['DELETE'] + '"></a>\270 </li>\271 </ul>\272 </td></tr>';273 var trigger = (parent ? 'Триггер №' + parent : '');274 var tr = '<tr data-id=' + response.data.row.id + '>\275 <td>\276 ' + response.data.row.id + '\277 </td>\278 <td>\279 <div class="trigger-item">\280 <span class="trigger-icon">' + icon + '</span>\281 <span class="trigger-text">' + text + '</span>\282 </div>\283 </td>\284 <td class="parent" data-parent="' + parent + '">\285 ' + trigger + '</td>\286 </tr>';287 if (id && ($('.section-trigger-guarantee .trigger-guarantee-elements tr[data-id=' + id + ']')).length != 0) {288 $('.section-trigger-guarantee table .trigger-guarantee-elements tr[data-id=' + id + ']').replaceWith(elem);289 } else {290 $('.section-trigger-guarantee table .trigger-guarantee-elements').append(elem);291 }292 if (id && ($('.section-trigger-guarantee .trigger-guarantee-table tr[data-id=' + id + ']')).length != 0) {293 $('.section-trigger-guarantee .trigger-guarantee-table tr[data-id=' + id + ']').replaceWith(tr);294 } else {295 $('.section-trigger-guarantee .trigger-guarantee-table').append(tr);296 }297 admin.closeModal($('#add-plug-modal')); 298 triggerGuarantee.applySettings();299 }300 );301 },302 /**303 * функция для приема файла из аплоадера304 */305 getImage: function (file) {306 $('.section-trigger-guarantee #add-plug-modal input[name="icon"]').val(file.url);307 if ($('.section-trigger-guarantee #add-plug-modal img').length != 0) {308 $('.section-trigger-guarantee #add-plug-modal img').attr('src', file.url);309 $('.section-trigger-guarantee #add-plug-modal img').attr('width', '170');310 $('.section-trigger-guarantee #add-plug-modal img').attr('alt', 'tempAlt');311 } else {312 $('.section-trigger-guarantee #add-plug-modal .img').html('<img class="img" width="170" alt="tempAlt" src="' + file.url + '">');313 }314 },315 /**316 * применение настроек к элементам триггера317 * 318 */319 applySettings: function () {320 var form = $('.section-trigger-guarantee .list-option select[name=form]').val();321 var radius = (form == 'circle' ? '50%' : 0);322 var float = $('.section-trigger-guarantee .list-option select[name=place]').val();323 var width = $('.section-trigger-guarantee .list-option input[name=width]').val();324 var unit = $('.section-trigger-guarantee .list-option select[name=unit]').val() == 1 ? '%' : 'px';325 width = width + unit;326 $('.section-trigger-guarantee .list-option .trigger-width').text(width);327 var height = $('.section-trigger-guarantee .list-option input[name=height]').val();328 $('.section-trigger-guarantee .list-option .trigger-height').text(height + 'px');329 if (float == 'left') {330 $('.section-trigger-guarantee table .trigger-guarantee-elements tr .trigger-icon').css('float', 'none');331 } else if (float == 'top') {332 $('.section-trigger-guarantee table .trigger-guarantee-elements tr .trigger-icon').css('display', 'block');333 $('.section-trigger-guarantee table .trigger-guarantee-elements tr .trigger-icon').css('float', 'none');334 }335 $('.section-trigger-guarantee table .trigger-guarantee-elements tr .trigger-icon img').css('border-radius', radius);336 $('.section-trigger-guarantee table .trigger-guarantee-elements tr .trigger-icon i').css('border-radius', radius);337 var color = $('.section-trigger-guarantee .list-option input[name="color_icon"]').val();338 $('.section-trigger-guarantee table .trigger-guarantee-elements tr .trigger-icon i').css('color', '#' + color);339 var colorBack = $('.section-trigger-guarantee .list-option input[name="background_icon"]').val();340 $('.section-trigger-guarantee table .trigger-guarantee-elements tr .trigger-icon i').css('background-color', '#' + colorBack);341 $('.section-trigger-guarantee table .trigger-guarantee-elements tr .trigger-icon img').css('background-color', '#' + colorBack);342 var background = $('.section-trigger-guarantee .list-option input[name="background"]').val();343 $('.section-trigger-guarantee table .trigger-guarantee-elements tr .trigger-item').css('background-color', '#' + background);344 $('.section-trigger-guarantee table .trigger-item').css('width', width);345 $('.section-trigger-guarantee table .trigger-item').css('height', height);346 var size = $('.section-trigger-guarantee .list-option input[name="fontSize"]').val();347 $('.section-trigger-guarantee table .trigger-icon i').css("font-size", size+"em");348 },349 /** 350 * сохраняем триггер в его элементами и настроками351 */352 saveTrigger: function (id, next_id) {353 var obj = '{';354 $('.section-trigger-guarantee .list-option input, .list-option select').each(function () {355 obj += '"' + $(this).attr('name') + '":"' + ($(this).val()) + '",';356 });357 obj += '}';358 //преобразуем полученные данные в JS объект для передачи на сервер359 var data = eval("(" + obj + ")");360 var title = $('.section-trigger-guarantee input[name="title-trigger"]').val();361 var elements = triggerGuarantee.createElementsList();362 admin.ajaxRequest({363 mguniqueurl: "action/saveTrigger",364 pluginHandler: 'trigger-guarantee', // плагин для обработки запроса365 id: id,366 settings: data,367 title: title,368 elements: elements,369 new_id: next_id,370 },371 function (response) {372 admin.indication(response.status, response.msg);373 if (!id) {374 admin.refreshPanel();375 }376 }377 );378 },379 // массив с id элементов триггера380 createElementsList: function () {381 var elem = [];382 $('.section-trigger-guarantee table .trigger-guarantee-elements tr').each(function () {383 elem.push($(this).data('id'));384 });385 return elem;386 },387 // 388 clearTrigger: function () {389 $('.section-trigger-guarantee .list-option select').each(function () {390 $(this).val('');391 });392 $('.section-trigger-guarantee .list-option input[name="color_icon"]').val('000');393 $('.section-trigger-guarantee .list-option input[name="background_icon"]').val('fff');394 $('.section-trigger-guarantee .list-option input[name="background"]').val('fff');395 $('.section-trigger-guarantee .list-option input[name="color_icon"]').css('border-color', '#000');396 $('.section-trigger-guarantee .list-option input[name="background"], .list-option input[name="background_icon"]').css('border-color', '#fff');397 $('.section-trigger-guarantee input[name="title-trigger"]').val('');398 $('.section-trigger-guarantee table .trigger-guarantee-elements tr').remove();399 var next_id = $('.section-trigger-guarantee .main-settings-trigger .short-code').data('id');400 $('.section-trigger-guarantee .main-settings-trigger .short-code').text(next_id);401 $('.section-trigger-guarantee .save-button.trigger').removeAttr('id');402 $('.section-trigger-guarantee .delete-trigger').data('id', '');403 $('.section-trigger-guarantee .add-new-button').removeAttr('id');404 $('.section-trigger-guarantee .list-option select[name=unit]').val('1');405 $('.section-trigger-guarantee .list-option input[name=fontSize]').val('4');406 },407 fillFieldTrigger: function (data) {408 $('.section-trigger-guarantee .list-option select[name="form"]').val(data.settings.form);409 $('.section-trigger-guarantee .list-option select[name="place"]').val(data.settings.place);410 $('.section-trigger-guarantee .list-option input[name="width"]').val(data.settings.width);411 $('.section-trigger-guarantee .list-option input[name="height"]').val(data.settings.height);412 $('.section-trigger-guarantee .list-option select[name="layout"]').val(data.settings.layout ? data.settings.layout : 'vert');413 $('.section-trigger-guarantee .list-option input[name="color_icon"]').val(data.settings.color_icon);414 $('.section-trigger-guarantee .list-option input[name="background_icon"]').val(data.settings.background_icon);415 $('.section-trigger-guarantee .list-option input[name="background"]').val(data.settings.background);416 $('.section-trigger-guarantee .list-option input[name="color_icon"]').css('cssText', 'border-color: #' + data.settings.color_icon + ' !important');417 $('.section-trigger-guarantee .list-option input[name="background"]').css('cssText', 'border-color: #' + data.settings.background + ' !important');418 $('.section-trigger-guarantee .list-option input[name="background_icon"]').css('cssText', 'border-color: #' + data.settings.background_icon + ' !important');419 $('.section-trigger-guarantee input[name="title-trigger"]').val(data.title);420 $('.section-trigger-guarantee .main-settings-trigger .short-code').text(data.id);421 $('.section-trigger-guarantee .save-button.trigger').attr('id', data.id);422 $('.section-trigger-guarantee .delete-trigger').data('id', data.id);423 $('.section-trigger-guarantee .add-new-button').attr('id', data.id);424 $('.section-trigger-guarantee .list-option select[name=unit]').val(data.settings.unit? data.settings.unit : '1');425 $('.section-trigger-guarantee .list-option input[name="fontSize"]').val(data.settings.fontSize);426 function buildRow(el) {427 var row = '<tr data-id=' + el.id + '>\428 <td >\429 <div class="trigger-item">\430 <span class="trigger-icon">' + el.icon + '</span>\431 <span class="trigger-text">' + el.text + '</span>\432 </div>\433 </td>\434 <td class="actions">\435 <ul class="action-list">\436 <li class="mover"\437 data-id="' + el.id + '">\438 <a href="javascript:void(0);"><i class="fa fa-arrows ui-sortable-handle"></i></a>\439 </li>\440 <li class="edit-row"\441 data-id="' + el.id + '">\442 <a class="tool-tip-bottom fa fa-pencil" href="javascript:void(0);"\443 title="' + triggerGuarantee.lang['EDIT'] + '"></a>\444 </li>\445 <li class="delete-row"\446 data-id="' + el.id + '">\447 <a class="tool-tip-bottom fa fa-trash" href="javascript:void(0);"\448 title="' + triggerGuarantee.lang['DELETE'] + '"></a>\449 </li>\450 </ul>\451 </td></tr>';452 $('.section-trigger-guarantee table .trigger-guarantee-elements').append(row);453 }454 data.elements.forEach(buildRow);455 triggerGuarantee.applySettings();456 },457 }458})();...

Full Screen

Full Screen

TriggerField.js

Source:TriggerField.js Github

copy

Full Screen

1/*!2 * Ext JS Library 3.1.13 * Copyright(c) 2006-2010 Ext JS, LLC4 * licensing@extjs.com5 * http://www.extjs.com/license6 */7/**8 * @class Ext.form.TriggerField9 * @extends Ext.form.TextField10 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).11 * The trigger has no default action, so you must assign a function to implement the trigger click handler by12 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox13 * for which you can provide a custom implementation. For example:14 * <pre><code>15var trigger = new Ext.form.TriggerField();16trigger.onTriggerClick = myTriggerFn;17trigger.applyToMarkup('my-field');18</code></pre>19 *20 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.21 * {@link Ext.form.DateField} and {@link Ext.form.ComboBox} are perfect examples of this.22 *23 * @constructor24 * Create a new TriggerField.25 * @param {Object} config Configuration options (valid {@Ext.form.TextField} config options will also be applied26 * to the base TextField)27 * @xtype trigger28 */29Ext.form.TriggerField = Ext.extend(Ext.form.TextField, {30 /**31 * @cfg {String} triggerClass32 * An additional CSS class used to style the trigger button. The trigger will always get the33 * class <tt>'x-form-trigger'</tt> by default and <tt>triggerClass</tt> will be <b>appended</b> if specified.34 */35 /**36 * @cfg {Mixed} triggerConfig37 * <p>A {@link Ext.DomHelper DomHelper} config object specifying the structure of the38 * trigger element for this Field. (Optional).</p>39 * <p>Specify this when you need a customized element to act as the trigger button for a TriggerField.</p>40 * <p>Note that when using this option, it is the developer's responsibility to ensure correct sizing, positioning41 * and appearance of the trigger. Defaults to:</p>42 * <pre><code>{tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.triggerClass}</code></pre>43 */44 /**45 * @cfg {String/Object} autoCreate <p>A {@link Ext.DomHelper DomHelper} element spec, or true for a default46 * element spec. Used to create the {@link Ext.Component#getEl Element} which will encapsulate this Component.47 * See <tt>{@link Ext.Component#autoEl autoEl}</tt> for details. Defaults to:</p>48 * <pre><code>{tag: "input", type: "text", size: "16", autocomplete: "off"}</code></pre>49 */50 defaultAutoCreate : {tag: "input", type: "text", size: "16", autocomplete: "off"},51 /**52 * @cfg {Boolean} hideTrigger <tt>true</tt> to hide the trigger element and display only the base53 * text field (defaults to <tt>false</tt>)54 */55 hideTrigger:false,56 /**57 * @cfg {Boolean} editable <tt>false</tt> to prevent the user from typing text directly into the field,58 * the field will only respond to a click on the trigger to set the value. (defaults to <tt>true</tt>).59 */60 editable: true,61 /**62 * @cfg {Boolean} readOnly <tt>true</tt> to prevent the user from changing the field, and63 * hides the trigger. Superceeds the editable and hideTrigger options if the value is true.64 * (defaults to <tt>false</tt>)65 */66 readOnly: false,67 /**68 * @cfg {String} wrapFocusClass The class added to the to the wrap of the trigger element. Defaults to69 * <tt>x-trigger-wrap-focus</tt>.70 */71 wrapFocusClass: 'x-trigger-wrap-focus',72 /**73 * @hide74 * @method autoSize75 */76 autoSize: Ext.emptyFn,77 // private78 monitorTab : true,79 // private80 deferHeight : true,81 // private82 mimicing : false,83 actionMode: 'wrap',84 defaultTriggerWidth: 17,85 // private86 onResize : function(w, h){87 Ext.form.TriggerField.superclass.onResize.call(this, w, h);88 var tw = this.getTriggerWidth();89 if(Ext.isNumber(w)){90 this.el.setWidth(w - tw);91 }92 this.wrap.setWidth(this.el.getWidth() + tw);93 },94 getTriggerWidth: function(){95 var tw = this.trigger.getWidth();96 if(!this.hideTrigger && tw === 0){97 tw = this.defaultTriggerWidth;98 }99 return tw;100 },101 // private102 alignErrorIcon : function(){103 if(this.wrap){104 this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);105 }106 },107 // private108 onRender : function(ct, position){109 this.doc = Ext.isIE ? Ext.getBody() : Ext.getDoc();110 Ext.form.TriggerField.superclass.onRender.call(this, ct, position);111 this.wrap = this.el.wrap({cls: 'x-form-field-wrap x-form-field-trigger-wrap'});112 this.trigger = this.wrap.createChild(this.triggerConfig ||113 {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.triggerClass});114 this.initTrigger();115 if(!this.width){116 this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());117 }118 this.resizeEl = this.positionEl = this.wrap;119 },120 updateEditState: function(){121 if(this.rendered){122 if (this.readOnly) {123 this.el.dom.readOnly = true;124 this.el.addClass('x-trigger-noedit');125 this.mun(this.el, 'click', this.onTriggerClick, this);126 this.trigger.setDisplayed(false);127 } else {128 if (!this.editable) {129 this.el.dom.readOnly = true;130 this.el.addClass('x-trigger-noedit');131 this.mon(this.el, 'click', this.onTriggerClick, this);132 } else {133 this.el.dom.readOnly = false;134 this.el.removeClass('x-trigger-noedit');135 this.mun(this.el, 'click', this.onTriggerClick, this);136 }137 this.trigger.setDisplayed(!this.hideTrigger);138 }139 this.onResize(this.width || this.wrap.getWidth());140 }141 },142 setHideTrigger: function(hideTrigger){143 if(hideTrigger != this.hideTrigger){144 this.hideTrigger = hideTrigger;145 this.updateEditState();146 }147 },148 /**149 * @param {Boolean} value True to allow the user to directly edit the field text150 * Allow or prevent the user from directly editing the field text. If false is passed,151 * the user will only be able to modify the field using the trigger. Will also add152 * a click event to the text field which will call the trigger. This method153 * is the runtime equivalent of setting the 'editable' config option at config time.154 */155 setEditable: function(editable){156 if(editable != this.editable){157 this.editable = editable;158 this.updateEditState();159 }160 },161 /**162 * @param {Boolean} value True to prevent the user changing the field and explicitly163 * hide the trigger.164 * Setting this to true will superceed settings editable and hideTrigger.165 * Setting this to false will defer back to editable and hideTrigger. This method166 * is the runtime equivalent of setting the 'readOnly' config option at config time.167 */168 setReadOnly: function(readOnly){169 if(readOnly != this.readOnly){170 this.readOnly = readOnly;171 this.updateEditState();172 }173 },174 afterRender : function(){175 Ext.form.TriggerField.superclass.afterRender.call(this);176 this.updateEditState();177 },178 // private179 initTrigger : function(){180 this.mon(this.trigger, 'click', this.onTriggerClick, this, {preventDefault:true});181 this.trigger.addClassOnOver('x-form-trigger-over');182 this.trigger.addClassOnClick('x-form-trigger-click');183 },184 // private185 onDestroy : function(){186 Ext.destroy(this.trigger, this.wrap);187 if (this.mimicing){188 this.doc.un('mousedown', this.mimicBlur, this);189 }190 delete this.doc;191 Ext.form.TriggerField.superclass.onDestroy.call(this);192 },193 // private194 onFocus : function(){195 Ext.form.TriggerField.superclass.onFocus.call(this);196 if(!this.mimicing){197 this.wrap.addClass(this.wrapFocusClass);198 this.mimicing = true;199 this.doc.on('mousedown', this.mimicBlur, this, {delay: 10});200 if(this.monitorTab){201 this.on('specialkey', this.checkTab, this);202 }203 }204 },205 // private206 checkTab : function(me, e){207 if(e.getKey() == e.TAB){208 this.triggerBlur();209 }210 },211 // private212 onBlur : Ext.emptyFn,213 // private214 mimicBlur : function(e){215 if(!this.isDestroyed && !this.wrap.contains(e.target) && this.validateBlur(e)){216 this.triggerBlur();217 }218 },219 // private220 triggerBlur : function(){221 this.mimicing = false;222 this.doc.un('mousedown', this.mimicBlur, this);223 if(this.monitorTab && this.el){224 this.un('specialkey', this.checkTab, this);225 }226 Ext.form.TriggerField.superclass.onBlur.call(this);227 if(this.wrap){228 this.wrap.removeClass(this.wrapFocusClass);229 }230 },231 beforeBlur : Ext.emptyFn,232 // private233 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.234 validateBlur : function(e){235 return true;236 },237 /**238 * The function that should handle the trigger's click event. This method does nothing by default239 * until overridden by an implementing function. See Ext.form.ComboBox and Ext.form.DateField for240 * sample implementations.241 * @method242 * @param {EventObject} e243 */244 onTriggerClick : Ext.emptyFn245 /**246 * @cfg {Boolean} grow @hide247 */248 /**249 * @cfg {Number} growMin @hide250 */251 /**252 * @cfg {Number} growMax @hide253 */254});255/**256 * @class Ext.form.TwinTriggerField257 * @extends Ext.form.TriggerField258 * TwinTriggerField is not a public class to be used directly. It is meant as an abstract base class259 * to be extended by an implementing class. For an example of implementing this class, see the custom260 * SearchField implementation here:261 * <a href="http://extjs.com/deploy/ext/examples/form/custom.html">http://extjs.com/deploy/ext/examples/form/custom.html</a>262 */263Ext.form.TwinTriggerField = Ext.extend(Ext.form.TriggerField, {264 /**265 * @cfg {Mixed} triggerConfig266 * <p>A {@link Ext.DomHelper DomHelper} config object specifying the structure of the trigger elements267 * for this Field. (Optional).</p>268 * <p>Specify this when you need a customized element to contain the two trigger elements for this Field.269 * Each trigger element must be marked by the CSS class <tt>x-form-trigger</tt> (also see270 * <tt>{@link #trigger1Class}</tt> and <tt>{@link #trigger2Class}</tt>).</p>271 * <p>Note that when using this option, it is the developer's responsibility to ensure correct sizing,272 * positioning and appearance of the triggers.</p>273 */274 /**275 * @cfg {String} trigger1Class276 * An additional CSS class used to style the trigger button. The trigger will always get the277 * class <tt>'x-form-trigger'</tt> by default and <tt>triggerClass</tt> will be <b>appended</b> if specified.278 */279 /**280 * @cfg {String} trigger2Class281 * An additional CSS class used to style the trigger button. The trigger will always get the282 * class <tt>'x-form-trigger'</tt> by default and <tt>triggerClass</tt> will be <b>appended</b> if specified.283 */284 initComponent : function(){285 Ext.form.TwinTriggerField.superclass.initComponent.call(this);286 this.triggerConfig = {287 tag:'span', cls:'x-form-twin-triggers', cn:[288 {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger1Class},289 {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger2Class}290 ]};291 },292 getTrigger : function(index){293 return this.triggers[index];294 },295 initTrigger : function(){296 var ts = this.trigger.select('.x-form-trigger', true);297 var triggerField = this;298 ts.each(function(t, all, index){299 var triggerIndex = 'Trigger'+(index+1);300 t.hide = function(){301 var w = triggerField.wrap.getWidth();302 this.dom.style.display = 'none';303 triggerField.el.setWidth(w-triggerField.trigger.getWidth());304 this['hidden' + triggerIndex] = true;305 };306 t.show = function(){307 var w = triggerField.wrap.getWidth();308 this.dom.style.display = '';309 triggerField.el.setWidth(w-triggerField.trigger.getWidth());310 this['hidden' + triggerIndex] = false;311 };312 if(this['hide'+triggerIndex]){313 t.dom.style.display = 'none';314 this['hidden' + triggerIndex] = true;315 }316 this.mon(t, 'click', this['on'+triggerIndex+'Click'], this, {preventDefault:true});317 t.addClassOnOver('x-form-trigger-over');318 t.addClassOnClick('x-form-trigger-click');319 }, this);320 this.triggers = ts.elements;321 },322 getTriggerWidth: function(){323 var tw = 0;324 Ext.each(this.triggers, function(t, index){325 var triggerIndex = 'Trigger' + (index + 1),326 w = t.getWidth();327 if(w === 0 && !this['hidden' + triggerIndex]){328 tw += this.defaultTriggerWidth;329 }else{330 tw += w;331 }332 }, this);333 return tw;334 },335 // private336 onDestroy : function() {337 Ext.destroy(this.triggers);338 Ext.form.TwinTriggerField.superclass.onDestroy.call(this);339 },340 /**341 * The function that should handle the trigger's click event. This method does nothing by default342 * until overridden by an implementing function. See {@link Ext.form.TriggerField#onTriggerClick}343 * for additional information.344 * @method345 * @param {EventObject} e346 */347 onTrigger1Click : Ext.emptyFn,348 /**349 * The function that should handle the trigger's click event. This method does nothing by default350 * until overridden by an implementing function. See {@link Ext.form.TriggerField#onTriggerClick}351 * for additional information.352 * @method353 * @param {EventObject} e354 */355 onTrigger2Click : Ext.emptyFn356});...

Full Screen

Full Screen

StimulusBuilder.py

Source:StimulusBuilder.py Github

copy

Full Screen

...38 if self.shared == 0:39 class empty_class: pass40 self.shared = empty_class4142 def add_trigger(self, t, message):43 self.parent.Trigger.add_trigger_event(t, 0.1, message)4445 def trigger_set_white(self):46 self.shared.trigger_state.value = 147 #return time.clock()48 return datetime.datetime.now()4950 def trigger_set_black(self):51 self.shared.trigger_state.value = 05253 def trigger_routine(self, time):5455 if self.first:56 if self.build_trigger: ...

Full Screen

Full Screen

Trigger.js

Source:Trigger.js Github

copy

Full Screen

1xdescribe("Ext.layout.component.field.Trigger", function(){2 var text, trigger, width, height;3 4 afterEach(function(){5 Ext.destroy(text, trigger);6 text = trigger = width = null;7 });8 9 describe("shrink wrap", function(){10 11 describe("without label", function() {12 13 it("should have the same size as a text field with a single trigger", function(){14 text = new Ext.form.field.Text({15 renderTo: Ext.getBody(),16 shrinkWrap: 317 });18 trigger = new Ext.form.field.Trigger({19 renderTo: Ext.getBody(),20 shrinkWrap: 321 });22 width = text.getWidth();23 24 expect(trigger.getWidth()).toBe(width);25 expect(trigger.inputEl.getWidth()).toBe(width - trigger.getTriggerWidth());26 });27 28 it("should have the same size as a text field with a 3 triggers", function(){29 text = new Ext.form.field.Text({30 renderTo: Ext.getBody(),31 shrinkWrap: 332 });33 trigger = new Ext.form.field.Trigger({34 renderTo: Ext.getBody(),35 shrinkWrap: 3,36 trigger1Cls: 'foo',37 trigger2Cls: 'bar',38 trigger3Cls: 'baz'39 });40 width = text.getWidth();41 42 expect(trigger.getWidth()).toBe(width);43 expect(trigger.inputEl.getWidth()).toBe(width - trigger.getTriggerWidth());44 });45 46 it("should respect an inputWidth", function(){47 trigger = new Ext.form.field.Trigger({48 renderTo: Ext.getBody(),49 shrinkWrap: 3,50 inputWidth: 20051 });52 expect(trigger.getWidth()).toBe(200);53 expect(trigger.inputEl.getWidth()).toBe(200 - trigger.getTriggerWidth());54 });55 });56 57 describe("with label", function(){58 59 describe("labelAlign: 'left'", function() {60 61 it("should take into account labelWidth", function(){62 text = new Ext.form.field.Text({63 renderTo: Ext.getBody(),64 shrinkWrap: 3,65 labelWidth: 150,66 fieldLabel: 'A label'67 });68 trigger = new Ext.form.field.Trigger({69 renderTo: Ext.getBody(),70 shrinkWrap: 3,71 labelWidth: 150,72 fieldLabel: 'A label'73 });74 width = text.getWidth();75 76 expect(trigger.getWidth()).toBe(width);77 expect(trigger.inputEl.getWidth()).toBe(width - trigger.getTriggerWidth() - trigger.labelWidth - trigger.labelPad);78 });79 80 it("should take into account labelPad", function(){81 text = new Ext.form.field.Text({82 renderTo: Ext.getBody(),83 shrinkWrap: 3,84 labelPad: 20,85 fieldLabel: 'A label'86 });87 trigger = new Ext.form.field.Trigger({88 renderTo: Ext.getBody(),89 shrinkWrap: 3,90 labelPad: 20,91 fieldLabel: 'A label'92 });93 width = text.getWidth();94 95 expect(trigger.getWidth()).toBe(width);96 expect(trigger.inputEl.getWidth()).toBe(width - trigger.getTriggerWidth() - trigger.labelWidth - trigger.labelPad);97 });98 });99 100 describe("labelAlign: 'top'", function(){101 it("should take ignore labelWidth", function(){102 text = new Ext.form.field.Text({103 renderTo: Ext.getBody(),104 shrinkWrap: 3,105 labelWidth: 150,106 fieldLabel: 'A label',107 labelAlign: 'top'108 });109 trigger = new Ext.form.field.Trigger({110 renderTo: Ext.getBody(),111 shrinkWrap: 3,112 labelWidth: 150,113 fieldLabel: 'A label',114 labelAlign: 'top'115 });116 width = text.getWidth();117 118 expect(trigger.getWidth()).toBe(width);119 expect(trigger.inputEl.getWidth()).toBe(width - trigger.getTriggerWidth());120 });121 122 it("should take into account labelPad", function(){123 text = new Ext.form.field.Text({124 renderTo: Ext.getBody(),125 shrinkWrap: 3,126 labelPad: 20,127 fieldLabel: 'A label',128 labelAlign: 'top'129 });130 trigger = new Ext.form.field.Trigger({131 renderTo: Ext.getBody(),132 shrinkWrap: 3,133 labelPad: 20,134 fieldLabel: 'A label',135 labelAlign: 'top'136 });137 width = text.getWidth();138 139 expect(trigger.getWidth()).toBe(width);140 expect(trigger.inputEl.getWidth()).toBe(width - trigger.getTriggerWidth());141 });142 });143 });144 145 });146 147 describe("configured", function() {148 describe("height", function() {149 beforeEach(function() {150 text = new Ext.form.field.Text({151 renderTo: Ext.getBody(),152 height: 200153 });154 trigger = new Ext.form.field.Trigger({155 renderTo: Ext.getBody(),156 height: 200157 });158 159 height = text.getHeight();160 });161 162 it("should have the same height as text field", function() {163 expect(trigger.getHeight()).toBe(height);164 // AND165 expect(trigger.inputEl.getHeight()).toBe(height);166 });167 });168 169 describe("width", function() {170 beforeEach(function() {171 text = new Ext.form.field.Text({172 renderTo: Ext.getBody(),173 width: 300174 });175 176 trigger = new Ext.form.field.Trigger({177 renderTo: Ext.getBody(),178 hideTrigger: true,179 width: 300180 });181 182 width = text.getWidth();183 });184 185 it("should have the same width as text field w/o trigger", function() {186 expect(trigger.getWidth()).toBe(width);187 // AND188 expect(trigger.inputEl.getWidth()).toBe(width);189 });190 191 it("should have the same overall width as text field w/ trigger", function() {192 var outerWidth = trigger.getWidth();193 194 expect(outerWidth).toBe(width);195 196 var inputWidth = trigger.inputEl.getWidth(),197 triggerWidth = 0;198 199 for (var i = 0, l = trigger.triggerEl.elements.length; i < l; i++) {200 var el = trigger.triggerEl.elements[i];201 202 triggerWidth += el.getWidth();203 }204 205 expect(inputWidth + triggerWidth).toBe(width);206 });207 });208 });...

Full Screen

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 locust 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