TabControl

article/2025/10/10 23:38:48

jquery主体:

 var TabControl = function (ops) {this._ops = {items: ops.items || [],hashItems: {},selectedIndex: ops.selectedIndex || 0};this._element = $(ops.element);this._tabContainerId = "ui-tabcontrol-container-";this._convertHashItems();this._init()._initId()._create()._initMember()._setTabContainer()._setTabContent()._bindEvent();}TabControl.prototype = {_convertHashItems: function () {var i = 0;for (; i < this._ops.items.length; i++) {this._ops.hashItems[this._ops.items[i].title] = {selectedIndex: i,selectedItem: this._ops.items[i]};}},_init: function () {this._element.addClass('ui-tabcontrol');return this;},_initId: function () {this._tabContainerId += uuid;return this;},_create: function () {this._createTab();return this;},_createTab: function () {var fragement = [],h = -1;fragement[++h] = "<div id= " + this._tabContainerId + " class=\"ui-tab-container\">";fragement[++h] = "</div>";this._element.prepend(fragement.join(''));},_initMember: function () {this.$container = $('#' + this._tabContainerId);this.$contents = $('.ui-tabcontrol-content').children();return this;},_setTabContainer: function () {var i = 0,items = this._ops.items,len = items.length;for (; i < len; i++) {var el = document.createElement('div');el.textContent = items[i].title;$(el).addClass('ui-tabcontrol-container-item');if (this._ops.selectedIndex == i) $(el).addClass('active');el.onclick = this._tabClickHandler.bind(this);this.$container.append(el);}return this;},_resetTabContainer: function () {var $targets = this.$container.children();$targets.removeClass('active');$($targets[this._ops.selectedIndex]).addClass('active');},_bindEvent: function () {return this;},_tabClickHandler: function (e) {var self = this,newValue = this._ops.hashItems[e.target.textContent];$$.trigger("tabHandleChanged", self._element, $$.Event({element: self._element,oldValue: this._oldValue,newValue: newValue}));this._ops.selectedIndex = newValue.selectedIndex;this._oldValue = newValue;this._resetTabContainer();this._setTabContent();},_setTabContent: function () {this.$contents.addClass('ui-tabcontrol-content-item');var i = 0,items = this._ops.items,len = items.length;for (; i < len; i++) {if (i !== this._ops.selectedIndex)$(this.$contents[i]).css('display', 'none');else$(this.$contents[i]).css('display', '');}return this;},setOptions: function (ops) {this._ops.items = ops.items;this._ops.selectedIndex = ops.selectedIndex || this._oldValue.selectedIndex;this._convertHashItems();this._removeTabTabContainer()._setTabContainer()._setTabContent();},_removeTabTabContainer: function () {this.$container.empty();return this;}}
View Code

react包装:

import ReactWidget from '../react-widget';class TabControl extends ReactWidget {constructor(props) {super(props);}componentWillReceiveProps(newProps) {this.element.setOptions({items: newProps.items,selectedIndex: newProps.selectedIndex});}componentDidMount() {this.element = new aui.TabControl({element: ReactDOM.findDOMNode(this),items: this.props.items,selectedIndex: this.props.selectedIndex});$(ReactDOM.findDOMNode(this)).on('tabHandleChanged', this.props.selectChanged.bind(this));}render() {return <div><div className='ui-tabcontrol-content'>{this.props.children}</div></div>
    }
}window.$$.TabControl = TabControl;
View Code

less样式:

