YAHOO.namespace("protoscript"); /* YAHOO.protoscript.Behaviors = [ { name:'Timer', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Click', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Blur', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Dblclick', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Focus', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Keydown', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Keypress', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Keyup', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Keydown', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Mousedown', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Mousemove', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Mouseover', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Mouseout', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Mouseup', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Resize', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'ToggleOpenClose', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'ToggleClass', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Fade', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Move', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Close', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Resize', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Animate', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Spotlight', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'SetClass', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'SetStyle', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'ReplaceClass', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Hide', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Show', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Script', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'ToggleShowHide', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Open', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'InnerHtml', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'FetchHtml', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'Popup', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] }, { name:'DragDrop', attributes:[ {name:'attr1', 'default':'val',type:'type'} ], callbacks:[ {name:'callback1'} ] } ]; */ YAHOO.protoscript.Util = function() { return { handleAnimMoments: function(cfg, anim, currScope) { if(cfg.onStart) { anim.onStart.subscribe(function() { ProtoScript.Core.callBehaviors(cfg.onStart, currScope); }); } if(cfg.onTween) { anim.onTween.subscribe(function() { ProtoScript.Core.callBehaviors(cfg.onTween, currScope); }); } if(cfg.onComplete) { anim.onComplete.subscribe(function() { ProtoScript.Core.callBehaviors(cfg.onComplete, currScope); }); } } } }(); YAHOO.protoscript.Ajax = function() { this.timeout = 60000; // 1 minute }; YAHOO.protoscript.Ajax.prototype = { get: function(url, data, callback, args) { this.callback = callback; var that = this; this.showLoading(); YAHOO.util.Connect.asyncRequest('GET', url, { success:that.onSuccess, failure:that.onFailure, argument:args, scope:that, timeout:this.timeout }); }, post: function(url, data, callback, args) { this.callback = callback; var that = this; this.showLoading(); YAHOO.util.Connect.asyncRequest('POST', url, { success:that.onSuccess, failure:that.onFailure, argument:args, scope:that, timeout:this.timeout }, data); }, formPost: function(url, frmId, callback, args) { this.callback = callback; var that = this; if(!args || !args.noloading){ this.showLoading(); } YAHOO.util.Connect.setForm(frmId); YAHOO.util.Connect.asyncRequest('POST', url, { success:that.onSuccess, failure:that.onFailure, argument:args, scope:that, timeout:this.timeout }); }, showLoading: function() { //yros.Loading.show(); }, hideLoading: function() { //yros.Loading.hide(); }, onFailure: function(req) { var isCommunicationFailure = (req.status == 0 && req.statusText == 'communication failure') ? true : false; var isAbort = (req.status == -1 && req.statusText == 'transaction aborted') ? true : false; var isFailure = (isCommunicationFailure || isAbort) ? true : false; this.showLoading(); }, onSuccess: function(req) { this.hideLoading(); this.callback(req); } }; YAHOO.protoscript.Timer = function(behaviorName, behaviorCfg) { this.init(behaviorName, behaviorCfg); }; YAHOO.protoscript.Timer.prototype = { defaultCfg : {}, init: function(behaviorName, behaviorCfg) { this.name = behaviorName; this.cfg = ProtoScript.Core.applyConfig(this.defaultCfg, behaviorCfg); }, action: function(currScope) { var scopeElems = currScope.elems; var behaviorCfg = this.cfg; //var behaviorName = behaviorCfg._name; // if there is an onTimer then set up the timer, otherwise no purpose if(behaviorCfg['onTimer']) { var onTimerElems = behaviorCfg['onTimer']._elems; // We will want to register a listener with each element individually. for(var i=0; i 0) { setTimeout(function() { ProtoScript.Core.callBehaviors(behaviorCfg['on'+behaviorName], scope); }, behaviorCfg.delay*1000); } else { ProtoScript.Core.callBehaviors(behaviorCfg['on'+behaviorName], scope); } } behaviorCfg._eventCnt++; }; }(i)); } } }; YAHOO.protoscript.Click = function(behaviorName, behaviorCfg) { this.init(behaviorName, behaviorCfg); }; YAHOO.protoscript.Click.prototype = { defaultCfg : {}, init: function(behaviorName, behaviorCfg) { this.name = behaviorName; this.cfg = ProtoScript.Core.applyConfig(this.defaultCfg, behaviorCfg); }, action: function(currScope) { YAHOO.protoscript.Trigger(this.cfg, currScope, 'click');} }; YAHOO.protoscript.Blur = function(behaviorName, behaviorCfg) { this.init(behaviorName, behaviorCfg); }; YAHOO.protoscript.Blur.prototype = { defaultCfg : {}, init: function(behaviorName, behaviorCfg) { this.name = behaviorName; this.cfg = ProtoScript.Core.applyConfig(this.defaultCfg, behaviorCfg); }, action: function(currScope) { YAHOO.protoscript.Trigger(this.cfg, currScope, 'blur');} }; YAHOO.protoscript.Dblclick = function(behaviorName, behaviorCfg) { this.init(behaviorName, behaviorCfg); }; YAHOO.protoscript.Dblclick.prototype = { defaultCfg : {}, init: function(behaviorName, behaviorCfg) { this.name = behaviorName; this.cfg = ProtoScript.Core.applyConfig(this.defaultCfg, behaviorCfg); }, action: function(currScope) { YAHOO.protoscript.Trigger(this.cfg, currScope, 'dblclick');} }; YAHOO.protoscript.Focus = function(behaviorName, behaviorCfg) { this.init(behaviorName, behaviorCfg); }; YAHOO.protoscript.Focus.prototype = { defaultCfg : {}, init: function(behaviorName, behaviorCfg) { this.name = behaviorName; this.cfg = ProtoScript.Core.applyConfig(this.defaultCfg, behaviorCfg); }, action: function(currScope) { YAHOO.protoscript.Trigger(this.cfg, currScope, 'focus');} }; YAHOO.protoscript.Keypress = function(behaviorName, behaviorCfg) { this.init(behaviorName, behaviorCfg); }; YAHOO.protoscript.Keypress.prototype = { defaultCfg : {}, init: function(behaviorName, behaviorCfg) { this.name = behaviorName; this.cfg = ProtoScript.Core.applyConfig(this.defaultCfg, behaviorCfg); }, action: function(currScope) { YAHOO.protoscript.Trigger(this.cfg, currScope, 'keypress');} }; YAHOO.protoscript.Mousedown = function(behaviorName, behaviorCfg) { this.init(behaviorName, behaviorCfg); }; YAHOO.protoscript.Mousedown.prototype = { defaultCfg : {}, init: function(behaviorName, behaviorCfg) { this.name = behaviorName; this.cfg = ProtoScript.Core.applyConfig(this.defaultCfg, behaviorCfg); }, action: function(currScope) { YAHOO.protoscript.Trigger(this.cfg, currScope, 'mousedown');} }; YAHOO.protoscript.Mousemove = function(behaviorName, behaviorCfg) { this.init(behaviorName, behaviorCfg); }; YAHOO.protoscript.Mousemove.prototype = { defaultCfg : {}, init: function(behaviorName, behaviorCfg) { this.name = behaviorName; this.cfg = ProtoScript.Core.applyConfig(this.defaultCfg, behaviorCfg); }, action: function(currScope) { YAHOO.protoscript.Trigger(this.cfg, currScope, 'mousemove');} }; YAHOO.protoscript.Mouseover = function(behaviorName, behaviorCfg) { this.init(behaviorName, behaviorCfg); }; YAHOO.protoscript.Mouseover.prototype = { defaultCfg : {}, init: function(behaviorName, behaviorCfg) { this.name = behaviorName; this.cfg = ProtoScript.Core.applyConfig(this.defaultCfg, behaviorCfg); }, action: function(currScope) { YAHOO.protoscript.Trigger(this.cfg, currScope, 'mouseover');} }; YAHOO.protoscript.Mouseout = function(behaviorName, behaviorCfg) { this.init(behaviorName, behaviorCfg); }; YAHOO.protoscript.Mouseout.prototype = { defaultCfg : {}, init: function(behaviorName, behaviorCfg) { this.name = behaviorName; this.cfg = ProtoScript.Core.applyConfig(this.defaultCfg, behaviorCfg); }, action: function(currScope) { YAHOO.protoscript.Trigger(this.cfg, currScope, 'mouseout');} }; YAHOO.protoscript.Mouseup = function(behaviorName, behaviorCfg) { this.init(behaviorName, behaviorCfg); }; YAHOO.protoscript.Mouseup.prototype = { defaultCfg : {}, init: function(behaviorName, behaviorCfg) { this.name = behaviorName; this.cfg = ProtoScript.Core.applyConfig(this.defaultCfg, behaviorCfg); }, action: function(currScope) { YAHOO.protoscript.Trigger(this.cfg, currScope, 'mouseup');} }; // YAHOO.protoscript.Resize = function(behaviorName, behaviorCfg) { // this.init(behaviorName, behaviorCfg); // }; // YAHOO.protoscript.Resize.prototype = { // defaultCfg : {}, // init: function(behaviorName, behaviorCfg) { // this.name = behaviorName; // this.cfg = ProtoScript.Core.applyConfig(this.defaultCfg, behaviorCfg); // }, // action: function(currScope) { YAHOO.protoscript.Trigger(this.cfg, currScope, 'resize');} // }; // onabort // onchange // onerror // onselect // onsubmit // onload // onunload YAHOO.protoscript.ToggleOpenClose = function(behaviorName, behaviorCfg) { this.init(behaviorName, behaviorCfg); }; YAHOO.protoscript.ToggleOpenClose.prototype = { defaultCfg : { }, init: function(behaviorName, behaviorCfg) { // console.log("ToggleOpenClose.init"); this.name = behaviorName; this.cfg = ProtoScript.Core.applyConfig(this.defaultCfg, behaviorCfg); }, // change to this? action: function(currScope) { var idx = currScope.idx; var scopeElems = currScope.elems; // console.log("ToggleOpenClose.action"); // console.log(" scopeElems.length"+scopeElems.length); for(var i=0; i' } else { // handle as url // later pull content from another page into an iframe and serve it up here return contentCfg; } } else { // handle as text return contentCfg; } } else if (cfg.bdCopyFrom && cfg.bdCopyFrom.length) { var contentCfg = cfg.bdCopyFrom; // try to resolve as css query string var elem = ProtoScript.Core.$(contentCfg); // got one if(elem && contentCfg !== '' && elem.length) { return elem[idx].innerHTML; } } return ''; }, getContext: function(contextCfg, idx) { var newContextCfg = []; if(contextCfg && contextCfg.length === 3) { newContextCfg[0] = contextCfg[0]; newContextCfg[1] = contextCfg[1]; newContextCfg[2] = contextCfg[2]; var contextElems = ProtoScript.Core.$(newContextCfg[0]); if(contextElems && contextElems.length > 0) { newContextCfg[0] = contextElems[idx]; } } return newContextCfg; } }; YAHOO.protoscript.DragDrop = function (behaviorName, behaviorCfg) { this.init(behaviorName, behaviorCfg); }; YAHOO.protoscript.DragDrop.prototype = { defaultCfg : { dropTarget: null, interactionGroup: 'proto-yui-group' }, init: function(behaviorName, behaviorCfg) { this.name = behaviorName; this.cfg = ProtoScript.Core.applyConfig(this.defaultCfg, behaviorCfg); // Create single or multiple drop targets based on how many elements are supplied to us var dropTargets = ProtoScript.Core.$(this.cfg.dropTarget); this.dropTargetDD = []; for(var i=0; i 0) { YAHOO.widget.ResizePanel.superclass.constructor.call(this, el, userConfig); } }; YAHOO.widget.ResizePanel.CSS_PANEL_RESIZE = "yui-resizepanel"; YAHOO.widget.ResizePanel.CSS_RESIZE_HANDLE = "resizehandle"; YAHOO.extend(YAHOO.widget.ResizePanel, YAHOO.widget.Panel, { init: function(el, userConfig) { YAHOO.widget.ResizePanel.superclass.init.call(this, el); this.beforeInitEvent.fire(YAHOO.widget.ResizePanel); var Dom = YAHOO.util.Dom, Event = YAHOO.util.Event, oInnerElement = this.innerElement, oResizeHandle = document.createElement("DIV"), sResizeHandleId = this.id + "_resizehandle"; oResizeHandle.id = sResizeHandleId; oResizeHandle.className = YAHOO.widget.ResizePanel.CSS_RESIZE_HANDLE; Dom.addClass(oInnerElement, YAHOO.widget.ResizePanel.CSS_PANEL_RESIZE); this.resizeHandle = oResizeHandle; function initResizeFunctionality() { var me = this, oHeader = this.header, oBody = this.body, oFooter = this.footer, nStartWidth, nStartHeight, aStartPos, nBodyBorderTopWidth, nBodyBorderBottomWidth, nBodyTopPadding, nBodyBottomPadding, nBodyOffset; oInnerElement.appendChild(oResizeHandle); this.ddResize = new YAHOO.util.DragDrop(sResizeHandleId, this.id); this.ddResize.setHandleElId(sResizeHandleId); this.ddResize.onMouseDown = function(e) { nStartWidth = oInnerElement.offsetWidth; nStartHeight = oInnerElement.offsetHeight; if (YAHOO.env.ua.ie && document.compatMode == "BackCompat") { nBodyOffset = 0; } else { nBodyBorderTopWidth = parseInt(Dom.getStyle(oBody, "borderTopWidth"), 10), nBodyBorderBottomWidth = parseInt(Dom.getStyle(oBody, "borderBottomWidth"), 10), nBodyTopPadding = parseInt(Dom.getStyle(oBody, "paddingTop"), 10), nBodyBottomPadding = parseInt(Dom.getStyle(oBody, "paddingBottom"), 10), nBodyOffset = nBodyBorderTopWidth + nBodyBorderBottomWidth + nBodyTopPadding + nBodyBottomPadding; } me.cfg.setProperty("width", nStartWidth + "px"); aStartPos = [Event.getPageX(e), Event.getPageY(e)]; }; this.ddResize.onDrag = function(e) { var aNewPos = [Event.getPageX(e), Event.getPageY(e)], nOffsetX = aNewPos[0] - aStartPos[0], nOffsetY = aNewPos[1] - aStartPos[1], nNewWidth = Math.max(nStartWidth + nOffsetX, 10), nNewHeight = Math.max(nStartHeight + nOffsetY, 10), nBodyHeight = (nNewHeight - (oFooter.offsetHeight + oHeader.offsetHeight + nBodyOffset)); me.cfg.setProperty("width", nNewWidth + "px"); if (nBodyHeight < 0) { nBodyHeight = 0; } oBody.style.height = nBodyHeight + "px"; }; } function onBeforeShow() { initResizeFunctionality.call(this); this.unsubscribe("beforeShow", onBeforeShow); } function onBeforeRender() { if (!this.footer) { this.setFooter(""); } if (this.cfg.getProperty("visible")) { initResizeFunctionality.call(this); } else { this.subscribe("beforeShow", onBeforeShow); } this.unsubscribe("beforeRender", onBeforeRender); } this.subscribe("beforeRender", onBeforeRender); if (userConfig) { this.cfg.applyConfig(userConfig, true); } this.initEvent.fire(YAHOO.widget.ResizePanel); }, toString: function() { return "ResizePanel " + this.id; } }); YAHOO.register("yui_proto", YAHOO.protoscript, {version:"0.5.0", build:"1"});