Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
observer.js
Package: Javascript工作流图形界面.rar [view]
Upload User: yfdli66
Upload Date: 2010-02-20
Package Size: 47k
Code Size: 4k
Category:
JavaScript
Development Platform:
JavaScript
- /*------------------------------------------------------------------------------
- + 控件数据显示 +
- + 观察者接口 Observer 主题接口 Subject
- +
- -------------------------------------------------------------------------------*/
- //定义观察者接口
- function Observer () {
- //interface
- this.update = update;
- function update () {
- }
- }
- //定义主题接口
- function Subject () {
- //interface
- this.attach = attach; //登记一个新的观察者
- this.detach = detach; //删除一个的观察者
- this.notifyObservers = notifyObservers; //通知所有登记的观察者
- function attach (observer) {
- }
- function detach (observer) {
- }
- function notifyObservers () {
- }
- }
- /*-----------定义具体的观察者--------*/
- //右边panel属性标签
- function PropertyLabelObserver () {
- //property
- this.object = null;
- //inhert
- this.base=Observer;
- this.base();
- //override
- this.update = update;
- //method
- this.setObject = setObject;
- function setObject (obj) {
- this.object = obj;
- }
- function update () {
- this.object.innerText = fSelectedObj.id;
- }
- }
- //获得焦点的控件改变颜色
- function focusCtlObserver () {
- //inhert
- this.base=Observer;
- this.base();
- //override
- this.update = update;
- function update () {
- for (var i=0;i<sltObjArray.options.length;i++) {
- var obj = eval(sltObjArray.options[i].value);
- if ( obj.id==fSelectedObj.id ) {
- obj.StrokeColor='green';
- obj.strokeweight=2;
- } else {
- obj.StrokeColor='#000000';
- obj.strokeweight=1;
- } //end if
- } // end for
- }
- }
- //右边panel属性列表
- function PropertyListObserver () {
- //inhert
- this.base=Observer;
- this.base();
- //override
- this.update = update;
- function update () {
- propertyContext.setPropertyState(fSelectedObj);
- propertyContext.setProperty();
- }
- }
- //线条的重绘
- function LinesObserver () {
- //inhert
- this.base=Observer;
- this.base();
- //override
- this.update = update;
- function update () {
- if(fSelectedObj != null) {
- if (fSelectedObj.ctlType!=CNST_CTLTYPE_LINES) {
- var aLines = fSelectedObj.line.split(";");
- for( var i = 0; i < aLines.length - 1; i ++ ){
- var lineObjStr = (aLines[i].split("TO")[0]).split(":")[0];
- var oLineStart = eval((aLines[i].split("TO")[0]).split(":")[1]);
- var oLineEnd = eval(aLines[i].split("TO")[1]);
- var posArray = cf_CalculateLinePos(oLineStart,oLineEnd);
- var str = lineObjStr + '.Points.value="'+posArray["x1"]+','+posArray["y1"]+' '+posArray["x2"]+','+posArray["y2"]+' '+posArray["x3"]+','+posArray["y3"]+' '+posArray["x4"]+','+posArray["y4"]+'"';
- eval(str);
- }
- }//end if
- }//end if
- }
- }
- //设置left+top属性
- function leftTopPropertyObserver () {
- //inhert
- this.base=Observer;
- this.base();
- //override
- this.update = update;
- function update () {
- for (var i=0;i<tbProperty.firstChild.rows.length;i++) {
- obj = tbProperty.firstChild.rows[i];
- var ctl = obj.firstChild.firstChild.firstChild.firstChild.children[1].firstChild;
- if (ctl.tagName.toLowerCase()=="input") {
- if (ctl.fieldName=="left") {
- ctl.value = fSelectedObj.style.posLeft;
- } else if (ctl.fieldName=="top") {
- ctl.value = fSelectedObj.style.posTop;
- }
- }
- }
- }
- }
- /*--------end-具体的观察者-------*/
- //定义控件主题类
- function ControlSubject () {
- //property
- this.observerList = new Array(); //用来存储观察者
- //inhert
- this.base=Observer;
- this.base();
- //override
- this.attach = attach; //登记一个新的观察者
- this.detach = detach; //删除一个的观察者
- this.notifyObservers = notifyObservers; //通知所有登记的观察者
- function attach (observer) {
- var i = this.observerList.length;
- this.observerList[i] = observer;
- }
- function detach (observer) {
- }
- function notifyObservers () {
- for (var i=0;i<this.observerList.length;i++) {
- this.observerList[i].update();
- }
- }
- }