Best JavaScript code snippet using webdriverio-monorepo
deskConfig.js
Source:deskConfig.js  
1MyDesktop = new Ext.app.App({2    init :function(){3        Ext.QuickTips.init();4    },5    getModules : function(){		6        return [7        new MyDesktop.smimControlResidencia(),8        new MyDesktop.resFaseProceso(),9        new MyDesktop.StartMenuKardexTct(),10        new MyDesktop.resPersona(),11        new MyDesktop.StartMenuVehiculos(),12        new MyDesktop.StartMenuTct(),13        new MyDesktop.StartMenuMovilidad(),14        new MyDesktop.StartMenuMovilidadInterna(),15        new MyDesktop.StartMenuComite(),16        new MyDesktop.StartMenuSeguridad(),17        new MyDesktop.StartMenuItemConfiguracion(),18        new MyDesktop.StartMenuGestionEmpleo(),19        new MyDesktop.StartMenuDesarrolloHumano(),20        new MyDesktop.StartMenuJuridico(),21        new MyDesktop.StartMenuGerencial(),22        new MyDesktop.StartOffline(),23        new MyDesktop.mReporte()24        ];25    },26    getStartConfig : function(){		27        return {28            id:'lblBienvenido',29            title:'Bienvenido',30            iconCls:'iconPersona',31            toolItems: [{32                text:'Cambiar clave',33                iconCls:'iconClave',34                scope:this,35                handler:function(){36                    var tmpUserSession = new UserSession();37                    var tmpDlg = new DlgUsuarioAC(tmpUserSession);38                    tmpDlg.show();39                }40            },{41                text:'Preferencias',42                iconCls:'iconPrefs',43                scope:this,44                menu: {45                    items:[{46                        text: 'Formato de reportes',47                        scope: this,48                        menu:{49                            items:['<b class="menu-title">Escoja un formato de reporte</b>',50                            {51                                id:'miHtml',52                                text: 'Html(Pagina Web)',53                                iconCls:'',54                                checked:false,55                                group: 'formato',56                                handler: miFormatoHandler57                            },58                            {59                                id:'miPdf',60                                text: 'Adobe Pdf',61                                iconCls:'',62                                checked:true,63                                group: 'formato',64                                handler: miFormatoHandler65                            },66                            {67                                id:'miRtf',68                                text: 'Microsoft Word',69                                iconCls:'',70                                checked:false,71                                group: 'formato',72                                handler: miFormatoHandler73                            },74                            {75                                id:'miXls',76                                text: 'Microsoft Excel',77                                iconCls:'',78                                checked:false,79                                group: 'formato',80                                handler: miFormatoHandler81                            },82                            {83                                id:'miCsv',84                                text: 'Microsoft Excel(CSV)',85                                iconCls:'',86                                checked:false,87                                group: 'formato',88                                handler: miFormatoHandler89                            },90                            {91                                id:'miSwf',92                                text: 'Adobe Flash',93                                iconCls:'',94                                checked:false,95                                group: 'formato',96                                handler: miFormatoHandler97                            }98                            ]99                        }100                    }101                    ]102                }103            },{104                text:'Ayuda',105                iconCls:'iconAyuda',106                scope:this,107                menu: {108                    items:[{109                        text: 'Acerca de ..',110                        scope: this,111                        handler:function(){112                            var objAcerca = new FrmAcercade();113                            objAcerca.show();114                        }115                    }116                    ]117                }                118            },'-',{119                text:'Salir',120                iconCls:'iconSalir',121                scope:this,122                handler:function(){123                    Ext.MessageBox.confirm(APP_TITLE, 'Esta seguro que desea salir del sistema?', function(inBtn){124                        if (inBtn=="yes")125                            window.location=URL_LOGOUT;126                    });127                }128            }]129        }130    }131});132/**133 * Menu para creacion de submenus dentro del menu inicio de la aplicacion.134 */135MyDesktop.StartMenuItem = Ext.extend(Ext.app.Module, {136    init : function(){137        this.launcher = {138            text: 'Window hola',139            iconCls:'bogus'140        }141    },142    createWindow: function(src){143        var desktop = this.app.getDesktop();144        try{145            var win = desktop.getWindow('win'+src.windowId);146            if(!win){147                var param="(desktop";148                if (src.params)149                    for (var k=0;k<src.params.length;k++)150                        param+= ",\""+src.params[k]+"\"";151                param+=");"152                win = eval('new '+src.windowId+param);153                win.show();154            }else155                win.toFront();156        }catch(Exception){157            Ext.MessageBox.show({158                title:'Control de acceso',159                msg:'No tiene los permisos necesarios para hacer uso de este modulo.\nPor favor consulte con el Administrador del Sistema. '+Exception.message,160                icon:Ext.Msg.INFO,161                buttons:Ext.Msg.OK162            });163        }164    }165});166MyDesktop.resFaseProceso = Ext.extend(MyDesktop.StartMenuItem, {167    init : function(){168        this.launcher = {169            text: 'Administraci\u00f3n procesos',170            iconCls: 'iconProceso',171            handler: function() {172                return false;173            },174            menu: {175                items:[{176                    text: 'Definici\u00f3n de proceso',177                    iconCls:'bogus',178                    handler :this.createWindow,179                    scope: this,180                    windowId:'FrmCgg_res_fase_general'181                },182                {183                    text: 'Listado de fases',184                    iconCls:'iconListado',185                    handler :this.createWindow,186                    scope: this,187                    windowId:'FrmListadoCgg_res_fase'188                }189                ]190            }191        }192    }193});194MyDesktop.resPersona = Ext.extend(MyDesktop.StartMenuItem, {195    init : function(){196        this.launcher = {197            text: 'Administraci\u00F3n persona',198            iconCls: 'iconPersona',199            handler: function() {200                return false;201            },202            menu: {203                items:[{204                    text: 'Especialidad',205                    iconCls:'iconListado',206                    handler :this.createWindow,207                    scope: this,208                    windowId:'FrmListadoCgg_especialidad'209                },{210                    text: 'Instituci\u00f3n educativa',211                    iconCls:'iconListado',212                    handler :this.createWindow,213                    scope: this,214                    windowId:'FrmListadoCgg_institucion_educativa'215                },{216                    text: 'Modalidad curso',217                    iconCls:'iconListado',218                    handler :this.createWindow,219                    scope: this,220                    windowId:'FrmListadoCgg_modalidad_curso'221                },{222                    text: 'Nivel estudio',223                    iconCls:'iconListado',224                    handler : this.createWindow,225                    scope: this,226                    windowId:'FrmListadoCgg_nivel_estudio'227                },{228                    text: 'Perfil profesional',229                    iconCls:'bogus',230                    handler : this.createWindow,231                    scope: this,232                    windowId:'FrmListadoCgg_gem_perfil_prof'233                },{234                    text: 'Persona',235                    iconCls:'iconListado',236                    handler :this.createWindow,237                    scope: this,238                    windowId:'FrmListadoCgg_res_persona'239                },{240                    text: 'Registrar observado',241                    iconCls:'bogus',242                    handler : this.createWindow,243                    scope: this,244                    windowId:'FrmListadoCgg_res_observado'245                },{246                    text: 'Titulo profesional',247                    iconCls:'iconListado',248                    handler :this.createWindow,249                    scope: this,250                    windowId:'FrmListadoCgg_titulo_profesional'251                }252                ]253            }254        }255    }256});257MyDesktop.smimControlResidencia = Ext.extend(MyDesktop.StartMenuItem, {258    init : function(){259        this.launcher = {260            text: 'Control de residencia',261            iconCls: 'iconResidencia',262            handler: function() {263                return false;264            },265            menu: {266                items:[{267                    text: 'Listado de tr\u00E1mites',268                    iconCls:'iconListado',269                    handler :this.createWindow,270                    scope: this,271                    windowId:'FrmListadoCgg_res_tramite'272                },{273                    text: 'Listado de transe\u00fantes',274                    iconCls:'bogus',275                    handler:this.createWindow,276                    scope: this,277                    windowId:'FrmListadoCgg_res_transeunte'278                },{279                    text: 'Seguimiento de tr\u00E1mites',280                    iconCls: 'iconSeguimiento',281                    handler:this.createWindow,282                    scope: this,283                    windowId:'FrmListadoCgg_res_seguimiento'284                },{285                    text: 'Historial de tr\u00e1mite',286                    iconCls:'iconHistorial',287                    handler :this.createWindow,288                    scope: this,289                    windowId:'FrmHistorialTramite'290                },{291                    text: 'Historial de persona',292                    iconCls:'iconHistorialPersona',293                    handler:this.createWindow,294                    scope: this,295                    windowId:'FrmCgg_res_persona_historial'296                },{297                    text: 'Informaci\u00f3n documental',298                    iconCls:'iconListado',299                    handler :this.createWindow,300                    scope: this,301                    windowId:'FrmListadoCgg_res_adjunto'302                },{303                    text: 'Comunicaciones',304                    iconCls:'iconListado',305                    handler :this.createWindow,306                    scope: this,307                    windowId:'FrmListadoCgg_res_comunicado'308                },{309                    text: 'Notificaciones',310                    iconCls:'bogus',311                    handler:this.createWindow,312                    scope: this,313                    windowId:'FrmListadoCgg_res_notificacion'314                },{315                    text: 'Denuncias',316                    iconCls:'bogus',317                    handler:this.createWindow,318                    scope: this,319                    params: [TypeDenuncia.RESIDENCIA],320                    windowId:'FrmListadoCgg_res_denuncia'321                },{322                    text: 'Archivo',323                    iconCls:'bogus',324                    handler:this.createWindow,325                    scope: this,326                    windowId:'FrmListadoCgg_res_prestamo_expediente'327                },{328                    text: 'Carnetizaci\u00f3n',329                    iconCls:'bogus',330                    handler:this.createWindow,331                    scope: this,332                    windowId:'FrmListadoCgg_res_carnet'333                },{334                    text: 'Usuarios',335                    iconCls:'bogus',336                    handler:this.createWindow,337                    scope: this,338                    windowId:'FrmAdministradorPersonaUsuario'339                },{340                    text: 'Dep\u00F3sito de garant\u00EDa',341                    iconCls:'bogus',342                    handler : this.createWindow,343                    scope: this,344                    windowId:'FrmListadoCgg_res_deposito_garantia'345                },'-',{346                    text: 'Operativos de seguimiento',347                    iconCls: 'iconOperativo',348                    handler: function() {349                        return false;350                    },351                    menu: {352                        items:[{353                            text: 'Matrimonio',354                            iconCls:'bogus',355                            handler:this.createWindow,356                            scope: this,357                            windowId:'FrmListadoCgg_res_matrimonio'358                        },{359                            text: 'Oficiales de Seguimiento',360                            iconCls:'bogus',361                            handler:this.createWindow,362                            scope: this,363                            windowId:'FrmListadoCgg_res_oficial_seguimiento'364                        }]365                    }366                }367                ]368            }369        }370    }371});372/**373 * Mene item. Menu de configuracion de valores del SIICGG374 */375MyDesktop.StartMenuItemConfiguracion = Ext.extend(MyDesktop.StartMenuItem, {376    init : function(){377        this.launcher = {378            text: 'Configuraci\u00F3n',379            iconCls: 'iconConfiguracion',380            handler: function() {381                return false;382            },383            menu: {384                items:[{385                    text:"Administraci\u00F3n de residencia",386                    iconCls:'bogus',387                    menu:{388                        items:[{389                            text: 'Administraci\u00F3n requisitos tr\u00E1mites residencia',390                            iconCls:'bogus',391                            handler: this.createWindow,392                            scope: this,393                            windowId:'FrmListadoCgg_res_requisito'394                        },{395                            text: 'Administraci\u00F3n tipo notificaci\u00F3n',396                            iconCls:'bogus',397                            handler:this.createWindow,398                            scope: this,399                            windowId:'FrmListadoCgg_res_tipo_notificacion'400                        },{401                            text: 'Administraci\u00F3n garant\u00EDa',402                            iconCls:'bogus',403                            handler : this.createWindow,404                            scope: this,405                            windowId:'FrmListadoCgg_res_garantia'406                        },{407                            text: 'Administraci\u00F3n de tipo de solicitud tr\u00E1mite',408                            iconCls:'bogus',409                            handler : this.createWindow,410                            scope: this,411                            windowId:'FrmListadoCgg_res_tipo_solicitud_tramite'412                        },{413                            text: 'Administraci\u00F3n estado tr\u00E1mite',414                            iconCls:'bogus',415                            handler:this.createWindow,416                            scope: this,417                            windowId:'FrmListadoCgg_res_estado_tramite'418                        },{419                            text: 'Administraci\u00F3n tipos de tr\u00E1mites',420                            iconCls:'bogus',421                            handler: this.createWindow,422                            scope: this,423                            windowId:'FrmListadoCgg_res_tipo_tramite'424                        }425                        ]426                    }427                },{428                    text:"Distribuci\u00f3n geográfica",429                    iconCls:'bogus',430                    menu:{431                        items:[{432                            text: 'Administraci\u00f3n de pa\u00EDs',433                            iconCls:'bogus',434                            handler : this.createWindow,435                            scope: this,436                            windowId:'FrmListadoCgg_pais'437                        },{438                            text: 'Administraci\u00f3n de provincia',439                            iconCls:'bogus',440                            handler:this.createWindow,441                            scope: this,442                            windowId:'FrmListadoCgg_provincia'443                        },{444                            text: 'Administraci\u00f3n de cant\u00f3n',445                            iconCls:'bogus',446                            handler : this.createWindow,447                            scope: this,448                            windowId:'FrmListadoCgg_canton'449                        },{450                            text: 'Administraci\u00f3n de parroquias',451                            iconCls:'bogus',452                            handler : this.createWindow,453                            scope: this,454                            windowId:'FrmListadoCgg_parroquia'455                        },{456                            text: 'Administraci\u00f3n de isla',457                            iconCls:'bogus',458                            handler : this.createWindow,459                            scope: this,460                            windowId:'FrmListadoCgg_isla'461                        }]462                    }463                },{464                    text:"Distribuci\u00f3n departamental",465                    iconCls:'bogus',466                    menu:{467                        items:[{468                            text: 'Administraci\u00F3n cargo',469                            iconCls:'bogus',470                            handler:this.createWindow,471                            scope: this,472                            windowId:'FrmListadoCgg_res_cargo'473                        },{474                            text: 'Administraci\u00F3n seccion',475                            iconCls:'bogus',476                            handler:this.createWindow,477                            scope: this,478                            windowId:'FrmListadoCgg_res_seccion'479                        }480                        ]481                    }482                },{483                    text:'Administraci\u00f3n de persona',484                    iconCls:'bogus',485                    menu:{486                        items:[{487                            text: 'Administraci\u00f3n de estado civil',488                            iconCls:'bogus',489                            handler:this.createWindow,490                            scope: this,491                            windowId:'FrmListadoCgg_res_estado_civil'492                        },{493                            text: 'Administraci\u00F3n de tipo contacto',494                            iconCls:'bogus',495                            handler:this.createWindow,496                            scope: this,497                            windowId:'FrmListadoCgg_res_tipo_contacto'498                        },{499                            text: 'Administraci\u00f3n de tipo sanguineo',500                            iconCls:'bogus',501                            handler:this.createWindow,502                            scope: this,503                            windowId:'FrmListadoCgg_res_tipo_sanguineo'504                        },{505                            text: 'Administraci\u00f3n de nacionalidad',506                            iconCls:'bogus',507                            handler:this.createWindow,508                            scope: this,509                            windowId:'FrmListadoCgg_nacionalidad'510                        },{511                            text: 'Administraci\u00f3n de documentos',512                            iconCls:'bogus',513                            handler:this.createWindow,514                            scope: this,515                            windowId:'FrmListadoCgg_res_documento_identificacio'516                        },{517                            text:'Idiomas',518                            iconCls:'bogus',519                            handler:this.createWindow,520                            scope:this,521                            windowId:'FrmListadoCgg_gem_idioma'522                        },'-',{523                            text: 'Administraci\u00f3n de persona jur\u00EDdica',524                            iconCls:'bogus',525                            handler:this.createWindow,526                            scope: this,527                            windowId:'FrmListadoCgg_res_persona_juridica'528                        }529                        ]530                    }531                },{532                    text:"Listados adicionales",533                    iconCls:'bogus',534                    menu:{535                        items:[{536                            text: 'Administraci\u00f3n de Procesos',537                            iconCls:'bogus',538                            handler : this.createWindow,539                            scope: this,540                            windowId:'FrmListadoCgg_res_proceso'541                        },{542                            text: 'Administraci\u00F3n criterio de fase',543                            iconCls:'bogus',544                            handler:this.createWindow,545                            scope: this,546                            windowId:'FrmListadoCgg_jur_criterio'547                        },{548                            text: 'Administraci\u00f3n veh\u00EDculo sector',549                            iconCls:'bogus',550                            handler:this.createWindow,551                            scope: this,552                            windowId:'FrmListadoCgg_veh_sector'553                        }]554                    }555                },{556                    text:"Control de informaci\u00f3n",557                    iconCls:'iconRegla',558                    menu:{559                        items:[{560                            text: 'Administraci\u00F3n de validaci\u00F3nes',561                            iconCls:'bogus',562                            handler:this.createWindow,563                            scope: this,564                            windowId:'FrmListadoCgg_regla_validacion'565                        },566                        {567                            text: 'Administraci\u00F3n de operaciones de validaci\u00F3n',568                            iconCls:'bogus',569                            handler:this.createWindow,570                            scope: this,571                            windowId:'FrmListadoCgg_operacion_validacion'572                        }]573                    }574                },{575                    text:"Sitio Web",576                    iconCls:'bogus',577                    menu:{578                        items:[{579                            text: 'Administraci\u00F3n de p\u00E1ginas',580                            iconCls:'bogus',581                            handler:this.createWindow,582                            scope: this,583                            windowId:'FrmListadoCgg_web_pagina'584                        },'-',585                        {586                            text: 'Administraci\u00F3n de frases de bienvenida',587                            iconCls:'bogus',588                            handler:this.createWindow,589                            scope: this,590                            windowId:'FrmListadoCgg_web_frase_bienvenida'591                        },'-',{592                            text:'Administraci\u00F3n de m\u00F3dulos',593                            iconCls:'bogus',594                            handler:this.createWindow,595                            scope:this,596                            windowId:'FrmListadoCgg_web_modulo'597                        },{598                            text:'Administraci\u00F3n de agencias',599                            iconCls:'bogus',600                            handler:this.createWindow,601                            scope:this,602                            windowId:'FrmListadoCgg_web_agencia'603                        },{604                            text:'Contactos Agencias',605                            iconCls:'bogus',606                            handler:this.createWindow,607                            scope:this,608                            windowId:'FrmListadoCgg_res_agencia_contacto'609                        }]610                    }611                },{612                    text: 'Administraci\u00f3n de Archivos',613                    iconCls:'iconAdjunto',614                    handler :this.createWindow,615                    scope:this,616                    windowId:'FrmListadoCgg_ecm_archivo'617                },{618                    text: 'Administraci\u00f3n sector productivo',619                    iconCls:'bogus',620                    handler:this.createWindow,621                    scope: this,622                    windowId:'FrmListadoCgg_sector_productivo'623                },{624                    text: 'Administraci\u00F3n par\u00E1metros configuraci\u00f3n',625                    iconCls:'iconConfiguracion',626                    handler:this.createWindow,627                    scope: this,628                    windowId:'FrmListadoCgg_configuracion'629                },{630                    text: 'Servicio de notificaciones',631                    iconCls:'iconMegafono',632                    handler:this.createWindow,633                    scope: this,634                    windowId:'FrmListadoCgg_buzon_correo'635                },'-',{636                    text: 'Reportes del sistema',                   637                    handler:this.createWindow,638                    scope: this,639                    windowId:'FrmListadoCgg_sec_reporte'640                }641                ]642            }643        }644    }645});646MyDesktop.resSeguimiento = Ext.extend(MyDesktop.StartMenuItem, {647    init : function(){648        this.launcher = {649            650            651            handler: function() {652                return false;653            },654            menu: {655                items:[656            ]657            }658        }659    }660});661/**662 * Menu item. Menu de Vehiculos663 */664MyDesktop.StartMenuVehiculos = Ext.extend(MyDesktop.StartMenuItem, {665    init : function(){666        this.launcher = {667            text: 'Veh\u00edculos',668            iconCls: 'iconVehiculos',669            handler: function() {670                return false;671            },672            menu: {673                items:[{674                    text:'Seguimiento de tr\u00e1mites',675                    iconCls:'bogus',676                    handler:this.createWindow,677                    scope: this,678                    windowId:'FrmListadoCgg_res_seguimiento_vehiculo'679                },{680                    text: 'Estados',681                    iconCls:'bogus',682                    handler:this.createWindow,683                    scope: this,684                    windowId:'FrmListadoCgg_veh_estado_vhmt'685                },{686                    text: 'Combustible',687                    iconCls:'bogus',688                    handler:this.createWindow,689                    scope: this,690                    windowId:'FrmListadoCgg_veh_combustible'691                },{692                    text: 'Motores',693                    iconCls:'bogus',694                    handler:this.createWindow,695                    scope: this,696                    windowId:'FrmListadoCgg_veh_motor'697                },{698                    text: 'Cilindraje',699                    iconCls:'bogus',700                    handler :this.createWindow,701                    scope: this,702                    windowId:'FrmListadoCgg_veh_cilindraje'703                },{704                    text: 'Marcas',705                    iconCls:'bogus',706                    handler :this.createWindow,707                    scope: this,708                    windowId:'FrmListadoCgg_veh_marca'709                },{710                    text: 'Color',711                    iconCls:'bogus',712                    handler:this.createWindow,713                    scope: this,714                    windowId:'FrmListadoCgg_veh_color'715                },{716                    text: 'Categorias',717                    iconCls:'bogus',718                    handler:this.createWindow,719                    scope: this,720                    windowId:'FrmListadoCgg_veh_categoria'721                },{722                    text: 'Veh\u00edculos',723                    iconCls:'bogus',724                    handler :this.createWindow,725                    scope:this,726                    windowId:'FrmListadoCgg_veh_vehiculo'727                }]728            }729        }730    }731});732/**733 * Menu item. Menu de configuracion de valores del SIICGG734 */735MyDesktop.StartMenuComite = Ext.extend(MyDesktop.StartMenuItem, {736    init : function(){737        this.launcher = {738            text: 'Comit\u00e9',739            iconCls: 'iconComite',740            handler: function() {741                return false;742            },743            menu: {744                items:[{745                    text: 'Comit\u00e9',746                    iconCls:'bogus',747                    handler :this.createWindow,748                    scope: this,749                    windowId:'FrmListadoCgg_res_comite'750                },{751                    text: 'Cargo de Comit\u00e9',752                    iconCls:'bogus',753                    handler:this.createWindow,754                    scope: this,755                    windowId:'FrmListadoCgg_res_cargo_comite'756                },{757                    text: 'Miembros de Comit\u00e9',758                    iconCls:'bogus',759                    handler:this.createWindow,760                    scope: this,761                    windowId:'FrmListadoCgg_res_miembro_comite'762                },{763                    text: 'Sesi\u00f3n de Comit\u00e9',764                    iconCls:'bogus',765                    handler:this.createWindow,766                    scope: this,767                    windowId:'FrmListadoCgg_res_sesion_comite'768                },{769                    text: 'Asistencia a sesi\u00F3n Comit\u00e9',770                    iconCls:'bogus',771                    handler :this.createWindow,772                    scope: this,773                    windowId:'FrmListadoCgg_res_sesion_miembro'774                },{775                    text: 'Resoluciones',776                    iconCls:'bogus',777                    handler :this.createWindow,778                    scope:this,779                    windowId:'FrmListadoCgg_res_resolucion'780                },{781                    text: 'Voto',782                    iconCls:'bogus',783                    handler : this.createWindow,784                    scope:this,785                    windowId:'FrmListadoCgg_res_voto'786                },{787                    text: 'Voto Administrador',788                    iconCls:'bogus',789                    handler : this.createWindow,790                    scope:this,791                    windowId:'FrmListadoCgg_res_voto_administrador'792                }]793            }794        }795    }796});797/**798 * Menu item. Menu de configuracion de valores del SIICGG799 */800MyDesktop.StartMenuSeguridad = Ext.extend(MyDesktop.StartMenuItem, {801    init : function(){802        this.launcher = {803            text: 'Seguridad',804            iconCls: 'iconSeguridad',805            handler: function() {806                return false;807            },808            menu: {809                items:[{810                    text: 'Privilegios',811                    iconCls:'bogus',812                    handler:this.createWindow,813                    scope: this,814                    windowId:'FrmListadoCgg_sec_objeto_rol'815                },{816                    text: 'Perfiles',817                    iconCls:'bogus',818                    handler:this.createWindow,819                    scope: this,820                    windowId:'FrmListadoCgg_sec_usuario_rol'821                },{822                    text: 'Objetos',823                    iconCls:'bogus',824                    handler : this.createWindow,825                    scope: this,826                    windowId:'FrmListadoCgg_sec_objeto'827                },{828                    text: 'Roles',829                    iconCls:'bogus',830                    handler : this.createWindow,831                    scope: this,832                    windowId:'FrmListadoCgg_sec_rol'833                },{834                    text: 'Sustitucion',835                    iconCls:'bogus',836                    handler : this.createWindow,837                    scope:this,838                    windowId:'FrmListadoCgg_sustitucion'839                },{840                    text: 'Usuario',841                    iconCls:'bogus',842                    handler:this.createWindow,843                    scope:this,844                    windowId:'FrmListadoCgg_usuario'845                },{846                    text: 'Sesiones',847                    iconCls:'bogus',848                    handler:this.createWindow,849                    scope:this,850                    windowId:'FrmListadoCgg_sec_sesion'851                }]852            }853        }854    }855});856/**857 * Menu item. Menu de configuracion de valores del SIICGG858 */859MyDesktop.StartMenuTct = Ext.extend(MyDesktop.StartMenuItem, {860    init : function(){861        this.launcher = {862            text: 'TCT',863            iconCls: 'iconTCT',864            handler: function() {865                return false;866            },867            menu: {868                items:[{869                    text: 'Aerolinea',870                    iconCls:'bogus',871                    handler:this.createWindow,872                    scope: this,873                    windowId:'FrmListadoCgg_res_aerolinea'874                },{875                    text: 'Aeropuerto',876                    iconCls:'bogus',877                    handler:this.createWindow,878                    scope: this,879                    windowId:'FrmListadoCgg_res_aeropuerto'880                },{881                    text: 'Actividad',882                    iconCls:'bogus',883                    handler:this.createWindow,884                    scope: this,885                    windowId:'FrmListadoCgg_tct_actividad'886                },{887                    text: 'Registro TCT',888                    iconCls:'bogus',889                    handler :this.createWindow,890                    scope: this,891                    windowId:'FrmListadoCgg_tct_registro'892                },{893                    text: 'Tipo Hospedaje',894                    iconCls:'bogus',895                    handler:this.createWindow,896                    scope: this,897                    windowId:'FrmListadoCgg_tct_tipo_hospedaje'898                },{899                    text: 'Ingreso fallido',900                    iconCls:'bogus',901                    handler:this.createWindow,902                    scope: this,903                    windowId:'FrmListadoCgg_tct_ingreso_fallido'904                }905                ]906            }907        }908    }909});910/**911 * Menu item. Menu de configuracion de valores del SIICGG912 */913MyDesktop.StartMenuMovilidad = Ext.extend(MyDesktop.StartMenuItem, {914    init : function(){915        this.launcher = {916            text: 'Movilidad',917            iconCls: 'iconTCT',918            handler: function() {919                return false;920            },921            menu: {922                items:[{923                    text: 'Forma Salida',924                    iconCls:'bogus',925                    handler :this.createWindow,926                    scope: this,927                    windowId:'FrmListadoCgg_tct_forma_salida'928                },{929                    text:"Movimiento Turistas/Transeuntes",930                    iconCls:'iconMovilidad',931                    handler :this.createWindow,932                    scope: this,933                    windowId:'FrmListadoCgg_res_movilidad'934                },{935                    text: 'Movimiento Residentes',936                    iconCls:'bogus',937                    handler:this.createWindow,938                    scope: this,939                    windowId:'FrmListadoCgg_res_movilidad_residentes'940                },{941                    text: 'Expulsion',942                    iconCls:'bogus',943                    handler:this.createWindow,944                    scope: this,945                    windowId:'FrmListadoCgg_res_expulsion'946                }]947            }948        }949    }950});951/**952 * Menu item. Menu de configuracion de valores del SIICGG953 */954MyDesktop.StartMenuMovilidadInterna = Ext.extend(MyDesktop.StartMenuItem, {955    init : function(){956        this.launcher = {957            text: 'Movilidad Interna',958            iconCls: 'iconTCT',959            handler: function() {960                return false;961            },962            menu: {963                items:[{964                    text: 'Movilidad Interna',965                    iconCls:'bogus',966                    handler :this.createWindow,967                    scope: this,968                    windowId:'FrmListadoCgg_res_movilidad_interna'969                },{970                    text: 'Muelle',971                    iconCls:'bogus',972                    handler :this.createWindow,973                    scope: this,974                    windowId:'FrmListadoCgg_res_muelle'975                },{976                    text:"Embarcaci\u00f3n",977                    iconCls:'bogus',978                    handler :this.createWindow,979                    scope: this,980                    windowId:'FrmListadoCgg_res_embarcacion'981                }]982            }983        }984    }985});986/**987 * Menu item. Menu de Gestion de empleo988 */989MyDesktop.StartMenuGestionEmpleo = Ext.extend(MyDesktop.StartMenuItem, {990    init : function(){991        this.launcher = {992            text: 'Gestión de empleo',993            iconCls: 'iconGestionEmpleo',994            handler: function() {995                return false;996            },997            menu: {998                items:[/*{999                 text:'Solicitud de clave',1000                 iconCls:'bogus',1001                 handler:this.createWindow,1002                 scope:this,1003                 windowId:'FrmListadoCgg_gem_area_funcional'1004                 },*/{1005                    text:'Ofertas vacantes',1006                    iconCls:'bogus',1007                    handler:this.createWindow,1008                    scope:this,1009                    windowId:'FrmListadoCgg_gem_vacante'1010                },{1011                    text:'Administraci\u00F3n busqueda perf\u00EDl',1012                    iconCls:'bogus',1013                    handler:this.createWindow,1014                    scope:this,1015                    windowId:'FrmListadoCgg_gem_busqueda_perfil',1016                    params: [false]1017                },{1018                    text:'Administraci\u00F3n de Empresas',1019                    iconCls:'bogus',1020                    handler:this.createWindow,1021                    scope:this,1022                    windowId:'FrmListadoCgg_gem_empresa'1023                },"-",{1024                    text:'Administraci\u00F3n de destrezas',1025                    iconCls:'bogus',1026                    handler:this.createWindow,1027                    scope:this,1028                    windowId:'FrmListadoCgg_gem_destreza'1029                },"-",{1030                    text: 'Denuncias de gesti\u00F3n de empleo',1031                    iconCls:'bogus',1032                    handler:this.createWindow,1033                    scope: this,1034                    params: [TypeDenuncia.GESTIONEMPLEO],1035                    windowId:'FrmListadoCgg_res_denuncia'1036                },"-",{1037                    text: 'Administrac\u00f3n preguntas frecuentes',1038                    iconCls:'bogus',1039                    handler:this.createWindow,1040                    scope: this,1041                    windowId:'FrmListadoCgg_web_preguntas'1042                },1043                {1044                    text:"Configuraci\u00F3n",1045                    iconCls:'iconConfiguracion',1046                    menu:{1047                        items:[{1048                            text:'Area funcional',1049                            iconCls:'bogus',1050                            handler:this.createWindow,1051                            scope:this,1052                            windowId:'FrmListadoCgg_gem_area_funcional'1053                        },{1054                            text:'Cargos',1055                            iconCls:'bogus',1056                            handler:this.createWindow,1057                            scope:this,1058                            windowId:'FrmListadoCgg_gem_cargo'1059                        },{1060                            text:'Tipos de contratos',1061                            iconCls:'bogus',1062                            handler:this.createWindow,1063                            scope:this,1064                            windowId:'FrmListadoCgg_gem_tipo_contrato'1065                        },{1066                            text:'Tipos de salarios',1067                            iconCls:'bogus',1068                            handler:this.createWindow,1069                            scope:this,1070                            windowId:'FrmListadoCgg_gem_tipo_salario'1071                        },{1072                            text:'Administraci\u00F3n de destrezas',1073                            iconCls:'bogus',1074                            handler:this.createWindow,1075                            scope:this,1076                            windowId:'FrmListadoCgg_gem_destreza'1077                        }]1078                    }1079                }]1080            }1081        }1082    }1083});1084/**1085 * Menu item. Menu de Kardex TCT1086 */1087MyDesktop.StartMenuKardexTct = Ext.extend(MyDesktop.StartMenuItem, {1088    init : function(){1089        this.launcher = {1090            text: 'Kardex',1091            iconCls: 'iconTCT',1092            handler: function() {1093                return false;1094            },1095            menu: {1096                items:[{1097                    text:'Punto de venta',1098                    iconCls:'bogus',1099                    handler:this.createWindow,1100                    scope:this,1101                    windowId:'FrmListadoCgg_kdx_punto_venta'1102                },{1103                    text: 'Tipo de pago',1104                    iconCls:'bogus',1105                    handler:this.createWindow,1106                    scope: this,1107                    windowId:'FrmListadoCgg_kdx_tipo_pago'1108                },{1109                    text: 'Denominaciones',1110                    iconCls:'bogus',1111                    handler:this.createWindow,1112                    scope: this,1113                    windowId:'FrmListadoCgg_kdx_denominacion'1114                },{1115                    text: 'Transferencia',1116                    iconCls:'bogus',1117                    handler:this.createWindow,1118                    scope: this,1119                    windowId:'FrmListadoCgg_kdx_transferencia'1120                },{1121                    text: 'Transferencia punto de venta',1122                    iconCls:'bogus',1123                    handler:this.createWindow,1124                    scope: this,1125                    windowId:'FrmListadoCgg_kdx_transferencia_pv'1126                },{1127                    text: 'Asignaci\u00f3n',1128                    iconCls:'bogus',1129                    handler:this.createWindow,1130                    scope: this,1131                    windowId:'FrmListadoCgg_kdx_asignacion'1132                },1133                {1134                    text: 'Stock de asignaciones',1135                    iconCls:'bogus',1136                    handler:this.createWindow,1137                    scope: this,1138                    windowId:'FrmListadoCgg_kdx_asignacion_stock'1139                },{1140                    text: 'Ingresos',1141                    iconCls:'bogus',1142                    handler :this.createWindow,1143                    scope: this,1144                    windowId:'FrmListadoCgg_kdx_compra'1145                },{1146                    text: 'Ventas',1147                    iconCls:'bogus',1148                    handler:this.createWindow,1149                    scope: this,1150                    windowId:'FrmListadoCgg_kdx_venta'1151                },{1152                    text: 'Cierre caja',1153                    iconCls:'bogus',1154                    handler:this.createWindow,1155                    scope: this,1156                    windowId:'FrmListadoCgg_kdx_cierre'1157                },{1158                    text: 'Kardex',1159                    iconCls:'bogus',1160                    handler:this.createWindow,1161                    scope: this,1162                    windowId:'FrmListadoCgg_kdx_kardex'1163                },{1164                    text: 'Tipos de especies',1165                    iconCls:'bogus',1166                    handler:this.createWindow,1167                    scope: this,1168                    windowId:'FrmListadoCgg_kdx_especie'1169                }, {1170                    text: 'Anulaci\u00f3n especie',1171                    iconCls:'bogus',1172                    handler:this.createWindow,1173                    scope: this,1174                    windowId:'FrmListadoCgg_kdx_anulacion'1175                }]1176            }1177        }1178    }1179});1180/**1181 * Menu item. Menu de Desarrollo Humano1182 */1183MyDesktop.StartMenuDesarrolloHumano = Ext.extend(MyDesktop.StartMenuItem, {1184    init : function(){1185        this.launcher = {1186            text: 'Desarrollo Humano',1187            iconCls: 'iconDesHumano',1188            handler: function() {1189                return false;1190            },1191            menu: {1192                items:[{1193                    text:"Administraci\u00f3n de Beca",1194                    iconCls:'bogus',1195                    menu:{1196                        items:[{1197                            text: 'Registro beca',1198                            iconCls:'bogus',1199                            handler:this.createWindow,1200                            scope: this,1201                            windowId:'FrmListadoCgg_dhu_beca'1202                        },{1203                            text: 'Seguimiento Acad\u00e9mico',1204                            iconCls:'bogus',1205                            handler:this.createWindow,1206                            scope: this,1207                            windowId:'FrmListadoCgg_dhu_seguimiento_academico'1208                        },{1209                            text: 'Seguimiento Econ\u00f3mico',1210                            iconCls:'bogus',1211                            handler:this.createWindow,1212                            scope: this,1213                            windowId:'FrmListadoCgg_dhu_seguimiento_economico'1214                        },{1215                            text: 'Seguimiento Profesional',1216                            iconCls:'bogus',1217                            handler:this.createWindow,1218                            scope: this,1219                            windowId:'FrmListadoCgg_dhu_seguimiento_profesional'1220                        },{1221                            text:"Configuraci\u00f3n",1222                            iconCls:'bogus',1223                            menu:{1224                                items:[1225                                {1226                                    text: 'Concepto desembolso',1227                                    iconCls:'bogus',1228                                    handler :this.createWindow,1229                                    scope: this,1230                                    windowId:'FrmListadoCgg_dhu_tipo_concepto'1231                                },{1232                                    text: 'Beca Certificado',1233                                    iconCls:'bogus',1234                                    handler:this.createWindow,1235                                    scope: this,1236                                    windowId:'FrmListadoCgg_dhu_beca_certificado'1237                                }, '-',{1238                                    text: 'Tipo de beca',1239                                    iconCls:'bogus',1240                                    handler:this.createWindow,1241                                    scope: this,1242                                    windowId:'FrmListadoCgg_dhu_tipo_beca'1243                                },{1244                                    text: 'Tipo Certificado',1245                                    iconCls:'bogus',1246                                    handler:this.createWindow,1247                                    scope: this,1248                                    windowId:'FrmListadoCgg_dhu_tipo_cacademico'1249                                } ]1250                            }1251                        }]1252                    }1253                },{1254                    text:"Administraci\u00f3n de Curso",1255                    iconCls:'bogus',1256                    menu:{1257                        items:[{1258                            text: 'Cursos',1259                            iconCls:'bogus',1260                            handler:this.createWindow,1261                            scope: this,1262                            windowId:'FrmListadoCgg_dhu_curso'1263                        },{1264                            text:"Asistentes curso",1265                            iconCls:'bogus',1266                            menu:{1267                                items:[1268                                {1269                                    text: 'Registro asistente',1270                                    iconCls:'bogus',1271                                    handler:this.createWindow,1272                                    scope: this,1273                                    windowId:'FrmListadoCgg_dhu_asistente_curso'1274                                }1275                                ]1276                            }1277                        },{1278                            text:"Configuraci\u00f3n",1279                            iconCls:'bogus',1280                            menu:{1281                                items:[1282                                {1283                                    text: 'Tipo de curso',1284                                    iconCls:'bogus',1285                                    handler:this.createWindow,1286                                    scope: this,1287                                    windowId:'FrmListadoCgg_dhu_tipo_curso'1288                                },{1289                                    text: 'Instituci\u00F3n',1290                                    iconCls:'bogus',1291                                    handler:this.createWindow,1292                                    scope: this,1293                                    windowId:'FrmListadoCgg_dhu_institucion_responsable'1294                                }1295                                ]1296                            }1297                        },{1298                            text:"Encuestas",1299                            iconCls:'bogus',1300                            menu:{1301                                items:[ {1302                                    text: 'Categor\u00EDa',1303                                    iconCls:'bogus',1304                                    handler:this.createWindow,1305                                    scope: this,1306                                    windowId:'FrmListadoCgg_dhu_categoria'1307                                }, {1308                                    text: 'Pregunta',1309                                    iconCls:'bogus',1310                                    handler:this.createWindow,1311                                    scope: this,1312                                    windowId:'FrmListadoCgg_dhu_pregunta'1313                                },1314                                {1315                                    text: 'Respuesta',1316                                    iconCls:'bogus',1317                                    handler:this.createWindow,1318                                    scope: this,1319                                    windowId:'FrmListadoCgg_dhu_respuesta'1320                                },1321                                {1322                                    text: 'Pregunta / Respuesta',1323                                    iconCls:'bogus',1324                                    handler:this.createWindow,1325                                    scope: this,1326                                    windowId:'FrmListadoCgg_dhu_pregunta_respuesta'1327                                }, {1328                                    text: 'Encuesta',1329                                    iconCls:'bogus',1330                                    handler:this.createWindow,1331                                    scope: this,1332                                    windowId:'FrmListadoCgg_dhu_encuesta'1333                                },1334                                {1335                                    text: 'Cuestionario',1336                                    iconCls:'bogus',1337                                    handler:this.createWindow,1338                                    scope: this,1339                                    windowId:'FrmListadoCgg_dhu_cuestionario'1340                                },1341                                {1342                                    text: 'Cronograma Encuesta',1343                                    iconCls:'bogus',1344                                    handler:this.createWindow,1345                                    scope: this,1346                                    windowId:'FrmListadoCgg_dhu_cronograma_encuesta'1347                                },1348                                {1349                                    text: 'Aplicaci\u00F3n Encuesta',1350                                    iconCls:'bogus',1351                                    handler:this.createWindow,1352                                    scope: this,1353                                    windowId:'FrmListadoCgg_dhu_aplicacion_encuesta'1354                                }1355                                ]1356                            }1357                        }1358                        ]1359                    }1360                }]1361            }1362        }1363    }1364});1365MyDesktop.StartMenuJuridico = Ext.extend(MyDesktop.StartMenuItem, {1366    init : function(){1367        this.launcher = {1368            text: 'Juridico',1369            iconCls: 'iconJuridico',1370            handler: function() {1371                return false;1372            },1373            menu: {1374                items:[{1375                    text:'Acuerdos',1376                    iconCls:'bogus',1377                    handler:this.createWindow,1378                    scope:this,1379                    windowId:'FrmListadoCgg_jur_acuerdo'1380                },{1381                    text: 'Anticipo',1382                    iconCls:'bogus',1383                    handler:this.createWindow,1384                    scope: this,1385                    windowId:'FrmListadoCgg_jur_anticipo'1386                },{1387                    text: 'Historial Acuerdos',1388                    iconCls:'bogus',1389                    handler:this.createWindow,1390                    scope: this,1391                    windowId:'FrmListadoCgg_jur_historial_acuerdo'1392                },'-',{1393                    text: 'Procesos Judiciales',1394                    iconCls:'bogus',1395                    handler:this.createWindow,1396                    scope: this,1397                    windowId:'FrmListadoCgg_jur_proceso_judicial'1398                },{1399                    text: 'Asesor',1400                    iconCls:'bogus',1401                    handler:this.createWindow,1402                    scope: this,1403                    windowId:'FrmListadoCgg_jur_asesor'1404                },{1405                    text: 'Historial Procesos',1406                    iconCls:'bogus',1407                    handler:this.createWindow,1408                    scope: this,1409                    windowId:'FrmListadoCgg_jur_historial_proceso'1410                },'-',{1411                    text: 'Tipo Proceso',1412                    iconCls:'bogus',1413                    handler:this.createWindow,1414                    scope: this,1415                    windowId:'FrmListadoCgg_jur_tipo_proceso'1416                },{1417                    text: 'Area Influencia',1418                    iconCls:'bogus',1419                    handler:this.createWindow,1420                    scope: this,1421                    windowId:'FrmListadoCgg_area_influencia'1422                },{1423                    text: 'Criterios',1424                    iconCls:'bogus',1425                    handler:this.createWindow,1426                    scope: this,1427                    windowId:'FrmListadoCgg_jur_seguimiento_criterio_juridico'1428                }1429                ]1430            }1431        }1432    }1433});1434MyDesktop.StartMenuGerencial = Ext.extend(MyDesktop.StartMenuItem, {1435    init : function(){1436        this.launcher = {1437            text: 'Gerencial',1438            iconCls:'iconGerencial',1439            handler: this.createWindow,1440            scope: this,1441            menu: {1442                items:[1443                {1444                    text:'Listado de reporte indicadores',1445                    iconCls:'bogus',1446                    handler:this.createWindow,1447                    scope:this,1448                    windowId:'FrmCgg_gerencial_reporte'1449                },{1450                    text:'Subsistema gerencial',1451                    iconCls:'bogus',1452                    handler:this.createWindow,1453                    scope:this,1454                    windowId:'FrmCgg_gerencial_matriz'1455                },'-',{1456                    text:'Administraci\u00f3n encargado indicador ',1457                    iconCls:'bogus',1458                    handler:this.createWindow,1459                    scope:this,1460                    windowId:'FrmListadoCgg_ger_indicador_encargado'1461                }1462                ]1463            }            1464        }1465    }1466});1467MyDesktop.StartOffline = Ext.extend(MyDesktop.StartMenuItem, {1468    init : function(){1469        this.launcher = {1470            text: 'Offline',1471            iconCls:'iconOffline',1472            handler: this.createWindow,1473            scope: this,1474            menu: {1475                items:[1476                {1477                    text:'Tct',1478                    iconCls:'bogus',1479                    handler:function(){1480                        var usuarioPvt = new FrmCgg_usuario_pvt();1481                        usuarioPvt.show();1482                    },1483                    scope:this                    1484                },{1485                    text:'E/S persona',1486                    iconCls:'bogus',1487                    handler:function(){1488                        /*var Canton_offlin = new FrmCgg_canton_offline();1489                        Canton_offlin.show();*/1490                        var url = 'https://'+ URL_SERVER +URL_WS+'/PublicWS/DatosConfigMovilidadSRV?tipo=file';1491                        var open_link = window.open('');1492                        open_link.location= url ;1493                    },1494                    scope:this1495                },{1496                    text:'Notificaci\u00f3n',1497                    iconCls:'bogus',1498                    handler:function(){1499                        //                        var Canton_noti_offlin = new FrmCgg_canton_noti_offline();1500                        //                           Canton_noti_offlin.show();1501                        var open_link = window.open('');1502                        var url = 'https://'+ URL_SERVER +URL_WS+'/PublicWS/DatosConfigNotificacionSRV?tipo=file';1503                        open_link.location= url ;1504                    },1505                    scope:this1506                }1507                ]1508            }1509        }1510    }...api.js
Source:api.js  
1(function() {2    function createWindow(options) {3        return $("<div />")4            .appendTo(Mocha.fixture)5            .kendoWindow(options)6            .data("kendoWindow");7    }8    function createDialog(options) {9        return $("<div />")10            .appendTo(Mocha.fixture)11            .kendoDialog(options)12            .data("kendoDialog");13    }14    describe("api", function() {15        beforeEach(function() {16            var Window = kendo.ui.Window;17            Mocha.fixture.html(__html__["tests/window/modals-fixture.html"]);18        });19        afterEach(function() {20            Mocha.fixture21                .closest("body")22                .find(".k-window-content")23                .each(function(idx, element) {24                    kendo.widgetInstance($(element)).destroy();25                });26            Mocha.fixture27                .closest("body")28                .find(".k-overlay")29                .remove();30            $.mockjax.clear();31            // Destroy all possible .k-animation-container elements left by previous test suites.32            kendo.destroy($("body"));33        });34        it("title gets title", function() {35            assert.equal(createWindow({ title: "Title" }).title(), "Title");36        });37        it("title sets title", function() {38            var window = createWindow({ title: "Title" }),39                oldTitle = window.title(),40                titleElement = $(".k-window-title", window.wrapper);41            window.title("Title is the new title!");42            assert.equal(titleElement.text(), "Title is the new title!");43            window.title(oldTitle);44            assert.equal(titleElement.text(), oldTitle);45        });46        it("title method gets and sets the title consistently", function() {47            var title = "foo",48                window = createWindow({ title: title }),49                oldTitle = window.title(),50                newTitle,51                titleElement = $(".k-window-title", window.wrapper);52            assert.equal(window.title(), title);53            window.title(window.title());54            assert.equal(window.title(), title);55        });56        it("title method and title property encode the title", function() {57            var stringValue = "<script>var foo1 = 1;</script>",58                window = createWindow({ title: stringValue }),59                titleElement = $(".k-window-title", window.wrapper);60            assert.equal(titleElement.html(), kendo.htmlEncode(stringValue));61            window.title(stringValue);62            assert.equal(titleElement.html(), kendo.htmlEncode(stringValue));63        });64        it("open of modal window adds overlay if it does not exist", function() {65            createWindow({ modal: true }).open();66            assert.equal($("body > .k-overlay").length, 1);67        });68        it("dblclick on resizable window title maximizes window", function() {69            var window = createWindow();70            window.wrapper.find(".k-window-titlebar").trigger("dblclick");71            assert.isOk(window.options.isMaximized);72        });73        it("dblclick on non resizable window title does not maximize window", function() {74            var window = createWindow({ resizable: false });75            window.element.find(".k-window-titlebar").trigger("dblclick");76            assert.isOk(!window.options.isMaximized);77        });78        it("close updates scroll position when window is maximized", function() {79            var container = $("<div style='height:2000px' />").appendTo(Mocha.fixture.height(2010)),80                document = $(Mocha.fixture[0].ownerDocument),81                window = createWindow({ visible: false }),82                scrollPosition = 200;83            document.scrollTop(0);84            window.setOptions({});85            window.open().maximize();86            window.close();87            document.scrollTop(scrollPosition);88            window.setOptions({});89            window.open().maximize();90            window.close();91            assert.equal(92                document.scrollTop(),93                scrollPosition94            );95        });96        it("document vertical scroll position is preserved on maximize and restore", function() {97            var window = createWindow();98            var div = $("<div style='height:2000px' />").appendTo(99                    Mocha.fixture.height(2010)100                ),101                scrollPosition = 300;102            $(Mocha.fixture[0].ownerDocument).scrollTop(scrollPosition);103            window.maximize();104            window.restore();105            assert.equal(106                $(Mocha.fixture[0].ownerDocument).scrollTop(),107                scrollPosition108            );109        });110        it("document horizontal scroll position is preserved on maximize and restore", function() {111            var window = createWindow();112            var div = $("<div style='width:5000px' />").appendTo(113                    Mocha.fixture.width(5020)114                ),115                scrollPosition = 1300;116            // Mocha.fixture's document is initially with overflow:hidden117            $(Mocha.fixture[0].ownerDocument)118                .find("html, body")119                .css("overflow", "");120            $(Mocha.fixture[0].ownerDocument).scrollLeft(scrollPosition);121            assert.equal(122                $(Mocha.fixture[0].ownerDocument).scrollLeft(),123                scrollPosition124            );125            window.center();126            window.maximize();127            window.restore();128            assert.equal(129                $(Mocha.fixture[0].ownerDocument).scrollLeft(),130                scrollPosition131            );132        });133        it("destroying a modal window moves overlay before previous window", function() {134            var dialog = createWindow({135                    modal: true136                }),137                overlappingDialog = createWindow({138                    modal: true139                });140            overlappingDialog.destroy();141            assert.isOk(dialog.wrapper.prev("div").is(".k-overlay"));142        });143        it("destroy does not throw errors when called twice on the same object", function() {144            var dialog = createWindow();145            dialog.destroy();146            dialog.destroy();147            assert.isOk(true);148        });149        it("closing a modal window moves overlay before previous window", function() {150            var dialog = createWindow({151                    modal: true152                }),153                overlappingDialog = createWindow({154                    modal: true155                });156            overlappingDialog.close();157            assert.isOk(dialog.wrapper.prev("div").is(".k-overlay"));158        });159        it("closing a modal window moves overlay before previous Kendo Dialog too", function() {160            var dialog = createDialog({161                    modal: true162                }),163                overlappingDialog = createWindow({164                    modal: true165                });166            overlappingDialog.close();167            assert.isOk(dialog.wrapper.prev("div").is(".k-overlay"));168        });169        it("closing a modal window removes overlay if previous modal has containment enabled", function() {170            $("<div id='container' style='height: 400px; width: 400px; position: absolute;' />").appendTo(Mocha.fixture);171            var dialog = createWindow({172                    modal: true,173                    draggable: {174                        containment: "#container"175                    },176                    animation: false177                }),178                overlappingDialog = createWindow({179                    modal: true,180                    animation: false181                });182            overlappingDialog.close();183            dialog.close();184            assert.equal($(".k-overlay").length, 0);185        });186        it("destroying a modal window removes overlay if other open window has different appendTo", function() {187            var dialog = createWindow({188                    modal: true,189                    appendTo: Mocha.fixture190                }),191                overlappingDialog = createWindow({192                    modal: true,193                    appendTo: document.body194                });195            overlappingDialog.destroy();196            assert.equal($(".k-overlay").length, 1);197            assert.equal(Mocha.fixture.children(".k-overlay").length, 1);198        });199        it("closing window from close handler", function() {200            var dialog = createWindow({201                modal: true,202                close: function(e) {203                    if (e.userTriggered) {204                        this.close();205                    }206                },207                deactivate: function() {208                    assert.isOk(true);209                }210            });211            dialog.wrapper.find(".k-i-close").click();212        });213        it("closing a modal window moves overlay below previous window", function(done) {214            function resumeTest() {215                window.setTimeout(function() {216                    assert.isOk(217                        modalWindow1.wrapper.css("zIndex") >218                        modalWindow1.wrapper219                            .siblings(".k-overlay")220                            .css("zIndex")221                    );222                    done();223                }, 10);224            }225            var modalWindow2 = $("#modalWindow2")226                .kendoWindow({227                    modal: true,228                    visible: false,229                    animation: {230                        open: {231                            duration: 0232                        },233                        close: {234                            duration: 0235                        }236                    },237                    close: resumeTest238                })239                .data("kendoWindow");240            var modalWindow1 = $("#modalWindow1")241                .kendoWindow({242                    modal: true,243                    animation: {244                        open: {245                            duration: 0246                        },247                        close: {248                            duration: 0249                        }250                    },251                    visible: false252                })253                .data("kendoWindow");254            modalWindow1.open();255            modalWindow2.open();256            modalWindow2.close();257        });258        it("refresh() of local URLs requests data via AJAX", function(done) {259            var dialog = createWindow(),260                hasRequestedData = false;261            $.mockjax(function() {262                hasRequestedData = true;263                done();264                return {};265            });266            dialog.refresh("httpfoo");267            assert.isOk(hasRequestedData);268            $.mockjax.clear();269        });270        it("refresh() with string uses it as a URL", function(done) {271            var url = "foo",272                dialog = createWindow({});273            $.mockjax({274                url: "foo",275                onAfterComplete: function() {276                    assert.equal(this.url, url);277                    done();278                }279            });280            dialog.refresh(url);281        });282        it("refresh() uses `content` if no url is provided", function(done) {283            $.mockjax(function(settings) {284                return {};285            });286            var url = "foo",287                dialog = createWindow({ content: url });288            $.mockjax.clear();289            $.mockjax(function(settings) {290                assert.equal(settings.url, url);291                done();292                return {};293            });294            dialog.refresh();295        });296        it("refresh() sends data to server", function(done) {297            var dialog = createWindow({}),298                data = { bar: "baz" };299            $.mockjax(function(settings) {300                assert.deepEqual(settings.data, data);301                done();302                return {};303            });304            dialog.refresh({305                url: "foo",306                data: data307            });308        });309        it("refresh() sets `content` option", function() {310            var dialog = createWindow({311                content: "http://example.com/"312            });313            dialog.refresh({ url: "test" });314            dialog.refresh();315            assert.equal(dialog.options.content.url, "test");316        });317        it("refresh() uses `content` object combined with URL", function(done) {318            $.mockjax(function(settings) {319                return {};320            });321            var url = "/bar",322                contentObject = { type: "POST" },323                dialog = createWindow({ content: contentObject });324            $.mockjax.clear();325            $.mockjax(function(settings) {326                assert.equal(settings.url, url);327                assert.equal(settings.type, contentObject.type);328                done();329                return {};330            });331            dialog.refresh(url);332        });333        it("refresh() creates iframe, if loading a remote url", function() {334            var dialog = createWindow({}),335                url = "http://example.com/";336            dialog.refresh(url);337            var iframe = dialog.wrapper.find("iframe");338            assert.equal(iframe.length, 1);339            assert.equal(iframe.attr("src"), url);340        });341        it("refresh() of AJAX window with cross-domain URL", function() {342            $.mockjax({343                url: "foo",344                responseText: "server foo"345            });346            var dialog = createWindow({347                    content: "foo"348                }),349                url = "http://example.com/";350            dialog.refresh(url);351            var iframe = dialog.wrapper.find("iframe");352            assert.equal(iframe.length, 1);353            assert.equal(iframe.attr("src"), url);354        });355        it("refresh() of local URL with iframe", function() {356            $.mockjax({357                url: "foo",358                responseText: "server foo"359            });360            var dialog = createWindow({361                iframe: true362            });363            dialog.refresh({364                url: "foo"365            });366            var iframe = dialog.wrapper.find("iframe");367            assert.equal(iframe.length, 1);368            assert.equal(iframe.attr("src"), "foo");369        });370        it("refresh() creates iframe if iframe:true", function() {371            $.mockjax({372                url: "foo",373                responseText: "server foo"374            });375            var dialog = createWindow();376            dialog.refresh({377                url: "foo",378                iframe: true379            });380            var iframe = dialog.wrapper.find("iframe");381            assert.equal(iframe.length, 1);382            assert.equal(iframe.attr("src"), "foo");383        });384        it("content() destroys nested widgets", function() {385            var dialog = createWindow();386            var ddl = $("<input />").appendTo(dialog.element);387            ddl.kendoDropDownList({ dataSource: ["foo"] });388            ddl.data("kendoDropDownList").open();389            dialog.content("bar");390            assert.isOk(!ddl.data("kendoDropDownList"));391        });392        it("content() with jQuery object", function() {393            var dialog = createWindow();394            var dom = $("<span class='a'>foo</span>");395            dialog.content(dom);396            assert.equal(dialog.element.find(".a").length, 1);397        });398        it("toFront() raises window z-index above other windows", function() {399            var firstWindow = createWindow(),400                secondWindow = createWindow();401            firstWindow.toFront();402            assert.equal(403                +wrapper(firstWindow).css("zIndex"),404                +wrapper(secondWindow).css("zIndex") + 2405            );406        });407        function wrapper(windowObject) {408            return windowObject.element.closest(".k-window");409        }410        it("toFront() raises window z-index above other windows with different z-index", function() {411            var firstWindow = createWindow(),412                secondWindow = createWindow();413            wrapper(secondWindow).css("zIndex", 10012);414            firstWindow.toFront();415            assert.equal(416                +wrapper(firstWindow).css("zIndex"),417                +wrapper(secondWindow).css("zIndex") + 2418            );419        });420        it("toFront() overlays iframes of windows with lower z-index", function() {421            var firstWindow = createWindow(),422                secondWindow = createWindow({423                    content: "http://google.com/"424                });425            firstWindow.toFront();426            assert.isOk(secondWindow.element.find("> .k-overlay").length);427        });428        it("toFront() appends only one overlay element to dom", function() {429            var firstWindow = createWindow(),430                secondWindow = createWindow({431                    content: "http://google.com/"432                });433            firstWindow.toFront();434            firstWindow.toFront();435            assert.equal(secondWindow.element.find("> .k-overlay").length, 1);436        });437        it("toFront() removes overlay on foremost window", function() {438            var firstWindow = createWindow({439                    content: "http://www.telerik.com/"440                }),441                secondWindow = createWindow({442                    content: "http://google.com/"443                });444            firstWindow.toFront();445            assert.isOk(!firstWindow.element.find("> .k-overlay").length);446        });447        it("toFront() moves modal overlay above other windows", function() {448            var firstWindow1 = createWindow(),449                secondWindow1 = createWindow({450                    modal: true451                });452            assert.isOk(453                parseInt(firstWindow1.wrapper.css("zIndex")) <454                    parseInt($(".k-overlay").css("zIndex"))455            );456        });457        it("toFront() does not increase the window z-index if not necessary", function() {458            var dialog = createWindow(),459                zIndex = dialog.wrapper.css("zIndex");460            dialog.toFront();461            assert.equal(dialog.wrapper.css("zIndex"), zIndex);462        });463        it("open() calls toFront()", function(done) {464            var firstWindow = createWindow();465            firstWindow.close();466            firstWindow.toFront = function() {467                assert.isOk(true);468                done();469            };470            firstWindow.open();471        });472        it("open() sets options.visible", function() {473            var dialog = createWindow({474                visible: false,475                animation: false476            });477            dialog.open();478            assert.isOk(dialog.options.visible);479        });480        it("open() adds k-display-inline-flex class to wrapper", function() {481            var dialog = createWindow({482                visible: false,483                animation: false484            });485            dialog.open();486            assert.isOk(dialog.wrapper.hasClass("k-display-inline-flex"));487        });488        it("close() sets options.visible", function() {489            var dialog = createWindow({490                visible: true,491                animation: false492            });493            dialog.close();494            assert.isOk(!dialog.options.visible);495        });496        it("pin() does not affect draggable", function() {497            var dialog = createWindow({498                visible: true,499                animation: false,500                draggable: true501            });502            dialog.pin();503            assert.equal(dialog.options.draggable, true);504        });505        it("pin() sets position:fixed style to wrapper", function() {506            var dialog = createWindow({507                visible: true,508                animation: false509            });510            dialog.pin();511            assert.equal(dialog.wrapper.css("position"), "fixed");512        });513        it("pin() toggles button class to k-i-unpin", function() {514            var dialog = createWindow({515                visible: true,516                animation: false,517                actions: ["Pin"]518            });519            assert.equal(dialog.wrapper.find(".k-i-pin").length, 1);520            assert.equal(dialog.wrapper.find(".k-i-unpin").length, 0);521            dialog.pin();522            assert.equal(dialog.wrapper.find(".k-i-unpin").length, 1);523            assert.equal(dialog.wrapper.find(".k-i-pin").length, 0);524        });525        it("pin() substracts the browser scroll position from the wrapper's top and left styles", function() {526            var spacerDiv = $(527                "<div style='width:6000px;height:3000px'> </div>"528            ).appendTo(Mocha.fixture);529            $(window).scrollLeft(2000);530            $(window).scrollTop(1000);531            var initialTop,532                initialLeft,533                dialog = createWindow({534                    visible: true,535                    animation: false536                });537            dialog.center();538            initialTop = parseInt(dialog.wrapper.css("top"), 10);539            initialLeft = parseInt(dialog.wrapper.css("left"), 10);540            dialog.pin();541            finalTop = parseInt(dialog.wrapper.css("top"), 10);542            finalLeft = parseInt(dialog.wrapper.css("left"), 10);543            assert.equal(finalTop, initialTop - $(window).scrollTop());544            assert.equal(finalLeft, initialLeft - $(window).scrollLeft());545            spacerDiv.remove();546        });547        it("pin() itself should not subtract scroll without center or unpin where called", function(){548            var spacerDiv = $(549                "<div style='width:6000px;height:3000px'> </div>"550            ).appendTo(Mocha.fixture);551            $(window).scrollLeft(2000);552            $(window).scrollTop(1000);553            var initialTop,554                initialLeft,555                dialog = createWindow({556                    visible: true,557                    animation: false558                });559            initialTop = parseInt(dialog.wrapper.css("top"), 10);560            initialLeft = parseInt(dialog.wrapper.css("left"), 10);561            dialog.pin();562            finalTop = parseInt(dialog.wrapper.css("top"), 10);563            finalLeft = parseInt(dialog.wrapper.css("left"), 10);564            assert.equal(finalTop, initialTop);565            assert.equal(finalLeft, initialLeft);566            dialog.unpin();567            dialog.center();568            initialTop = parseInt(dialog.wrapper.css("top"), 10);569            initialLeft = parseInt(dialog.wrapper.css("left"), 10);570            dialog.pin();571            finalTop = parseInt(dialog.wrapper.css("top"), 10);572            finalLeft = parseInt(dialog.wrapper.css("left"), 10);573            assert.equal(finalTop, initialTop - $(window).scrollTop());574            assert.equal(finalLeft, initialLeft - $(window).scrollLeft());575        });576        it("unpin() does not affect draggable", function() {577            var dialog = createWindow({578                visible: true,579                animation: false,580                draggable: true,581                pinned: true582            });583            dialog.unpin();584            assert.equal(dialog.options.draggable, true);585        });586        it("unpin() removes position:fixed style from wrapper", function() {587            var dialog = createWindow({588                visible: true,589                animation: false,590                pinned: true591            });592            dialog.unpin();593            assert.equal(dialog.wrapper.css("position"), "absolute");594        });595        it("unpin() toggles button class to k-i-pin", function() {596            var dialog = createWindow({597                visible: true,598                animation: false,599                actions: ["Pin"],600                pinned: true601            });602            assert.equal(dialog.wrapper.find(".k-i-unpin").length, 1);603            assert.equal(dialog.wrapper.find(".k-i-pin").length, 0);604            dialog.unpin();605            assert.equal(dialog.wrapper.find(".k-i-pin").length, 1);606            assert.equal(dialog.wrapper.find(".k-i-unpin").length, 0);607        });608        it("unpin() adds the browser scroll position to the wrapper's top and left styles", function() {609            var spacerDiv = $(610                "<div style='width:6000px;height:3000px'> </div>"611            ).appendTo(Mocha.fixture);612            $(window).scrollLeft(2000);613            $(window).scrollTop(1000);614            var initialTop,615                initialLeft,616                dialog = createWindow({617                    visible: true,618                    animation: false,619                    pinned: true620                });621            dialog.center();622            initialTop = parseInt(dialog.wrapper.css("top"), 10);623            initialLeft = parseInt(dialog.wrapper.css("left"), 10);624            dialog.unpin();625            finalTop = parseInt(dialog.wrapper.css("top"), 10);626            finalLeft = parseInt(dialog.wrapper.css("left"), 10);627            assert.equal(finalTop, initialTop + $(window).scrollTop());628            assert.equal(finalLeft, initialLeft + $(window).scrollLeft());629            spacerDiv.remove();630        });631        it("restoring a pinned Window preserves the pinned state", function() {632            var dialog = createWindow({633                visible: true,634                animation: false635            });636            dialog.center();637            dialog.minimize();638            dialog.pin();639            dialog.restore();640            assert.equal(dialog.wrapper.css("position"), "fixed");641        });642        it("centering a Window sets correct top and left styles", function() {643            var win = $(window),644                dialog = createWindow({645                    animation: false,646                    width: "50%",647                    height: "50%"648                });649            dialog.center();650            assert.closeTo(651                parseInt(dialog.wrapper.css("top"), 10),652                (win.height() - parseInt(dialog.wrapper.outerHeight(), 10)) / 2,653                1654            );655            assert.closeTo(656                parseInt(dialog.wrapper.css("left"), 10),657                (win.width() - parseInt(dialog.wrapper.outerWidth(), 10)) / 2,658                1659            );660        });661        it("centering a pinned Window sets correct top and left styles", function() {662            var pageWidth = 6000,663                pageHeight = pageWidth,664                scrollPosition = pageWidth / 3;665            var div = $("<div />")666                .css({ width: pageWidth, height: pageHeight })667                .appendTo(Mocha.fixture.height(pageHeight));668            $(Mocha.fixture[0].ownerDocument)669                .scrollTop(scrollPosition)670                .scrollLeft(scrollPosition);671            var dialog1 = createWindow({672                pinned: true,673                animation: false674            });675            var dialog2 = createWindow({676                pinned: false,677                animation: false678            });679            dialog1.center();680            dialog2.center();681            assert.equal(682                parseInt(dialog1.wrapper.css("top"), 10),683                parseInt(dialog2.wrapper.css("top"), 10) - scrollPosition684            );685            assert.equal(686                parseInt(dialog1.wrapper.css("left"), 10),687                parseInt(dialog2.wrapper.css("left"), 10) - scrollPosition688            );689        });690        it("minimize() removes min-height", function() {691            var dialog = createWindow({692                visible: true,693                animation: false694            });695            dialog.minimize();696            assert.isOk(!dialog.wrapper[0].style.minHeight);697        });698        it("restore() adds back min-height", function() {699            var dialog = createWindow({700                visible: true,701                animation: false702            });703            dialog.minimize();704            dialog.restore();705            assert.isOk(dialog.wrapper[0].style.minHeight);706        });707        it("maximize() hides the pin/unpin icon", function() {708            var dialog = createWindow({709                visible: true,710                actions: ["Pin"],711                animation: false712            });713            dialog.maximize();714            assert.equal(dialog.wrapper.find(".k-i-pin:visible").length, 0);715        });716        it("maximize() hides the maximize icon", function() {717            var dialog = createWindow({718                visible: true,719                actions: ["Maximize"],720                animation: false721            });722            dialog.maximize();723            assert.equal(724                dialog.wrapper.find(".k-i-window-maximize:visible").length,725                0726            );727        });728        it("maximize() shows the restore icon", function() {729            var dialog = createWindow({730                visible: true,731                actions: ["Maximize"],732                animation: false733            });734            dialog.maximize();735            assert.equal(736                dialog.wrapper.find(".k-i-window-restore:visible").length,737                1738            );739        });740        it("maximize() adds a k-window-maximized class", function() {741            var dialog = createWindow({742                visible: true,743                actions: ["Pin"],744                animation: false745            });746            dialog.maximize();747            assert.isOk(dialog.wrapper.is(".k-window-maximized"));748        });749        it("restore() shows the pin/unpin icon", function() {750            var dialog = createWindow({751                visible: true,752                actions: ["Pin"],753                animation: false754            });755            dialog.maximize();756            dialog.restore();757            assert.equal(dialog.wrapper.find(".k-i-pin:visible").length, 1);758        });759        it("restore() removes the k-window-maximized class", function() {760            var dialog = createWindow({761                visible: true,762                actions: ["Pin"],763                animation: false764            });765            dialog.maximize();766            dialog.wrapper.addClass("k-window-maximized");767            dialog.restore();768            assert.isOk(!dialog.wrapper.is(".k-window-maximized"));769        });770        it("title() on titleless window does not fail", function() {771            var dialog = createWindow({ title: false });772            dialog.title("foo");773            assert.isOk(true);774        });775        it("title(false) removes titlebar", function() {776            var dialog = createWindow({ title: "foo" });777            dialog.title(false);778            assert.equal(dialog.wrapper.find(".k-window-titlebar").length, 0);779            assert.equal(parseInt(dialog.wrapper.css("padding-top"), 10), 0);780        });781        it("title('foo') on titleless window adds title", function() {782            var dialog = createWindow({ title: false });783            dialog.title("foo");784            assert.equal(dialog.wrapper.find(".k-window-titlebar").length, 1);785        });786        it("extending the window does not break the close method", function() {787            var MyWindow = kendo.ui.Window.extend({788                options: {789                    name: "MyWindow",790                    animation: false791                },792                init: function(element, options) {793                    kendo.ui.Window.prototype.init.apply(this, [794                        element,795                        options796                    ]);797                }798            });799            kendo.ui.plugin(MyWindow);800            var myWindow = $("<div />")801                .kendoMyWindow()802                .data("kendoMyWindow");803            myWindow.open().close();804            myWindow.destroy();805            assert.isOk(true);806        });807        it("destroying a window destroys nested components", function() {808            var html =809                "<div id='dialog'><select><option>foo</option></select></div>";810            var dialog = $(html)811                .appendTo(Mocha.fixture)812                .find("select")813                .kendoDropDownList()814                .end()815                .kendoWindow()816                .data("kendoWindow");817            dialog.element818                .find("select")819                .data("kendoDropDownList")820                .open();821            dialog.destroy();822            assert.equal($("body > .k-animation-container").length, 0);823        });824        it("async open/close of model windows leaves overlay", function() {825            var first = createWindow({ modal: true });826            var second = createWindow({ modal: true, visible: false });827            first.close();828            second.open();829            assert.isOk($(".k-overlay").is(":visible"));830        });831        it("opening a closing animated window leaves it in opened state", function(done) {832            var dialog = createWindow({833                animation: {834                    open: { duration: 50 },835                    close: { duration: 50 }836                }837            });838            dialog.close().open();839            setTimeout(function() {840                assert.isOk(dialog.wrapper.is(":visible"));841                done();842            }, 100);843        });844        it("setOptions can toggle draggable option", function() {845            var dialog = createWindow();846            dialog.setOptions({ draggable: true });847            assert.isOk(dialog.dragging);848            var draggingDestroy = spy(dialog.dragging, "destroy");849            dialog.setOptions({ draggable: false });850            assert.isOk(!dialog.dragging);851            assert.isOk(draggingDestroy.calls("destroy"), 1);852        });853        it("setOptions can toggle resizable option", function() {854            var dialog = createWindow();855            dialog.setOptions({ resizable: true });856            assert.isOk(dialog.resizing);857            var resizingDestroy = spy(dialog.resizing, "destroy");858            dialog.setOptions({ resizable: false });859            assert.isOk(!dialog.resizing);860            assert.isOk(resizingDestroy.calls("destroy"), 1);861        });862        it("setOptions can set zero integer position", function() {863            var dialog = createWindow();864            dialog.setOptions({865                position: {866                    top: 0,867                    left: 0868                }869            });870            assert.equal(dialog.wrapper.css("left"), "0px");871            assert.equal(dialog.wrapper.css("top"), "0px");872        });873        it("setOptions can set integer position", function() {874            var dialog = createWindow();875            dialog.setOptions({876                position: {877                    top: 10,878                    left: 10879                }880            });881            assert.equal(dialog.wrapper.css("left"), "10px");882            assert.equal(dialog.wrapper.css("top"), "10px");883        });884        it("setOptions can set string position", function() {885            var dialog = createWindow();886            dialog.setOptions({887                position: {888                    top: "10px",889                    left: "10px"890                }891            });892            assert.equal(dialog.wrapper.css("left"), "10px");893            assert.equal(dialog.wrapper.css("top"), "10px");894        });895        it("setOptions resets maximized state", function() {896            var dialog = createWindow();897            dialog.maximize();898            dialog.setOptions({899                position: {900                    width: 100,901                    height: 200902                }903            });904            assert.isOk(!dialog.options.isMaximized);905        });906        it("setting new title updates widget options", function() {907            var newTitle = "foo",908                dialog = createWindow();909            dialog.title(newTitle);910            assert.equal(dialog.options.title, newTitle);911        });912        it("setOptions can toggle modality 1", function() {913            var dialog = createWindow({ modal: false });914            dialog.setOptions({ modal: true });915            assert.equal(916                dialog.wrapper.siblings(".k-overlay").filter(":visible").length,917                1918            );919            dialog.setOptions({ modal: false });920            assert.equal(921                dialog.wrapper.siblings(".k-overlay").filter(":visible").length,922                0923            );924        });925        it("setOptions can toggle modality 2", function() {926            var dialog = createWindow({ modal: true });927            dialog.setOptions({ modal: false });928            assert.equal(929                dialog.wrapper.siblings(".k-overlay").filter(":visible").length,930                0931            );932            dialog.setOptions({ modal: true });933            assert.equal(934                dialog.wrapper.siblings(".k-overlay").filter(":visible").length,935                1936            );937        });938        it("setOptions does not show modal overlay if window is hidden", function() {939            var dialog = createWindow({ visible: false });940            dialog.setOptions({ modal: true });941            assert.equal(942                dialog.wrapper.siblings(".k-overlay").filter(":visible").length,943                0944            );945            dialog.setOptions({ modal: true, visible: false });946            assert.equal(947                dialog.wrapper.siblings(".k-overlay").filter(":visible").length,948                0949            );950        });951        it("setOptions to suppress close animation", function() {952            var dialog = createWindow({ visible: false });953            dialog.setOptions({954                animation: {955                    close: false956                }957            });958            dialog.open();959            assert.isOk(true);960        });961        it("setOptions should make deep extend of options.position", function() {962            var dialog = createWindow({963                visible: false,964                position: {965                    top: 100,966                    left: 200967                }968            });969            dialog.setOptions({970                position: {971                    top: 200972                }973            });974            assert.deepEqual(975                dialog.options.position,976                { top: 200, left: 200 },977                "position.top should be changed, but position.left stays the same"978            );979            dialog.setOptions({980                position: {981                    left: 300982                }983            });984            assert.deepEqual(985                dialog.options.position,986                { top: 200, left: 300 },987                "position.top stays the same, but position.left is changed"988            );989            dialog.setOptions({990                position: {991                    left: "50%"992                }993            });994            assert.deepEqual(995                dialog.options.position,996                { top: 200, left: "50%" },997                "string values should work too"998            );999        });1000        it("overlay is not hidden when showing second modal window after closing first", function(done) {1001            var dialog = createWindow({1002                animation: { close: { duration: 500 } },1003                modal: true1004            });1005            var secondDialog = createWindow({1006                animation: { open: { duration: 1000 } },1007                modal: true,1008                visible: false,1009                activate: function() {1010                    assert.isOk($(".k-overlay").is(":visible"));1011                    done();1012                }1013            });1014            dialog.close();1015            secondDialog.open();1016        });1017        it("setOptions allows changing of window actions", function() {1018            var dialog = createWindow();1019            dialog.setOptions({1020                actions: ["Minimize", "Close"]1021            });1022            assert.equal(dialog.wrapper.find(".k-i-window-minimize").length, 1);1023        });1024        it("toFront does not scroll page when windows are pinned", function() {1025            var spacerDiv = $(1026                "<div style='height:3000px'> </div>"1027            ).appendTo(Mocha.fixture);1028            var dialog = createWindow({1029                pinned: true1030            });1031            $(window).scrollTop(200);1032            $(dialog.wrapper).css({ top: 180 });1033            dialog.toFront();1034            assert.equal($(window).scrollTop(), 200);1035            spacerDiv.remove();1036        });1037        function setDimensionTest(dim) {1038            var options = {};1039            options[dim] = 400;1040            var wnd = createWindow(options);1041            options[dim] = null;1042            wnd.setOptions(options);1043            assert.isOk(!wnd.wrapper[0].style[dim]);1044        }1045        it("setOptions resets width", $.proxy(setDimensionTest, this, "width"));1046        it(1047            "setOptions resets height",1048            $.proxy(setDimensionTest, this, "height")1049        );1050        it(1051            "setOptions resets minWidth",1052            $.proxy(setDimensionTest, this, "minWidth")1053        );1054        it(1055            "setOptions resets maxWidth",1056            $.proxy(setDimensionTest, this, "maxWidth")1057        );1058        it(1059            "setOptions resets minHeight",1060            $.proxy(setDimensionTest, this, "minHeight")1061        );1062        it(1063            "setOptions resets maxHeight",1064            $.proxy(setDimensionTest, this, "maxHeight")1065        );1066        it("isMinimized is updated when minimizing window", function() {1067            var dialog = createWindow({1068                visible: true,1069                animation: false1070            });1071            dialog.minimize();1072            assert.isOk(dialog.isMinimized());1073        });1074        it("isMinimized is updated when restoring window", function() {1075            var dialog = createWindow({1076                visible: true,1077                animation: false1078            });1079            dialog.minimize();1080            dialog.restore();1081            assert.isOk(!dialog.isMinimized());1082        });1083        it("isMaximized is updated when maximizing window", function() {1084            var dialog = createWindow({1085                visible: true,1086                animation: false1087            });1088            dialog.maximize();1089            assert.isOk(dialog.isMaximized());1090        });1091        it("isMaximized is updated when restoring window", function() {1092            var dialog = createWindow({1093                visible: true,1094                animation: false1095            });1096            dialog.maximize();1097            dialog.restore();1098            assert.isOk(!dialog.isMaximized());1099        });1100        it("maximize() takes borders into account", function() {1101            var borderWidth = 10;1102            var dialog = createWindow({1103                visible: true,1104                animation: false1105            });1106            dialog.wrapper.css("border-width", borderWidth + "px");1107            dialog.maximize();1108            assert.equal(1109                dialog.wrapper.width() + borderWidth * 2,1110                $(window).width()1111            );1112        });1113        it("maximize() sets body's and html's overflow to hidden", function() {1114            var dialog = createWindow({1115                visible: true,1116                animation: false1117            });1118            // Mocha.fixture's document is initially with overflow:hidden1119            $(Mocha.fixture[0].ownerDocument)1120                .find("html, body")1121                .css("overflow", "");1122            dialog.maximize();1123            assert.equal($("body").css("overflow"), "hidden");1124            assert.equal($("html").css("overflow"), "hidden");1125            dialog.close();1126        });1127        it("restore() restores body's and html's original overflow after maximize()", function() {1128            var dialog = createWindow({1129                visible: true,1130                animation: false1131            });1132            // Mocha.fixture's document is initially with overflow:hidden1133            $(Mocha.fixture[0].ownerDocument)1134                .find("html, body")1135                .css("overflow", "scroll");1136            dialog.maximize();1137            dialog.restore();1138            assert.equal($("body").css("overflow"), "scroll");1139            assert.equal($("html").css("overflow"), "scroll");1140        });1141        it("closing maximized window restores body's and html's original overflow", function() {1142            var dialog = createWindow({1143                visible: true,1144                animation: false1145            });1146            // Mocha.fixture's document is initially with overflow:hidden1147            $(Mocha.fixture[0].ownerDocument)1148                .find("html, body")1149                .css("overflow", "scroll");1150            dialog.maximize();1151            dialog.close();1152            assert.equal($("body").css("overflow"), "scroll");1153            assert.equal($("html").css("overflow"), "scroll");1154        });1155        it("opening maximized window sets body's and html's overflow to hidden", function() {1156            var dialog = createWindow({1157                visible: true,1158                animation: false1159            });1160            // Mocha.fixture's document is initially with overflow:hidden1161            $(Mocha.fixture[0].ownerDocument)1162                .find("html, body")1163                .css("overflow", "scroll");1164            dialog.maximize();1165            dialog.close();1166            dialog.open();1167            assert.equal($("body").css("overflow"), "hidden");1168            assert.equal($("html").css("overflow"), "hidden");1169        });1170        it("closing maximized window retrieved original body's and html's overflow", function() {1171            var dialog = createWindow({1172                visible: true,1173                animation: false1174            });1175            // Mocha.fixture's document is initially with overflow:hidden1176            $(Mocha.fixture[0].ownerDocument)1177                .find("html, body")1178                .css("overflow", "scroll");1179            dialog.maximize();1180            dialog.open();1181            dialog.close();1182            assert.equal($("body").css("overflow"), "scroll");1183            assert.equal($("html").css("overflow"), "scroll");1184        });1185        it("get properly modals", function() {1186            var dialog1 = createWindow({1187                modal: true,1188                title:  'First Window'1189            });1190            var dialog2 = createWindow({1191                modal: true,1192                title:  'Second Window'1193            });1194            assert.equal(dialog1._modals().length, 2);1195            assert.equal(dialog2._modals().length, 2);1196        });1197        it("get properly modals in containment scenario", function() {1198            var div = $('<div id="containement" style="height:500px;width:500px">')1199            div.appendTo(Mocha.fixture);1200            var dialog1 = createWindow({1201                modal: true,1202                title:  'First Window',1203                draggable: {1204                    containment : '#containement'1205                }1206            });1207            var dialog2 = createWindow({1208                modal: true,1209                title:  'Second Window',1210                draggable: {1211                    containment : '#containement'1212                }1213            });1214            assert.equal(dialog1._modals().length, 2);1215            assert.equal(dialog2._modals().length, 2);1216        });1217    });...events.js
Source:events.js  
1(function() {2    var keys;3    function createWindow(options) {4        var dialog = $("<div />")5            .appendTo(Mocha.fixture)6            .kendoWindow(options);7        var dialogObject = dialog.data("kendoWindow");8        return dialogObject;9    }10    describe("events", function() {11        beforeEach(function() {});12        afterEach(function() {13            Mocha.fixture14                .closest("body")15                .find(".k-window-content")16                .each(function(idx, element) {17                    $(element)18                        .data("kendoWindow")19                        .destroy();20                });21            Mocha.fixture22                .closest("body")23                .find(".k-overlay")24                .remove();25            $.mockjax.clear();26        });27        it("clicking on window brings it in front of other windows and adds k-state-focused", function() {28            jasmine.clock().install();29            var firstWindow = createWindow({ animation: { open: { duration: 50 } } }),30                secondWindow = createWindow();31            firstWindow.element.trigger("mousedown");32            jasmine.clock().tick(50);33            assert.equal(34                +firstWindow.wrapper.css("zIndex"),35                +secondWindow.wrapper.css("zIndex") + 236            );37            assert.isOk(firstWindow.wrapper.is(".k-state-focused"));38            jasmine.clock().uninstall();39        });40        it("clicking on minimized window brings it in front of other windows and adds k-state-focused", function() {41            jasmine.clock().install();42            var firstWindow = createWindow({ animation: { open: { duration: 50 } } }),43                secondWindow = createWindow();44            firstWindow.minimize();45            firstWindow.wrapper.trigger("mousedown");46            jasmine.clock().tick(50);47            assert.equal(48                +firstWindow.wrapper.css("zIndex"),49                +secondWindow.wrapper.css("zIndex") + 250            );51            assert.isOk(firstWindow.wrapper.is(".k-state-focused"));52            jasmine.clock().uninstall();53        });54        it("clicking on inactive iframe window adds k-state-focused", function() {55            jasmine.clock().install();56            var firstWindow = createWindow({57                    content: "/base/tests/window/blank.html",58                    iframe: true,59                    animation: { open: { duration: 50 } }60                }),61                secondWindow = createWindow({62                    content: "/base/tests/window/blank.html",63                    iframe: true,64                    animation: { open: { duration: 50 } }65                });66            firstWindow.element.find(".k-overlay").trigger("mousedown");67            jasmine.clock().tick(50);68            assert.isOk(firstWindow.wrapper.is(".k-state-focused"));69            jasmine.clock().uninstall();70        });71        it("loading of iframe triggers load event", function(done) {72            var timeout = setTimeout(done, 2000);73            createWindow({74                content: "/base/tests/window/blank.html",75                iframe: true,76                refresh: function() {77                    clearTimeout(timeout);78                    assert.isOk(true);79                    done();80                }81            });82        });83        it("multiple loading of iframe triggers one refresh per load", function(done) {84            var triggers = 0;85            var first = true;86            var timeout = setTimeout(done, 4000);87            var dialog = createWindow({88                content: "/base/tests/window/blank.html",89                iframe: true,90                refresh: function() {91                    triggers++;92                    if (first) {93                        dialog.refresh("blank.html?v2");94                        first = false;95                    } else {96                        clearTimeout(timeout);97                        assert.equal(triggers, 2);98                        done();99                    }100                }101            });102        });103        it("clicking the refresh button on a static window triggers refresh event", function() {104            var triggers = 0,105                dialog = createWindow({106                    actions: ["Refresh"],107                    refresh: function() {108                        triggers++;109                    }110                });111            dialog.wrapper.find(".k-i-refresh").trigger("click");112            assert.equal(triggers, 1);113        });114        it("clicking the close button triggers close event", function() {115            var triggers = 0,116                dialog = createWindow({117                    close: function() {118                        assert.isOk(true);119                    }120                });121            dialog.wrapper.find(".k-i-close").trigger("click");122        });123        it("clicking the close button triggers close event when default is prevented", function() {124            var triggers = 0,125                dialog = createWindow({126                    animation: false,127                    close: function(ev) {128                        assert.isOk(true);129                        ev.preventDefault();130                    }131                });132            dialog.wrapper.find(".k-i-close").trigger("click");133            dialog.wrapper.find(".k-i-close").trigger("click");134        });135        it("minimize triggers minimize event", function() {136            var triggers = 0,137                dialog = createWindow({138                    actions: ["Minimize", "Restore"],139                    minimize: function() {140                        triggers++;141                    }142                });143            dialog.wrapper.find(".k-i-window-minimize").trigger("click");144            assert.equal(triggers, 1);145        });146        it("maximize triggers maximize event", function() {147            var triggers = 0,148                dialog = createWindow({149                    actions: ["Maximize", "Restore"],150                    maximize: function() {151                        triggers++;152                    }153                });154            dialog.wrapper.find(".k-i-window-maximize").trigger("click");155            assert.equal(triggers, 1);156        });157        it("error event gets triggered with proper information", function(done) {158            var dialog = createWindow({159                error: function(e) {160                    assert.isOk(e);161                    assert.equal(e.status, "error");162                    assert.equal(e.xhr.status, 404);163                    done();164                }165            });166            $.mockjaxSettings.responseTime = 0;167            $.mockjax({168                url: "/foo",169                status: 404,170                responseText: "Foo not found"171            });172            dialog.refresh("/foo");173        });174        it("moving minimized window does not show drag handles", function() {175            var dialog = createWindow();176            dialog.minimize();177            dialog.dragging.dragend({178                currentTarget: dialog.wrapper179            });180            assert.equal(181                dialog.wrapper.find(".k-resize-handle").css("display"),182                "none"183            );184        });185        it("moving minimized window does not show drag handles", function() {186            var dialog = createWindow();187            dialog.minimize();188            dialog.initialWindowPosition = { top: 0, left: 0 };189            dialog.dragging.dragcancel({190                currentTarget: dialog.wrapper191            });192            assert.equal(193                dialog.wrapper.find(".k-resize-handle").css("display"),194                "none"195            );196        });197        it("destroy can be called in close event", function() {198            var dialog = createWindow({199                close: function() {200                    this.destroy();201                }202            });203            dialog.close();204            assert.isOk(true);205        });206    });207    describe("keyboard support", function() {208        beforeEach(function() {209            keys = kendo.keys;210            $.fn.press = function(key, options) {211                return this.trigger(212                    $.extend({ type: "keydown", keyCode: key }, options)213                );214            };215        });216        afterEach(function() {217            Mocha.fixture218                .closest("body")219                .find(".k-window-content")220                .each(function(idx, element) {221                    $(element)222                        .data("kendoWindow")223                        .destroy();224                });225            Mocha.fixture226                .closest("body")227                .find(".k-overlay")228                .remove();229            $.mockjax.clear();230        });231        it("escape key triggers close event", function() {232            var triggers = 0;233            var dialog = createWindow({234                close: function(e) {235                    assert.isOk(true);236                    assert.isOk(e.userTriggered);237                }238            });239            dialog.element.press(keys.ESC);240        });241        it("escape key on minimized Window triggers close event", function() {242            var triggers = 0;243            var dialog = createWindow({244                close: function(e) {245                    assert.isOk(true);246                    assert.isOk(e.userTriggered);247                }248            });249            dialog.minimize();250            dialog.wrapper.press(keys.ESC);251        });252        it("hitting escape in closing window does not trigger new close", function() {253            var calls = 0;254            var dialog = createWindow({255                close: function() {256                    calls++;257                },258                animation: { close: { duration: 50 } }259            });260            dialog.element.press(keys.ESC).press(keys.ESC);261            assert.equal(calls, 1);262        });263        it("up arrow moves window up", function() {264            var dialogObject = createWindow({});265            var dialog = dialogObject.wrapper;266            var offset = dialogObject.wrapper.offset();267            dialog.press(keys.UP);268            assert.closeTo(269                dialogObject.wrapper.offset().top,270                offset.top - 10,271                1272            );273        });274        it("down arrow moves window down", function() {275            var dialogObject = createWindow({});276            var dialog = dialogObject.wrapper;277            var offset = dialogObject.wrapper.offset();278            dialog.press(keys.DOWN);279            assert.closeTo(280                dialogObject.wrapper.offset().top,281                offset.top + 10,282                1283            );284        });285        it("left arrow moves window left", function() {286            var dialogObject = createWindow({});287            var dialog = dialogObject.wrapper;288            var offset = dialogObject.wrapper.offset();289            dialog.press(keys.LEFT);290            assert.equal(dialogObject.wrapper.offset().left, offset.left - 10);291        });292        it("right arrow moves window right", function() {293            var dialogObject = createWindow({});294            var dialog = dialogObject.wrapper;295            var offset = dialogObject.wrapper.offset();296            dialog.press(keys.RIGHT);297            assert.equal(dialogObject.wrapper.offset().left, offset.left + 10);298        });299        it("up arrow moves minimized window up", function() {300            var dialogObject = createWindow({});301            dialogObject.minimize();302            var dialog = dialogObject.wrapper;303            var offset = dialogObject.wrapper.offset();304            dialog.press(keys.UP);305            assert.closeTo(306                dialogObject.wrapper.offset().top,307                offset.top - 10,308                1309            );310        });311        it("down arrow moves minimized window down", function() {312            var dialogObject = createWindow({});313            dialogObject.minimize();314            var dialog = dialogObject.wrapper;315            var offset = dialogObject.wrapper.offset();316            dialog.press(keys.DOWN);317            assert.closeTo(318                dialogObject.wrapper.offset().top,319                offset.top + 10,320                1321            );322        });323        it("left arrow moves minimized window left", function() {324            var dialogObject = createWindow({});325            dialogObject.minimize();326            var dialog = dialogObject.wrapper;327            var offset = dialogObject.wrapper.offset();328            dialog.press(keys.LEFT);329            assert.equal(dialogObject.wrapper.offset().left, offset.left - 10);330        });331        it("right arrow moves minimized window right", function() {332            var dialogObject = createWindow({});333            dialogObject.minimize();334            var dialog = dialogObject.wrapper;335            var offset = dialogObject.wrapper.offset();336            dialog.press(keys.RIGHT);337            assert.equal(dialogObject.wrapper.offset().left, offset.left + 10);338        });339        it("ctrl+down arrow expands window", function() {340            var dialogObject = createWindow({ height: 200 });341            var dialog = dialogObject.wrapper;342            dialog.press(keys.DOWN, { ctrlKey: true });343            assert.equal(dialogObject.wrapper.outerHeight(), 210);344        });345        it("ctrl+up arrow shrinks window", function() {346            var dialogObject = createWindow({ height: 200 });347            var dialog = dialogObject.wrapper;348            dialog.press(keys.UP, { ctrlKey: true });349            assert.equal(dialogObject.wrapper.outerHeight(), 190);350        });351        it("ctrl+left arrow shrinks window", function() {352            var dialogObject = createWindow({ width: 200 });353            var dialog = dialogObject.wrapper;354            dialog.press(keys.LEFT, { ctrlKey: true });355            assert.equal(dialogObject.wrapper.outerWidth(), 190);356        });357        it("ctrl+right arrow expands window", function() {358            var dialogObject = createWindow({ width: 200 });359            var dialog = dialogObject.wrapper;360            dialog.press(keys.RIGHT, { ctrlKey: true });361            assert.equal(dialogObject.wrapper.outerWidth(), 210);362        });363        it("ctrl+left takes minWidth into account", function() {364            var dialogObject = createWindow({365                width: 100,366                minWidth: 95367            });368            var dialog = dialogObject.wrapper;369            dialog.press(keys.LEFT, { ctrlKey: true });370            assert.closeTo(dialogObject.wrapper.outerWidth(), 95, 1);371        });372        it("ctrl+right takes maxWidth into account", function() {373            var dialogObject = createWindow({374                width: 100,375                maxWidth: 105376            });377            var dialog = dialogObject.wrapper;378            dialog.press(keys.RIGHT, { ctrlKey: true });379            assert.equal(dialogObject.wrapper.outerWidth(), 105);380        });381        it("ctrl+up takes minHeight into account", function() {382            var dialogObject = createWindow({383                height: 100,384                minHeight: 95385            });386            var dialog = dialogObject.wrapper;387            dialog.press(keys.UP, { ctrlKey: true });388            assert.equal(dialogObject.wrapper.outerHeight(), 95);389        });390        it("ctrl+down takes maxHeight into account", function() {391            var dialogObject = createWindow({392                height: 100,393                maxHeight: 105394            });395            var dialog = dialogObject.wrapper;396            dialog.press(keys.DOWN, { ctrlKey: true });397            assert.closeTo(dialogObject.wrapper.outerHeight(), 105, 1);398        });399        it("alt+p toggles pin", function() {400            var dialogObject = createWindow({401                height: 100,402                maxHeight: 105403            });404            var dialog = dialogObject.wrapper;405            dialog.press(80, { altKey: true });406            assert.isOk(dialogObject.options.pinned);407            dialog.press(80, { altKey: true });408            assert.isOk(!dialogObject.options.pinned);409        });410        it("alt+up maximizes the window", function() {411            var dialogObject = createWindow({412                height: 100,413                maxHeight: 105414            });415            var dialog = dialogObject.wrapper;416            dialog.press(keys.UP, { altKey: true });417            assert.isOk(dialogObject.isMaximized());418        });419        it("alt+down restores a maximized window", function() {420            var dialogObject = createWindow({421                height: 100,422                maxHeight: 105423            });424            var dialog = dialogObject.wrapper;425            dialogObject.maximize();426            dialog.press(keys.DOWN, { altKey: true });427            assert.isOk(!dialogObject.isMaximized());428        });429        it("alt+down minimizes window", function() {430            var dialogObject = createWindow({431                height: 100,432                maxHeight: 105433            });434            var dialog = dialogObject.wrapper;435            dialog.press(keys.DOWN, { altKey: true });436            assert.isOk(dialogObject.isMinimized());437        });438        it("alt+up restores a minimized window", function() {439            var dialogObject = createWindow({440                height: 100,441                maxHeight: 105442            });443            var dialog = dialogObject.wrapper;444            dialogObject.minimize();445            dialog.press(keys.UP, { altKey: true });446            assert.isOk(!dialogObject.isMinimized());447        });448        it("alt+r triggers refresh event", function(done) {449            var timeout = setTimeout(done, 2000);450            var dialogObject = createWindow({451                content: "/base/tests/window/blank.html",452                iframe: true453            });454            dialogObject.one("refresh", function() {455                clearTimeout(timeout);456                assert.isOk(true);457                done();458            });459            dialogObject.element.press(82, { altKey: true });460        });461        it("resizing window with the keyboard updates widget options", function() {462            var initialSize = 200,463                dialog = createWindow({464                    width: initialSize,465                    height: initialSize466                });467            dialog.wrapper.press(keys.RIGHT, { ctrlKey: true });468            dialog.wrapper.press(keys.DOWN, { ctrlKey: true });469            assert.equal(dialog.options.width, initialSize + 10 + "px");470            assert.equal(dialog.options.height, initialSize + 10 + "px");471        });472        it("hitting arrow keys in nested input does not trigger keyboard support", function() {473            var dialogObject = createWindow({474                content: {475                    template: "<input class='foo' />"476                }477            });478            var dialog = dialogObject.element;479            var offset = dialogObject.wrapper.offset();480            dialog.find("input").press(keys.UP);481            assert.equal(dialogObject.wrapper.offset().top, offset.top);482        });483        it("hitting escape in a non-closable window does not close it", function() {484            var handler = spy();485            var dialogObject = createWindow({486                actions: ["custom"],487                close: handler488            });489            dialogObject.element.press(keys.ESC);490            assert.isOk(!handler.calls);491        });492        it("opening and closing modal Windows positions the modal overlay correctly over all other instances but one", function() {493            var win1 = createWindow({ modal: true, animate: false }),494                win2 = createWindow({ modal: true, animate: false }),495                win3 = createWindow({ modal: true, animate: false }),496                modalOverlay = Mocha.fixture497                    .closest("body")498                    .children(".k-overlay");499            assert.isOk(500                modalOverlay.css("z-index") < win3.wrapper.css("z-index")501            );502            assert.isOk(503                modalOverlay.css("z-index") > win2.wrapper.css("z-index")504            );505            win3.close();506            assert.isOk(507                modalOverlay.css("z-index") < win2.wrapper.css("z-index")508            );509            assert.isOk(510                modalOverlay.css("z-index") > win1.wrapper.css("z-index")511            );512        });513        it("Resizing with keyboard raises resize event", function() {514            var dialogObject = createWindow({515                resize: function() {516                    assert.isOk(true);517                }518            });519            dialogObject.wrapper.children(".k-window-content").trigger({520                type: "keydown",521                keyCode: 40,522                ctrlKey: true523            });524        });525        it("resizeEnd event is triggered after resizing", function() {526            var handler = spy();527            var dialog = createWindow({528                resizeEnd: handler529            });530            dialog.resizing.dragend({531                currentTarget: dialog.wrapper532            });533            assert.isOk(handler.calls);534        });535        it("preventing resizeStart stops resizing", function() {536            var handler = spy();537            var dialog = createWindow({538                resizeStart: function(e) {539                    e.preventDefault();540                },541                resizeEnd: handler,542                resize: handler543            });544            dialog.resizing.dragstart();545            dialog.resizing.drag();546            dialog.resizing.dragend();547            assert.isOk(!dialog.resizing.initialPosition);548            assert.isOk(!handler.calls);549        });550        it("preventing dragstart stops dragging", function() {551            var handler = spy();552            var dialog = createWindow({553                dragstart: function(e) {554                    e.preventDefault();555                },556                dragend: handler557            });558            dialog.dragging.dragstart();559            dialog.dragging.dragend();560            assert.isOk(!dialog.initialWindowPosition);561            assert.isOk(!handler.calls);562        });563        it("restore() triggers restore event", function() {564            var triggers = 0,565                dialog = createWindow({566                    actions: ["Maximize", "Restore"],567                    restore: function() {568                        triggers++;569                    }570                });571            dialog.maximize();572            dialog.restore();573            assert.equal(triggers, 1);574        });575        it("restore() triggers restore event", function() {576            var triggers = 0,577                dialog = createWindow({578                    restore: function() {579                        triggers++;580                    }581                });582            dialog.maximize();583            dialog.restore();584            assert.equal(triggers, 1);585        });586        it("alt+up triggers restore event", function() {587            var triggers = 0,588                dialog = createWindow({589                restore: function(ev) {590                    triggers++;591                }592            });593            dialog.minimize();594            dialog.wrapper.press(keys.UP, { altKey: true });595            assert.isOk(triggers, 1);596        });597        it("alt+down triggers restore event", function() {598            var triggers = 0,599                dialog = createWindow({600                restore: function(ev) {601                    triggers++;602                }603            });604            dialog.maximize();605            dialog.wrapper.press(keys.DOWN, { altKey: true });606            assert.isOk(triggers, 1);607        });608    });...initialization.js
Source:initialization.js  
1(function() {2    var form;3    function createWindow(options, element) {4        element = element || $("<div class='wnd' />").appendTo(Mocha.fixture);5        return element.kendoWindow(options).data("kendoWindow");6    }7    function createHighWindow(options, element, innerHeight) {8        element =9            element ||10            $(11                "<div class='wnd'><div style='height:" +12                    innerHeight +13                    "px'></div></div>"14            ).appendTo(Mocha.fixture);15        return element.kendoWindow(options).data("kendoWindow");16    }17    describe("initialization", function() {18        beforeEach(function() {19            $.mockjax({20                url: "echo",21                responseTime: 0,22                response: function(request) {23                    this.contentType = "text/json";24                    this.responseText = request.data;25                }26            });27            $.mockjax({28                url: /foo|telerik\.com/i,29                responseText: "foo bar baz"30            });31            Mocha.fixture.html(__html__["tests/window/templates-fixture.html"]);32        });33        afterEach(function() {34            Mocha.fixture35                .closest("body")36                .find(".k-window-content")37                .each(function(idx, element) {38                    $(element)39                        .data("kendoWindow")40                        .destroy();41                });42            Mocha.fixture43                .closest("body")44                .find(".k-overlay")45                .remove();46            $.mockjax.clear();47        });48        it("creates default html structure", function() {49            var dialog = createWindow();50            assert.isOk(dialog.wrapper.is(".k-widget, .k-window"));51            assert.isOk(52                dialog.wrapper53                    .children()54                    .eq(0)55                    .is(".k-window-titlebar, .k-header")56            );57        });58        it("construction triggers open and activate events", function() {59            var dialog = createWindow({60                open: function() {61                    assert.isOk(true);62                },63                activate: function() {64                    assert.isOk(true);65                }66            });67        });68        it("construction does not trigger open and activate events on hidden windows", function() {69            var isActivated = false,70                isOpened = false;71            var dialog = createWindow(72                {73                    open: function() {74                        isOpened = true;75                    },76                    activate: function() {77                        isActivated = true;78                    },79                    visible: false80                },81                $("<div />")82                    .appendTo(Mocha.fixture)83                    .hide()84            );85            assert.isOk(!isActivated);86            assert.isOk(!isOpened);87        });88        it("construction of modal window shows overlay", function() {89            var dialog = createWindow({90                modal: true91            });92            assert.isOk($(".k-overlay").is(":visible"));93        });94        it("hiding second modal window does not hide first overlay", function() {95            var dialog1 = createWindow({96                    modal: true,97                    animation: {98                        open: false,99                        close: false100                    }101                }),102                dialog2 = createWindow({103                    modal: true,104                    animation: {105                        open: false,106                        close: false107                    }108                });109            dialog2.close();110            assert.isOk($(".k-overlay").is(":visible"));111            dialog1.close();112            assert.isOk(!$(".k-overlay").is(":visible"));113            dialog1.open();114            assert.isOk($(".k-overlay").is(":visible"));115        });116        it("destroy() does not delete overlay if there are other opened modal windows", function() {117            var dialog1 = createWindow({118                    modal: true119                }),120                dialog2 = createWindow({121                    modal: true122                });123            dialog2.destroy();124            assert.equal($(".k-overlay").length, 1);125            assert.isOk($(".k-overlay").is(":visible"));126            dialog1.destroy();127            assert.equal($(".k-overlay").length, 0);128        });129        it("creating a modal window after closing another shows overlay", function() {130            var dialog1 = createWindow({131                modal: true132            });133            dialog1.close();134            var dialog2 = createWindow({135                modal: true136            });137            assert.isOk($(".k-overlay").is(":visible"));138        });139        it("creating a window with a remote `content` creates iframe", function() {140            var dialog = createWindow({141                    content: "http://www.telerik.com/",142                    title: "title"143                }),144                iframe = dialog.element.find("iframe");145            assert.equal(iframe.length, 1);146            assert.equal(iframe.attr("title"), "title");147            assert.equal(iframe.attr("src"), "http://www.telerik.com/");148        });149        it("creating a window with a `content` on the same server does not create iframe", function() {150            var dialog = createWindow({151                content: "foo"152            });153            assert.equal(dialog.element.find("iframe").length, 0);154        });155        it("creating a window without a `content` does not create iframe", function() {156            var dialog = createWindow();157            assert.equal(dialog.element.find("iframe").length, 0);158        });159        it("creating a modal adds overlay and places it before the window markup", function() {160            var dialog = createWindow({161                modal: true162            });163            assert.isOk(dialog.wrapper.prev("div").is(".k-overlay"));164        });165        it("creating a second modal moves overlay after the first one", function() {166            var dialog = createWindow({167                    modal: true168                }),169                overlappingDialog = createWindow({170                    modal: true171                });172            assert.equal($(".k-overlay").length, 1);173            assert.isOk(!dialog.wrapper.prev("div").is(".k-overlay"));174            assert.isOk(overlappingDialog.wrapper.prev("div").is(".k-overlay"));175            assert.deepEqual(176                dialog.wrapper.next("div")[0],177                overlappingDialog.wrapper.prev("div")[0]178            );179        });180        it("creating a second dialog with a content frame overlays the first one", function() {181            var firstWindow = createWindow({182                    content: "http://www.telerik.com"183                }),184                secondWindow = createWindow();185            assert.isOk(firstWindow.element.find("> .k-overlay").length);186        });187        it("specifying iframe=true creates iframe for local URL", function() {188            var dialog = createWindow({ iframe: true, content: "foo" }),189                iframe = dialog.element.find("iframe");190            assert.isOk(iframe.length, 1);191            assert.equal(iframe.attr("src"), "foo");192        });193        it("specifying iframe=false does not create iframe for remote URL", function() {194            var dialog = createWindow({195                    iframe: false,196                    content: "http://www.telerik.com/"197                }),198                iframe = dialog.element.find("iframe");199            assert.equal(iframe.length, 0);200        });201        it("creating a window with an iframe adds a k-window-iframecontent class", function() {202            var dialog = createWindow({203                iframe: true,204                content: "about:blank",205                height: 100206            });207            assert.isOk(dialog.element.hasClass("k-window-iframecontent"));208        });209        it("creating window with minHeight constrains larger content with inner minHeight", function() {210            var dialog = createWindow({211                minHeight: 200212            });213            assert.equal(parseInt(dialog.wrapper.css("minHeight"), 10), 200);214        });215        it("creating window with size sets the class", function() {216            var dialog = createWindow({217                minHeight: 200,218                size: "small"219            });220            assert.isOk(dialog.wrapper.hasClass("k-window-sm"));221        });222        it("creating window with preventScroll stop the document scrolling", function() {223            var dialog = createWindow({224                minHeight: 200,225                visible: true,226                modal: {227                    preventScroll: true228                }229            });230            assert.equal("hidden", $("body").css("overflow"));231        });232        it("closing window with preventScroll stop the document scrolling", function() {233            var dialog = createWindow({234                minHeight: 200,235                visible: true,236                modal: {237                    preventScroll: true238                }239            });240            dialog.close();241            assert.equal("visible", $("body").css("overflow"));242        });243        it("content.template", function() {244            var dialog = createWindow({245                content: {246                    template: "foo #= 1 + 1 #"247                }248            });249            assert.equal(dialog.element.text(), "foo 2");250        });251        it("content.template is used when fetching jsonp data", function(done) {252            var dialog = createWindow({253                content: {254                    url: "echo",255                    dataType: "json",256                    data: {257                        foo: "bar"258                    },259                    template: "templated #= foo #",260                    complete: function() {261                        assert.equal(dialog.element.text(), "templated bar");262                        done();263                    }264                }265            });266        });267        it("title=false does not render title and adds css class", function() {268            var dialog = createWindow({269                title: false270            });271            assert.equal(dialog.wrapper.find(".k-window-titlebar").length, 0);272            assert.isOk(dialog.wrapper.is(".k-window-titleless"));273        });274        it("k-rtl class is not rendered by default", function() {275            var dialog = createWindow({276                title: "foo"277            });278            assert.isOk(!dialog.wrapper.hasClass("k-rtl"));279        });280        it("k-rtl class is rendered when in k-rtl container", function() {281            var element = $("<div class='k-rtl'><div></div></div>").appendTo(282                    Mocha.fixture283                ),284                dialog = createWindow({}, element.find("> div"));285            assert.isOk(dialog.wrapper.hasClass("k-rtl"));286        });287        it("invisible windows do not interfere with overlay", function() {288            var dialog1 = $("<div />")289                    .hide()290                    .appendTo(Mocha.fixture),291                dialog2 = dialog1.clone().appendTo(Mocha.fixture);292            dialog1.kendoWindow({293                visible: false,294                animation: false,295                modal: true296            });297            dialog1298                .show()299                .data("kendoWindow")300                .open();301            dialog2.kendoWindow({302                visible: false,303                animation: false,304                modal: true305            });306            assert.isOk($(".k-overlay").is(":visible"));307        });308        it("visible:false option is inferred from content element", function() {309            var div = $("<div style='display: none'>foo</div>").appendTo(310                    Mocha.fixture311                ),312                clientObject;313            div.kendoWindow();314            clientObject = div.data("kendoWindow");315            assert.isOk(clientObject.wrapper.is(":hidden"));316            assert.isOk(!clientObject.wrapper.hasClass("k-display-inline-flex"));317            assert.equal(div.css("display"), "block");318            assert.isOk(!clientObject.options.visible);319        });320        it("visible:true option is inferred from content element", function() {321            var div = $("<div>foo</div>").appendTo(Mocha.fixture),322                clientObject;323            div.kendoWindow();324            clientObject = div.data("kendoWindow");325            assert.isOk(clientObject.wrapper.is(":visible"));326            assert.isOk(div.is(":visible"));327            assert.isOk(clientObject.options.visible);328        });329        it("visible: false creates hidden windows", function() {330            var div = $("<div>foo</div>").appendTo(Mocha.fixture),331                clientObject;332            div.kendoWindow({333                visible: false,334                refresh: function() {335                    this.center();336                    this.open();337                }338            });339            clientObject = div.data("kendoWindow");340            assert.isOk(!clientObject.wrapper.is(":visible"));341            assert.isOk(!clientObject.wrapper.hasClass("k-display-inline-flex"));342            assert.isOk(!div.is(":visible"));343            assert.isOk(!clientObject.options.visible);344        });345        it("scripts in window are executed only once", function() {346            window.triggers = 1;347            $("#div-with-script-child").kendoWindow();348            assert.equal(window.triggers, 1);349        });350        it("scripts with type in window are executed only once", function() {351            window.triggers = 1;352            $("#div-with-script-with-type").kendoWindow();353            assert.equal(window.triggers, 1);354        });355        it("template script tags are not removed from window", function() {356            $("#div-with-template").kendoWindow();357            assert.equal($("#kendo-template").length, 1);358        });359        it("width is constrained by minWidth", function() {360            var dialog = createWindow({ minWidth: 100, width: 90 });361            assert.equal(dialog.wrapper.outerWidth(), 100);362        });363        it("width is constrained by maxWidth", function() {364            var dialog = createWindow({ maxWidth: 100, width: 190 });365            assert.equal(dialog.wrapper.outerWidth(), 100);366        });367        it("height is constrained by minHeight", function() {368            var dialog = createWindow({ minHeight: 100, height: 90 });369            assert.equal(dialog.wrapper.outerHeight(), 100);370        });371        it("height is constrained by maxHeight", function() {372            var dialog = createWindow({ maxHeight: 100, height: 190 });373            assert.equal(dialog.wrapper.outerHeight(), 100);374        });375        it("creating window with string width", function() {376            var dialog = createWindow({ width: "190px" });377            assert.equal(dialog.wrapper.outerWidth(), 190);378        });379        it("creating window with percent width", function() {380            var dialog = createWindow({ width: "190%" });381            assert.equal(dialog.wrapper[0].style.width, "190%");382        });383        it("creating window with em width", function() {384            var dialog = createWindow({ width: "10em" });385            assert.equal(dialog.wrapper[0].style.width, "10em");386        });387        it("creating window with em width", function() {388            var dialog = createWindow({ width: "auto" });389            assert.equal(dialog.wrapper[0].style.width, "auto");390        });391        it("creating window with literal string height", function() {392            var dialog = createWindow({ height: "190px" });393            assert.equal(dialog.wrapper.outerHeight(), 190);394        });395        it("creating window with percent height", function() {396            var dialog = createWindow({ height: "190%" });397            assert.equal(dialog.wrapper[0].style.height, "190%");398        });399        it("creating window with em height", function() {400            var dialog = createWindow({ height: "10em" });401            assert.equal(dialog.wrapper[0].style.height, "10em");402        });403        it("creating window with em height", function() {404            var dialog = createWindow({ height: "auto" });405            assert.equal(dialog.wrapper[0].style.height, "auto");406        });407        it("passing empty actions array does not show any buttons in title bar", function() {408            var dialog = createWindow({ actions: [] });409            assert.equal(dialog.wrapper.find(".k-window.action").length, 0);410        });411        it("creating pinned window applies a position:fixed style", function() {412            var dialog = createWindow({ pinned: true });413            assert.equal(dialog.wrapper.css("position"), "fixed");414        });415        it("creating pinned window with a Pin command adds an Unpin button", function() {416            var dialog = createWindow({ pinned: true, actions: ["Pin"] });417            assert.equal(dialog.wrapper.find(".k-i-unpin").length, 1);418        });419        it("creating pinned window pins the window if initially visible", function() {420            var dialog = createWindow({421                pinned: true,422                position: {423                    top: 0,424                    left: 0425                }426            });427            assert.equal(dialog.wrapper.css("position"), "fixed");428        });429        it("creating pinned and visible:false window pins the window when shown", function() {430            var dialog = createWindow({431                pinned: true,432                visible: false,433                position: {434                    top: 0,435                    left: 0436                }437            });438            assert.notEqual(dialog.wrapper.css("position"), "fixed");439            dialog.open();440            assert.equal(dialog.wrapper.css("position"), "fixed");441        });442        it("center method should pin if pinned is enabled and element is hidden", function() {443            var dialog = createWindow(444                {445                    pinned: true,446                    visible: false447                },448                $("<div class='wnd' style='display: none;'></div>").appendTo(449                    Mocha.fixture450                )451            );452            assert.notEqual(dialog.wrapper.css("position"), "fixed");453            dialog.center();454            assert.equal(dialog.wrapper.css("position"), "fixed");455        });456        it("creating window with an int zero top position applies a top style", function() {457            var dialog = createWindow({458                position: {459                    top: 0460                }461            });462            assert.equal(dialog.wrapper.css("top"), "0px");463        });464        it("creating window with an int non-zero top position applies a top style", function() {465            var dialog = createWindow({466                position: {467                    top: 1468                }469            });470            assert.equal(dialog.wrapper.css("top"), "1px");471        });472        it("creating window with a string top position applies a top style", function() {473            var dialog = createWindow({474                position: {475                    top: "1px"476                }477            });478            assert.equal(dialog.wrapper.css("top"), "1px");479        });480        it("creating window with an int zero left position applies a left style", function() {481            var dialog = createWindow({482                position: {483                    left: 0484                }485            });486            assert.equal(dialog.wrapper.css("left"), "0px");487        });488        it("creating window with an int non-zero left position applies a left style", function() {489            var dialog = createWindow({490                position: {491                    left: 1492                }493            });494            assert.equal(dialog.wrapper.css("left"), "1px");495        });496        it("creating window with a string left position applies a left style", function() {497            var dialog = createWindow({498                position: {499                    left: "1px"500                }501            });502            assert.equal(dialog.wrapper.css("left"), "1px");503        });504    });505    describe("appendTo option", function() {506        beforeEach(function() {507            form = $("<form id='myForm'></form>").appendTo(Mocha.fixture);508        });509        afterEach(function() {510            Mocha.fixture511                .closest("body")512                .find(".k-window-content")513                .each(function(idx, element) {514                    $(element)515                        .data("kendoWindow")516                        .destroy();517                });518            Mocha.fixture519                .closest("body")520                .find(".k-overlay")521                .remove();522            form.remove();523        });524        it("appends window to given container", function() {525            var dialog = createWindow({526                appendTo: "form#myForm"527            });528            assert.equal(dialog.wrapper.parent()[0], form[0]);529        });530        it("passing element appends window to given container", function() {531            var dialog = createWindow({532                appendTo: form[0]533            });534            assert.equal(dialog.wrapper.parent()[0], form[0]);535        });536        it("modal windows append single overlay to container", function() {537            createWindow({ appendTo: form, modal: true });538            createWindow({ appendTo: form, modal: true });539            assert.equal(form.children(".k-overlay").length, 1);540        });541        it("window content element is visible after initialization if wrapper widget with visible:false is initialized inside a hidden container", function() {542            Mocha.fixture.css("visibility", "hidden");543            var dialog = createWindow(544                { visible: false },545                $("<div class='wnd' />")546                    .appendTo(Mocha.fixture)547                    .hide()548            );549            dialog.open();550            Mocha.fixture.css("visibility", "");551            assert.equal(dialog.element.css("visibility"), "visible");552        });553        it("initializing with scrollable: false adds overflow: hidden", function() {554            var dialog = createWindow({ scrollable: false });555            assert.equal(dialog.element.css("overflow"), "hidden");556        });557        it("scrollable: false is persisted upon activate", function() {558            var dialog = createWindow({ visible: false, scrollable: false });559            dialog.open();560            assert.equal(dialog.element.css("overflow"), "hidden");561        });562        it("scrollable: false through setOptions adds overflow:hidden", function() {563            var dialog = createWindow({});564            dialog.setOptions({ scrollable: false });565            assert.equal(dialog.element.css("overflow"), "hidden");566        });567        it("should not scroll down to Window if not modal and initially visible", function() {568            jasmine.clock().install();569            createWindow({570                title: "Window Web: title 1t",571                content: "test",572                position: { top: 8240 , left: 50 },573                height: "470px",574                width: "1450px",575                animation: false576            });577            jasmine.clock().tick(1);578            assert.equal(document.documentElement.scrollTop, 0);579            jasmine.clock().uninstall();580        });581    });...sample.js
Source:sample.js  
...52    createWindow : function(){53        var desktop = this.app.getDesktop();54        var win = desktop.getWindow('grid-win');55        if(!win){56            win = desktop.createWindow({57                id: 'grid-win',58                title:'Grid Window',59                width:740,60                height:480,61                iconCls: 'icon-grid',62                shim:false,63                animCollapse:false,64                constrainHeader:true,65                layout: 'fit',66                items:67                    new Ext.grid.GridPanel({68                        border:false,69                        ds: new Ext.data.Store({70                            reader: new Ext.data.ArrayReader({}, [71                               {name: 'company'},72                               {name: 'price', type: 'float'},73                               {name: 'change', type: 'float'},74                               {name: 'pctChange', type: 'float'}75                            ]),76                            data: Ext.grid.dummyData77                        }),78                        cm: new Ext.grid.ColumnModel([79                            new Ext.grid.RowNumberer(),80                            {header: "Company", width: 120, sortable: true, dataIndex: 'company'},81                            {header: "Price", width: 70, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},82                            {header: "Change", width: 70, sortable: true, dataIndex: 'change'},83                            {header: "% Change", width: 70, sortable: true, dataIndex: 'pctChange'}84                        ]),85                        viewConfig: {86                            forceFit:true87                        },88                        //autoExpandColumn:'company',89                        tbar:[{90                            text:'Add Something',91                            tooltip:'Add a new row',92                            iconCls:'add'93                        }, '-', {94                            text:'Options',95                            tooltip:'Blah blah blah blaht',96                            iconCls:'option'97                        },'-',{98                            text:'Remove Something',99                            tooltip:'Remove the selected item',100                            iconCls:'remove'101                        }]102                    })103            });104        }105        win.show();106    }107});108MyDesktop.TabWindow = Ext.extend(Ext.app.Module, {109    id:'tab-win',110    init : function(){111        this.launcher = {112            text: 'Tab Window',113            iconCls:'tabs',114            handler : this.createWindow,115            scope: this116        }117    },118    createWindow : function(){119        var desktop = this.app.getDesktop();120        var win = desktop.getWindow('tab-win');121        if(!win){122            win = desktop.createWindow({123                id: 'tab-win',124                title:'Tab Window',125                width:740,126                height:480,127                iconCls: 'tabs',128                shim:false,129                animCollapse:false,130                border:false,131                constrainHeader:true,132                layout: 'fit',133                items:134                    new Ext.TabPanel({135                        activeTab:0,136                        items: [{137                            title: 'Tab Text 1',138                            header:false,139                            html : '<p>Something useful would be in here.</p>',140                            border:false141                        },{142                            title: 'Tab Text 2',143                            header:false,144                            html : '<p>Something useful would be in here.</p>',145                            border:false146                        },{147                            title: 'Tab Text 3',148                            header:false,149                            html : '<p>Something useful would be in here.</p>',150                            border:false151                        },{152                            title: 'Tab Text 4',153                            header:false,154                            html : '<p>Something useful would be in here.</p>',155                            border:false156                        }]157                    })158            });159        }160        win.show();161    }162});163MyDesktop.AccordionWindow = Ext.extend(Ext.app.Module, {164    id:'acc-win',165    init : function(){166        this.launcher = {167            text: 'Accordion Window',168            iconCls:'accordion',169            handler : this.createWindow,170            scope: this171        }172    },173    createWindow : function(){174        var desktop = this.app.getDesktop();175        var win = desktop.getWindow('acc-win');176        if(!win){177            win = desktop.createWindow({178                id: 'acc-win',179                title: 'Accordion Window',180                width:250,181                height:400,182                iconCls: 'accordion',183                shim:false,184                animCollapse:false,185                constrainHeader:true,186                tbar:[{187                    tooltip:{title:'Rich Tooltips', text:'Let your users know what they can do!'},188                    iconCls:'connect'189                },'-',{190                    tooltip:'Add a new user',191                    iconCls:'user-add'192                },' ',{193                    tooltip:'Remove the selected user',194                    iconCls:'user-delete'195                }],196                layout:'accordion',197                border:false,198                layoutConfig: {199                    animate:false200                },201                items: [202                    new Ext.tree.TreePanel({203                        id:'im-tree',204                        title: 'Online Users',205                        loader: new Ext.tree.TreeLoader(),206                        rootVisible:false,207                        lines:false,208                        autoScroll:true,209                        tools:[{210                            id:'refresh',211                            on:{212                                click: function(){213                                    var tree = Ext.getCmp('im-tree');214                                    tree.body.mask('Loading', 'x-mask-loading');215                                    tree.root.reload();216                                    tree.root.collapse(true, false);217                                    setTimeout(function(){ // mimic a server call218                                        tree.body.unmask();219                                        tree.root.expand(true, true);220                                    }, 1000);221                                }222                            }223                        }],224                        root: new Ext.tree.AsyncTreeNode({225                            text:'Online',226                            children:[{227                                text:'Friends',228                                expanded:true,229                                children:[{230                                    text:'Jack',231                                    iconCls:'user',232                                    leaf:true233                                },{234                                    text:'Brian',235                                    iconCls:'user',236                                    leaf:true237                                },{238                                    text:'Jon',239                                    iconCls:'user',240                                    leaf:true241                                },{242                                    text:'Tim',243                                    iconCls:'user',244                                    leaf:true245                                },{246                                    text:'Nige',247                                    iconCls:'user',248                                    leaf:true249                                },{250                                    text:'Fred',251                                    iconCls:'user',252                                    leaf:true253                                },{254                                    text:'Bob',255                                    iconCls:'user',256                                    leaf:true257                                }]258                            },{259                                text:'Family',260                                expanded:true,261                                children:[{262                                    text:'Kelly',263                                    iconCls:'user-girl',264                                    leaf:true265                                },{266                                    text:'Sara',267                                    iconCls:'user-girl',268                                    leaf:true269                                },{270                                    text:'Zack',271                                    iconCls:'user-kid',272                                    leaf:true273                                },{274                                    text:'John',275                                    iconCls:'user-kid',276                                    leaf:true277                                }]278                            }]279                        })280                    }), {281                        title: 'Settings',282                        html:'<p>Something useful would be in here.</p>',283                        autoScroll:true284                    },{285                        title: 'Even More Stuff',286                        html : '<p>Something useful would be in here.</p>'287                    },{288                        title: 'My Stuff',289                        html : '<p>Something useful would be in here.</p>'290                    }291                ]292            });293        }294        win.show();295    }296});297// for example purposes298var windowIndex = 0;299MyDesktop.BogusModule = Ext.extend(Ext.app.Module, {300    init : function(){301        this.launcher = {302            text: 'Window '+(++windowIndex),303            iconCls:'bogus',304            handler : this.createWindow,305            scope: this,306            windowId:windowIndex307        }308    },309    createWindow : function(src){310        var desktop = this.app.getDesktop();311        var win = desktop.getWindow('bogus'+src.windowId);312        if(!win){313            win = desktop.createWindow({314                id: 'bogus'+src.windowId,315                title:src.text,316                width:640,317                height:480,318                html : '<p>Something useful would be in here.</p>',319                iconCls: 'bogus',320                shim:false,321                animCollapse:false,322                constrainHeader:true323            });324        }325        win.show();326    }327});...app.js
Source:app.js  
1// open a single window2var win = Ti.UI.createWindow({3	backgroundColor:'#fff',tabBarHidden:true, barColor:"#999", title:"Blur Demos"4});5var data =[6	{title:"Basic Blur", hasChild:true, header:"Basic Blur Demos", itemId:-2},7	{title:"Blur Background", hasChild:true, header:"View Demos", itemId:0},8	{title:"Blur Overlay", hasChild:true, itemId:1},9	{title:"Blur & Tinted Overlay", hasChild:true, itemId:2},10	{title:"applyBlurTo From View", hasChild:true, header:"Image Demos", itemId:3},11	{title:"applyBlurTo From Blob", hasChild:true, itemId:4},12	{title:"Overlay applyBlurTo - View", hasChild:true, itemId:5},13	{title:"Overlay applyBlurTo - Image", hasChild:true, itemId:6},14	{title:"iOS Blur", hasChild:true, header:"GPU ImageView Demos", itemId:7},15	{title:"Box Blur", hasChild:true, itemId:8},16	{title:"Gaussian Blur", hasChild:true, itemId:9},17	{title:"Kind of Live Blur on scroll", hasChild:true, header:"Live Blur Demos",itemId:10},18	{title:"Kind of Live Blur", hasChild:true,itemId:11}	19];20var tableView = Ti.UI.createTableView({21	width:Ti.UI.FILL, height:Ti.UI.FILL, data:data	22});23win.add(tableView);24tableView.addEventListener('click',function(e){25	if(e.rowData.itemId===-2){26		tabGroup.activeTab.open(require('basic_blur_view_example').createWindow());27	}28	if(e.rowData.itemId===0){29		tabGroup.activeTab.open(require('overlay_bg_demo').createWindow());30	}31	if(e.rowData.itemId===1){32		tabGroup.activeTab.open(require('overlay_cropped').createWindow());33	}34	if(e.rowData.itemId===2){35		tabGroup.activeTab.open(require('overlay_cropped_tinted').createWindow());36	}37	if(e.rowData.itemId===3){38		tabGroup.activeTab.open(require('image_from_view').createWindow());39	}	40	if(e.rowData.itemId===4){41		tabGroup.activeTab.open(require('image_from_blob').createWindow());42	}43	if(e.rowData.itemId===5){44		tabGroup.activeTab.open(require('image_overlay_view').createWindow());45	}46	if(e.rowData.itemId===6){47		tabGroup.activeTab.open(require('image_overlay_image').createWindow());48	}	49	if(e.rowData.itemId===7){50		tabGroup.activeTab.open(require('GPU_IOS_Blur').createWindow());51	}	52	if(e.rowData.itemId===8){53		tabGroup.activeTab.open(require('GPU_Box_Blur').createWindow());54	}	55	if(e.rowData.itemId===9){56		tabGroup.activeTab.open(require('GPU_Gaussian_Blur').createWindow());57	}		58	if(e.rowData.itemId===10){59		tabGroup.activeTab.open(require('blur_on_scroll').createWindow());60	}	61	if(e.rowData.itemId===11){62		tabGroup.activeTab.open(require('timed_live_blur').createWindow());63	}					64});65var tabGroup = Titanium.UI.createTabGroup();66tabGroup.addTab(Ti.UI.createTab({67	window:win68}));...Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3    .remote(options)4    .init()5    .getTitle().then(function(title) {6        console.log('Title was: ' + title);7    })8    .end();Using AI Code Generation
1describe('webdriver.io page', () => {2    it('should have the right title', () => {3        const title = browser.getTitle()4        expect(title).toEqual('WebdriverIO · Next-gen browser and mobile automation test framework for Node.js')5    })6})7describe('webdriver.io page', () => {8    it('should have the right title', () => {9        const title = browser.getTitle()10        expect(title).toEqual('WebdriverIO · Next-gen browser and mobile automation test framework for Node.js')11    })12})Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3    .remote(options)4    .init()5    .setValue('input[name="q"]','webdriverio')6    .click('button[name="btnK"]')7    .getTitle().then(function(title) {8        console.log('Title was: ' + title);9    })10    .end();Using AI Code Generation
1const assert = require('assert');2describe('webdriver.io page', () => {3    it('should have the right title', () => {4        const title = browser.getTitle();5        assert.strictEqual(title, 'WebdriverIO · Next-gen WebDriver test framework for Node.js');6    });7});8exports.config = {9};10exports.config = {11};12exports.config = {13};14exports.config = {15    capabilities: [{16    }],17};18exports.config = {19};20exports.config = {21    mochaOpts: {22    },23};24exports.config = {25    onPrepare: function (config, capabilities) {26        console.log('Starting test runner...');27    },28    onComplete: function() {29        console.log('Test runner finished.');30    },31};32exports.config = {33};34exports.config = {35    cucumberOpts: {Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3var client = webdriverio.remote(options);4    .init()5    .getTitle().then(function(title) {6        console.log('Title was: ' + title);7    })8    .end();Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3var client = webdriverio.remote(options);4    .init()5    .setValue('input[name="q"]','WebdriverIO')6    .click('button[name="btnK"]')7    .getTitle().then(function(title) {8        console.log('Title was: ' + title);9    })10    .end();Using AI Code Generation
1const { remote } = require('webdriverio');2const opts = {3    capabilities: {4    }5};6(async () => {7    const browser = await remote(opts);8    console.log(await browser.getTitle());9    await browser.deleteSession();10})();11const { remote } = require('webdriverio');12const opts = {13    capabilities: {14    }15};16(async () => {17    const browser = await remote(opts);18    console.log(await browser.getTitle());19    await browser.deleteSession();20})();21const { remote } = require('webdriverio');22const opts = {23    capabilities: {24    }25};26(async () => {27    const browser = await remote(opts);28    console.log(await browser.getTitle());29    await browser.deleteSession();30})();31const { remote } = require('webdriverio');32const opts = {33    capabilities: {34    }35};36(async () => {37    const browser = await remote(opts);38    console.log(await browser.getTitle());39    await browser.deleteSession();40})();41const { remote } = require('webdriverio');42const opts = {43    capabilities: {44    }45};46(async () => {47    const browser = await remote(opts);48    console.log(await browser.getTitle());49    await browser.deleteSession();50})();51const { remote } = require('webdriverio');52const opts = {53    capabilities: {54    }55};56(async () => {57    const browser = await remote(opts);Using AI Code Generation
1describe('Test Window', function() {2    it('should open a new window', function () {3    });4});5describe('Test Window', function() {6    it('should close the new window', function () {7        browser.closeWindow();8    });9});10describe('Test Window', function() {11    it('should switch to the new window', function () {12        browser.switchWindow('WebdriverIO window');13    });14});15describe('Test Window', function() {16    it('should get the list of window handles', function () {17        var handles = browser.getWindowHandles();18    });19});20describe('Test Window', function() {21    it('should get the current window handle', function () {22        var handle = browser.getWindowHandle();23    });24});25describe('Test Window', function() {26    it('should close the current window', function () {Wondering what could be a next-gen browser and mobile test automation framework that is also simple and concise? Yes, that’s right, it's WebdriverIO. Since the setup is very easy to follow compared to Selenium testing configuration, you can configure the features manually thereby being the center of attraction for automation testing. Therefore the testers adopt WedriverIO to fulfill their needs of browser testing.
Learn to run automation testing with WebdriverIO tutorial. Go from a beginner to a professional automation test expert with LambdaTest WebdriverIO tutorial.
Running Your First Automation Script - Learn the steps involved to execute your first Test Automation Script using WebdriverIO since the setup is very easy to follow and the features can be configured manually.
Selenium Automation With WebdriverIO - Read more about automation testing with WebdriverIO and how it supports both browsers and mobile devices.
Browser Commands For Selenium Testing - Understand more about the barriers faced while working on your Selenium Automation Scripts in WebdriverIO, the ‘browser’ object and how to use them?
Handling Alerts & Overlay In Selenium - Learn different types of alerts faced during automation, how to handle these alerts and pops and also overlay modal in WebdriverIO.
How To Use Selenium Locators? - Understand how Webdriver uses selenium locators in a most unique way since having to choose web elements very carefully for script execution is very important to get stable test results.
Deep Selectors In Selenium WebdriverIO - The most popular automation testing framework that is extensively adopted by all the testers at a global level is WebdriverIO. Learn how you can use Deep Selectors in Selenium WebdriverIO.
Handling Dropdown In Selenium - Learn more about handling dropdowns and how it's important while performing automated browser testing.
Automated Monkey Testing with Selenium & WebdriverIO - Understand how you can leverage the amazing quality of WebdriverIO along with selenium framework to automate monkey testing of your website or web applications.
JavaScript Testing with Selenium and WebdriverIO - Speed up your Javascript testing with Selenium and WebdriverIO.
Cross Browser Testing With WebdriverIO - Learn more with this step-by-step tutorial about WebdriverIO framework and how cross-browser testing is done with WebdriverIO.
Get 100 minutes of automation test minutes FREE!!