.ui-tabcontrol {.ui-tab-container {.ui-tabcontrol-container-item {display      : inline-block;padding      : 10px 20px;text-align   : center;border       : 1px solid #ff9900;border-radius: 1px;border-right : 0px;cursor       : pointer;&:hover {color: #bbb;}&:last-child {border-right: 1px solid #ff9900;}}.active {border-top      : 3px solid #000000;background-color: #bbbbbb;border-bottom   : 1px solid #bbbbbb;&:hover {color: #ffffff;}}}.ui-tabcontrol-content {background-color: #bbbbbb;}
}
View Code

效果:

 

转载于:https://www.cnblogs.com/moran1992/p/11080135.html


http://chatgpt.dhexx.cn/article/PSPqTf6S.shtml

相关文章

WinForm TabControl美化

一、简述 TabControl控件是winform里非常常用的一个控件&#xff0c;但是默认的tab控件的标签页和文字颜色都是无法修改的。有时候我们会要用到竖排列的标签页&#xff0c;或者想要更改标签页的背景颜色和字体时&#xff0c;自带的TabControl就满足不了我们的需求了&#xff0…

MFC中选项卡TabControl控件的用法

前言&#xff1a;我这里的开发环境是VS2010&#xff0c;其它不同的开发环境可能会有所差别&#xff0c;但绝不会差太多&#xff0c;其根本方法一般是不会变的。 选项卡控件(英文名&#xff1a;TabControl),这个控件使用在开发一些比较复杂&#xff0c;和用户交互性比较多的软件…

C#中TabControl相关用法

最近在用C#做项目时&#xff0c;用到TabControl这个控件&#xff0c;将学到的东西做个总结&#xff1a; 一、拖一个TabControl控件到窗口上&#xff0c;在控件上点击右键&#xff0c;可以添加选项卡/删除选项卡&#xff1b;或者在属性中找到TabPages,点击进去&#xff0c;可以看…

【Wayland】Weston启动流程分析

Weston启动流程分析 Weston是Wayland Compositor的实现。其Server端作为独立的进程运行在系统中。MakeFile中编译成果为&#xff0c;“weston”的可执行程序MakeFile.am(weston 2.0.0) bin_PROGRAMS westonweston_LDFLAGS -export-dynamic weston_CPPFLAGS $(AM_CPPFLAGS)…

Weston 纹理倒置(render-gl)

纹理倒置 背景 在 render-gl 接入 frame buffer object 实现 off-screen 渲染后,发现得到的渲染图发生了180的倒置. 查阅了有关资料后,在 eglspec.1.5 中的 2.2.2.1 Native Surface Coordinate Systems 找到了答案: The coordinate system for native windows and pixmaps …

【Wayland】Wayland简介与定制指导

Wayland与Weston简介 由于某些原因。移植并定制一套基于Wayland的Compositor。Wayland与Weston&#xff0c;是两个相辅相成的概念。这里简单总结一下&#xff1a; wayland是一套为“显示”服务的协议&#xff0c;基于C/S结构。它定制了一套标准的接口、基本通信方式。wayland…

display:weston:weston-simple-egl

写在前面&#xff1a; 客户端渲染 在Wayland架构中&#xff0c;客户端UI的所有呈现均由客户端代码执行&#xff0c;通常由客户端使用的图形工具包执行。 图形工具箱可以使用其希望呈现UI元素的任何方法&#xff1a;在CPU上进行软件呈现&#xff0c;使用GLES进行硬件呈现。 W…

Ubuntu 20.04 X86成功编译运行wayland、wayland-protocols、weston,亲测有效,踩了很多坑,完美解决。

编译前期准备&#xff1a; 1、更换国内源&#xff1a; #添加阿里源 deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.aliyun.c…

weston 窗口管理 (1)

窗口管理 (1) 一、概述 在传统嵌入式场景下,通常只会运行一个UI程序,故相当于单窗口程序,无需桌面服务器的介入;在桌面系统下,对于每一个UI程序而言,它们的行为相比于嵌入式场景仍然没有发生改变,其对接的仍然是窗口,只不过在同一个时刻允许多个UI程序同时运行. 无论如何对于…

weston 简介

参考???weston wiki Weston - Gentoo Wiki weston (1): Linux man pages – code.tools Weston-1.12.0 非常详尽&#xff0c;多图慎入&#xff1a;Wayland与Weston简介 - 云社区 - 腾讯云 什么是weston&#xff1f; Wayland是一套display server(Wayland compositor)与…

waylandweston

简单地说&#xff0c;Wayland是一套display server(Wayland compositor)与client间的通信协议&#xff0c;而Weston是Wayland compositor的参考实现。其官网为http://wayland.freedesktop.org/。它们定位于在Linux上替换X图形系统。X图形系统经历了30年左右的发展&#xff0c;其…

weston 1: 编译与运行傻瓜教程

本人Kubuntu版本是22.04 sudo apt-get update sudo apt-get upgrade 进入主目录 cd $HOME/ mkdir install mkdir works vim ~/.bashrc export WLD$HOME/install source ~/.bashrc cd works wayland git clone https://gitlab.freedesktop.org/wayland/wayland.git cd …

weston input 概述

weston input 概述 零、前言 本文描述了有关于 weston (基于 wayland 协议一种显示服务器的实现) 中有关于输入设备管理的部分;为了聚焦于此,本文不会对 weston 整体或 wayland 协议进行过多的阐述. 考虑到读者可能存在不同的需求,采用分层次的描述方式,主要面向以下两类人群…

weston 2: 登录后直接启动weston配置

本人Kubuntu版本是22.04 名词&#xff1a;SDDM&#xff08;SDDM - Arch Linux 中文维基&#xff09;显示管理器 配置流程如下&#xff1a; 1.修改配置文件 a.配置.bashrc vim ~/.bashrc //以下内容删除 #export WLD$HOME/install #export LD_LIBRARY_PATH$WLD/lib/x86_64-…

Weston介绍

Weston结构说明 Weston源码结构 clients&#xff1a;wayland显示客户端应用 compositor&#xff1a;合成器进程&#xff08;服务端&#xff09;&#xff0c;窗体风 格样式处理 libweston&#xff1a;合成器以及客户端渲染处理以及驱动实现方式&#xff0c;以及wayland服务与客户…

Wayland/Weston 启动方式简介

前言 本文简单介绍 Weston 常用的几种 backend 启动方式。目前最新的 Weston 8.0.0 支持如下几种 backend&#xff1a; drm-backendfbdev-backendheadless-backendrdp-backendwayland-backendx11-backend 其中 headless-backend 不带任何 UI 界面&#xff0c;主要用于 westo…

weston设置

weston设置 屏幕旋转180度方法修改标题栏位置启动配置文件 屏幕旋转180度方法 编辑 /etc/xdg/weston/weston.ini文件&#xff0c;增加如下语句 [output] nameDSI-1 transform180其中name为你的显示屏名称&#xff0c;可以通过如下命令来查看显示屏名称&#xff1a; card0-DS…

Weston 窗口管理(2)

窗口管理(2) 本文基于 weston 分支 10.0.2 进行描述. 五、概述 本文为窗口管理(1)的续章,更多站在开发者角度,以 weston 的代码实现讲解窗口管理(1)中所实现的部分业务场景. 六、数据结构 在窗口管理(1)中曾经描述过 weston 具体的分层逻辑,如下: 再进一步可以把 WESTON_LAY…

01-weston 简介

参考​​​​​​weston wiki Weston - Gentoo Wiki weston (1): Linux man pages – code.tools Weston-1.12.0 非常详尽&#xff0c;多图慎入&#xff1a;Wayland与Weston简介 - 云社区 - 腾讯云 什么是weston&#xff1f; Wayland是一套display server(Wayland compos…

disunity的使用

1. 下载并安装好jdk: 下载地址&#xff1a;http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 安装教程&#xff1a;http://jingyan.baidu.com/article/6dad5075d1dc40a123e36ea3.html 2.下载disunity: https://…