resourcepopup.js

来自「Hippo CMS是一个以信息为中心的开源内容管理系统。Hippo CMS目标是」· JavaScript 代码 · 共 92 行

JS
92
字号
/*
* Copyright 2001-2007 Hippo (www.hippo.nl)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// CONSTRUCTOR for the CalendarPopup Object
function ResourcePopup(url) {
	var c;
	
  c = new PopupWindow();
	c.getXYPosition=RP_getXYPosition;
  c.setUrl(url);
  
  c.offsetX = -152;
	c.offsetY = 25;
	c.setSize(300,300);
	c.autoHide();
	c.select = RP_select;
	c.ancestorShowPopup=PopupWindow_showPopup;
	c.showPopup=RP_showPopup;
	c.hidePopup=PopupWindow_hidePopup;
	c.cssPrefix="";
	c.choose=RP_choose;
  
  var lockObject = new Object();
  lockObject.locked=false;
  lockObject.objectReference=null;
  lockObject.callBack= function (){ c.choose(arguments); }
  
  c.callbackFunction = function(value) { alert("selected: "+value); }
  
	c.lockObject=lockObject;

	c.assignTargets=RP_assignTargets;
	c.findWidgetElement=RP_findWidgetElement;
	return c;
}

function RP_showPopup(){	
	
	this.ancestorShowPopup();	
	this.popupWindow.opener.forms_getLink=this.lockObject.callBack;
}

function RP_initTargets(element,sourceProps,targetProps){	
	this.targets=this.loadElements(element,targetProps);
	this.sourceElements=this.loadElements(element,sourceProps);
	if (this.sourceElements.length <= 0 || this.targets.length <= 0){ alert('No target fields defined'); return null;}
	if (this.sourceElements[0].obj.value != '' && this.sourceElements[0].obj.value != null){
  	this.assignTargets(this.sourceElements[0].obj.value);	
	}
}


function RP_choose(){
  if (arguments[0].length > 0){
  	 this.callbackFunction(arguments[0][0]);
 		 this.hidePopup(); 
 		 this.lockObject.reference=null;	 
	 }
}

function RP_getXYPosition(){
	 var coords=new Object();
	 coords.x=100; 
	 coords.y=100;
}
// Set the prefix to be added to all CSS classes when writing output
function RP_setCssPrefix(val) { 
	this.cssPrefix = val; 
	}


// Simple method to interface popup calendar with a text-entry box
function RP_select(callback) {	
	this.lockObject.reference=this;
	
	this.callbackFunction = callback;
	
	this.showPopup();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?