Calendar View contribution integrated

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7546 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2007-12-05 15:59:28 +00:00
parent b39830a2bd
commit 64ab846e77
66 changed files with 13965 additions and 3 deletions

View File

@@ -0,0 +1,75 @@
// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download.
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================
/* SOURCE FILE: AnchorPosition.js */
function getAnchorPosition(anchorname){var useWindow=false;var coordinates=new Object();var x=0,y=0;var use_gebi=false, use_css=false, use_layers=false;if(document.getElementById){use_gebi=true;}else if(document.all){use_css=true;}else if(document.layers){use_layers=true;}if(use_gebi && document.all){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_gebi){var o=document.getElementById(anchorname);x=AnchorPosition_getPageOffsetLeft(o);y=AnchorPosition_getPageOffsetTop(o);}else if(use_css){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_layers){var found=0;for(var i=0;i<document.anchors.length;i++){if(document.anchors[i].name==anchorname){found=1;break;}}if(found==0){coordinates.x=0;coordinates.y=0;return coordinates;}x=document.anchors[i].x;y=document.anchors[i].y;}else{coordinates.x=0;coordinates.y=0;return coordinates;}coordinates.x=x;coordinates.y=y;return coordinates;}
function getAnchorWindowPosition(anchorname){var coordinates=getAnchorPosition(anchorname);var x=0;var y=0;if(document.getElementById){if(isNaN(window.screenX)){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else{x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}}else if(document.all){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else if(document.layers){x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}coordinates.x=x;coordinates.y=y;return coordinates;}
function AnchorPosition_getPageOffsetLeft(el){var ol=el.offsetLeft;while((el=el.offsetParent) != null){ol += el.offsetLeft;}return ol;}
function AnchorPosition_getWindowOffsetLeft(el){return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;}
function AnchorPosition_getPageOffsetTop(el){var ot=el.offsetTop;while((el=el.offsetParent) != null){ot += el.offsetTop;}return ot;}
function AnchorPosition_getWindowOffsetTop(el){return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;}
/* SOURCE FILE: PopupWindow.js */
function PopupWindow_getXYPosition(anchorname){var coordinates;if(this.type == "WINDOW"){coordinates = getAnchorWindowPosition(anchorname);}else{coordinates = getAnchorPosition(anchorname);}this.x = coordinates.x;this.y = coordinates.y;}
function PopupWindow_setSize(width,height){this.width = width;this.height = height;}
function PopupWindow_populate(contents){this.contents = contents;this.populated = false;}
function PopupWindow_setUrl(url){this.url = url;}
function PopupWindow_setWindowProperties(props){this.windowProperties = props;}
function PopupWindow_refresh(){if(this.divName != null){if(this.use_gebi){document.getElementById(this.divName).innerHTML = this.contents;}else if(this.use_css){document.all[this.divName].innerHTML = this.contents;}else if(this.use_layers){var d = document.layers[this.divName];d.document.open();d.document.writeln(this.contents);d.document.close();}}else{if(this.popupWindow != null && !this.popupWindow.closed){if(this.url!=""){this.popupWindow.location.href=this.url;}else{this.popupWindow.document.open();this.popupWindow.document.writeln(this.contents);this.popupWindow.document.close();}this.popupWindow.focus();}}}
function PopupWindow_showPopup(anchorname){this.getXYPosition(anchorname); this.x += this.offsetX;this.y += this.offsetY;if(!this.populated &&(this.contents != "")){this.populated = true;this.refresh();}if(this.divName != null){if(this.use_gebi){document.getElementById(this.divName).style.left = this.x + "px";document.getElementById(this.divName).style.top = this.y;document.getElementById(this.divName).style.display = "block";}else if(this.use_css){document.all[this.divName].style.left = this.x;document.all[this.divName].style.top = this.y;document.all[this.divName].style.display = "block";}else if(this.use_layers){document.layers[this.divName].left = this.x;document.layers[this.divName].top = this.y;document.layers[this.divName].visibility = "visible";}}else{if(this.popupWindow == null || this.popupWindow.closed){if(this.x<0){this.x=0;}if(this.y<0){this.y=0;}if(screen && screen.availHeight){if((this.y + this.height) > screen.availHeight){this.y = screen.availHeight - this.height;}}if(screen && screen.availWidth){if((this.x + this.width) > screen.availWidth){this.x = screen.availWidth - this.width;}}var avoidAboutBlank = window.opera ||( document.layers && !navigator.mimeTypes['*']) || navigator.vendor == 'KDE' ||( document.childNodes && !document.all && !navigator.taintEnabled);this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");}this.refresh();}}
function PopupWindow_hidePopup(){if(this.divName != null){if(this.use_gebi){document.getElementById(this.divName).style.display = "none";}else if(this.use_css){document.all[this.divName].style.display = "none";}else if(this.use_layers){document.layers[this.divName].visibility = "none";}}else{if(this.popupWindow && !this.popupWindow.closed){this.popupWindow.close();this.popupWindow = null;}}}
function PopupWindow_isClicked(e){if(this.divName != null){if(this.use_layers){var clickX = e.pageX;var clickY = e.pageY;var t = document.layers[this.divName];if((clickX > t.left) &&(clickX < t.left+t.clip.width) &&(clickY > t.top) &&(clickY < t.top+t.clip.height)){return true;}else{return false;}}else if(document.all){var t = window.event.srcElement;while(t.parentElement != null){if(t.id==this.divName){return true;}t = t.parentElement;}return false;}else if(this.use_gebi && e){var t = e.originalTarget;while(t.parentNode != null){if(t.id==this.divName){return true;}t = t.parentNode;}return false;}return false;}return false;}
function PopupWindow_hideIfNotClicked(e){if(this.autoHideEnabled && !this.isClicked(e)){this.hidePopup();}}
function PopupWindow_autoHide(){this.autoHideEnabled = true;}
function PopupWindow_hidePopupWindows(e){for(var i=0;i<popupWindowObjects.length;i++){if(popupWindowObjects[i] != null){var p = popupWindowObjects[i];p.hideIfNotClicked(e);}}}
function PopupWindow_attachListener(){if(document.layers){document.captureEvents(Event.MOUSEUP);}window.popupWindowOldEventListener = document.onmouseup;if(window.popupWindowOldEventListener != null){document.onmouseup = new Function("window.popupWindowOldEventListener();PopupWindow_hidePopupWindows();");}else{document.onmouseup = PopupWindow_hidePopupWindows;}}
function PopupWindow(){if(!window.popupWindowIndex){window.popupWindowIndex = 0;}if(!window.popupWindowObjects){window.popupWindowObjects = new Array();}if(!window.listenerAttached){window.listenerAttached = true;PopupWindow_attachListener();}this.index = popupWindowIndex++;popupWindowObjects[this.index] = this;this.divName = null;this.popupWindow = null;this.width=0;this.height=0;this.populated = false;this.visible = false;this.autoHideEnabled = false;this.contents = "";this.url="";this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";if(arguments.length>0){this.type="DIV";this.divName = arguments[0];}else{this.type="WINDOW";}this.use_gebi = false;this.use_css = false;this.use_layers = false;if(document.getElementById){this.use_gebi = true;}else if(document.all){this.use_css = true;}else if(document.layers){this.use_layers = true;}else{this.type = "WINDOW";}this.offsetX = 0;this.offsetY = 0;this.getXYPosition = PopupWindow_getXYPosition;this.populate = PopupWindow_populate;this.setUrl = PopupWindow_setUrl;this.setWindowProperties = PopupWindow_setWindowProperties;this.refresh = PopupWindow_refresh;this.showPopup = PopupWindow_showPopup;this.hidePopup = PopupWindow_hidePopup;this.setSize = PopupWindow_setSize;this.isClicked = PopupWindow_isClicked;this.autoHide = PopupWindow_autoHide;this.hideIfNotClicked = PopupWindow_hideIfNotClicked;}
/* SOURCE FILE: ColorPicker2.js */
ColorPicker_targetInput = null;
function ColorPicker_writeDiv(){document.writeln("<DIV ID=\"colorPickerDiv\" STYLE=\"display:none;\"> </DIV>");}
function ColorPicker_show(anchorname){this.showPopup(anchorname);}
function ColorPicker_pickColor(color,obj){obj.hidePopup();pickColor(color);}
function pickColor(color){if(ColorPicker_targetInput==null){alert("Target Input is null, which means you either didn't use the 'select' function or you have no defined your own 'pickColor' function to handle the picked color!");return;}ColorPicker_targetInput.value = color;}
function ColorPicker_select(inputobj,linkname){if(inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea"){alert("colorpicker.select: Input object passed is not a valid form input object");window.ColorPicker_targetInput=null;return;}window.ColorPicker_targetInput = inputobj;this.show(linkname);}
function ColorPicker_highlightColor(c){var thedoc =(arguments.length>1)?arguments[1]:window.document;var d = thedoc.getElementById("colorPickerSelectedColor");d.style.backgroundColor = c;d = thedoc.getElementById("colorPickerSelectedColorValue");d.innerHTML = c;}
function ColorPicker(){var windowMode = false;if(arguments.length==0){var divname = "colorPickerDiv";}else if(arguments[0] == "window"){var divname = '';windowMode = true;}else{var divname = arguments[0];}if(divname != ""){var cp = new PopupWindow(divname);}else{var cp = new PopupWindow();cp.setSize(225,250);}cp.currentValue = "#FFFFFF";cp.writeDiv = ColorPicker_writeDiv;cp.highlightColor = ColorPicker_highlightColor;cp.show = ColorPicker_show;cp.select = ColorPicker_select;var colors = new Array("#000000","#000033","#000066","#000099","#0000CC","#0000FF","#330000","#330033","#330066","#330099","#3300CC",
"#3300FF","#660000","#660033","#660066","#660099","#6600CC","#6600FF","#990000","#990033","#990066","#990099",
"#9900CC","#9900FF","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#FF0000","#FF0033","#FF0066",
"#FF0099","#FF00CC","#FF00FF","#003300","#003333","#003366","#003399","#0033CC","#0033FF","#333300","#333333",
"#333366","#333399","#3333CC","#3333FF","#663300","#663333","#663366","#663399","#6633CC","#6633FF","#993300",
"#993333","#993366","#993399","#9933CC","#9933FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF",
"#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#006600","#006633","#006666","#006699","#0066CC",
"#0066FF","#336600","#336633","#336666","#336699","#3366CC","#3366FF","#666600","#666633","#666666","#666699",
"#6666CC","#6666FF","#996600","#996633","#996666","#996699","#9966CC","#9966FF","#CC6600","#CC6633","#CC6666",
"#CC6699","#CC66CC","#CC66FF","#FF6600","#FF6633","#FF6666","#FF6699","#FF66CC","#FF66FF","#009900","#009933",
"#009966","#009999","#0099CC","#0099FF","#339900","#339933","#339966","#339999","#3399CC","#3399FF","#669900",
"#669933","#669966","#669999","#6699CC","#6699FF","#999900","#999933","#999966","#999999","#9999CC","#9999FF",
"#CC9900","#CC9933","#CC9966","#CC9999","#CC99CC","#CC99FF","#FF9900","#FF9933","#FF9966","#FF9999","#FF99CC",
"#FF99FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#33CC00","#33CC33","#33CC66","#33CC99",
"#33CCCC","#33CCFF","#66CC00","#66CC33","#66CC66","#66CC99","#66CCCC","#66CCFF","#99CC00","#99CC33","#99CC66",
"#99CC99","#99CCCC","#99CCFF","#CCCC00","#CCCC33","#CCCC66","#CCCC99","#CCCCCC","#CCCCFF","#FFCC00","#FFCC33",
"#FFCC66","#FFCC99","#FFCCCC","#FFCCFF","#00FF00","#00FF33","#00FF66","#00FF99","#00FFCC","#00FFFF","#33FF00",
"#33FF33","#33FF66","#33FF99","#33FFCC","#33FFFF","#66FF00","#66FF33","#66FF66","#66FF99","#66FFCC","#66FFFF",
"#99FF00","#99FF33","#99FF66","#99FF99","#99FFCC","#99FFFF","#CCFF00","#CCFF33","#CCFF66","#CCFF99","#CCFFCC",
"#CCFFFF","#FFFF00","#FFFF33","#FFFF66","#FFFF99","#FFFFCC","#FFFFFF");var total = colors.length;var width = 18;var cp_contents = "";var windowRef =(windowMode)?"window.opener.":"";if(windowMode){cp_contents += "<HTML><HEAD><TITLE>Select Color</TITLE></HEAD>";cp_contents += "<BODY MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0><CENTER>";}cp_contents += "<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=0>";var use_highlight =(document.getElementById || document.all)?true:false;for(var i=0;i<total;i++){if((i % width) == 0){cp_contents += "<TR>";}if(use_highlight){var mo = 'onMouseOver="'+windowRef+'ColorPicker_highlightColor(\''+colors[i]+'\',window.document)"';}else{mo = "";}cp_contents += '<TD BGCOLOR="'+colors[i]+'"><FONT SIZE="-3"><A HREF="#" onClick="'+windowRef+'ColorPicker_pickColor(\''+colors[i]+'\','+windowRef+'window.popupWindowObjects['+cp.index+']);return false;" '+mo+' STYLE="text-decoration:none;">&nbsp;&nbsp;&nbsp;</A></FONT></TD>';if( ((i+1)>=total) ||(((i+1) % width) == 0)){cp_contents += "</TR>";}}if(document.getElementById){var width1 = Math.floor(width/2);var width2 = width = width1;cp_contents += "<TR><TD COLSPAN='"+width1+"' BGCOLOR='#ffffff' ID='colorPickerSelectedColor'>&nbsp;</TD><TD COLSPAN='"+width2+"' ALIGN='CENTER' ID='colorPickerSelectedColorValue'>#FFFFFF</TD></TR>";}cp_contents += "</TABLE>";if(windowMode){cp_contents += "</CENTER></BODY></HTML>";}cp.populate(cp_contents+"\n");cp.offsetY = 25;cp.autoHide();return cp;}

View File

@@ -0,0 +1,79 @@

var DaysArray = function()
{
var _arr = new Array();
_arr[0] = "Sunday";
_arr[1] = "Monday";
_arr[2] = "Tuesday";
_arr[3] = "Wednesday";
_arr[4] = "Thursday";
_arr[5] = "Friday";
_arr[6] = "Saturday";
return _arr;
}
var HoursArray = function()
{
var _arr = new Array();
_arr[0] = "00:00";
_arr[1] = "00:30";
for (i=1; i<24; i++) {
_arr[i*2] = i + ":00";
_arr[i*2+1] = i + ":30";
}
return _arr;
}
var MonthsArray = function()
{
var _arr = new Array();
_arr[0] = "January";
_arr[1] = "February";
_arr[2] = "March";
_arr[3] = "April";
_arr[4] = "May";
_arr[5] = "June";
_arr[6] = "July";
_arr[7] = "August";
_arr[8] = "September";
_arr[9] = "October";
_arr[10] = "November";
_arr[11] = "December";
return _arr;
}
function refreshAllViews()
{
callEventRetrieverWeekView();
callEventRetrieverDayView();
callEventRetrieverMonthView();
}
// Removes leading whitespaces
function lTrim( value )
{
var re = /\s*((\S+\s*)*)/;
return value.replace(re, "$1");
}
// Removes ending whitespaces
function rTrim( value )
{
var re = /((\s*\S+)*)\s*/;
return value.replace(re, "$1");
}
// Removes leading and ending whitespaces
function trim( value )
{
return lTrim(rTrim(value));
}
String.prototype.pad = function(l, s, t)
{
return s || (s = " "), (l -= this.length) > 0 ? (s = new Array(Math.ceil(l / s.length)
+ 1).join(s)).substr(0, t = !t ? l : t == 1 ? 0 : Math.ceil(l / 2))
+ this + s.substr(0, l - t) : this;
};

View File

@@ -0,0 +1,114 @@
//
// TODO: package up in an calendar object
// instead of having functions floating
// around in the global namespace.
//
// Author: simon@webteq.eu
//
function applyFilter(query) {
if (query == "") {
query = "\S"; // match everything
}
var re = new RegExp(query,"i");
var select = document.getElementById("availcals");
for (i=0; i<select.length;i++) {
var display;
if (!re.test(select.options[i].text)) {
display = "none";
} else {
display = "block";
}
select.options[i].style.display = display;
}
};
var addSuccessHandler = function(o) {
var result = o.responseText;
var _div = document.getElementById("subscribedCalendars");
if (_div != null) {
_div.innerHTML = result;
}
refreshAllViews();
};
var addFailureHandler = function(o) {
alert("Couldn't get calendar subscriptions");
};
var addCallback = {
success:addSuccessHandler,
failure:addFailureHandler,
argument: { foo:"foo", bar:"bar" }
};
function setupCalendarSubscription() {
// Determine which option is selected
var selectList = document.getElementById("availcals");
var idx = selectList.options.selectedIndex;
if (idx > -1) {
addCalendarSubscription(selectList.options[idx].value);
}
}
function addCalendarSubscription(calendarRef) {
var url = getContextPath() + "/wcservice/calendar/calendarSubscriptions";
var params = new Array();
params[0] = "ref=" + spaceRef;
params[1] = "calendar=" + calendarRef;
var request = YAHOO.util.Connect.asyncRequest("POST", url + "?" + params.join("&"), addCallback, null);
}
//
// Functions for removing subscriptions
//
var removeFailureHandler = function(o) {
alert(o.responseText);
};
var removeCallback = {
success:addSuccessHandler,
failure:removeFailureHandler,
argument: { foo:"foo", bar:"bar" }
};
function removeCalendarSubscription() {
// Determine which option is selected
var selectList = document.getElementById("subscriptions");
var idx = selectList.options.selectedIndex;
if (idx > -1) {
var url = getContextPath() + "/wcservice/calendar/calendarRemove";
var params = new Array();
params[0] = "ref=" + spaceRef;
params[1] = "calendar=" + selectList.options[idx].value;
var request = YAHOO.util.Connect.asyncRequest("POST", url + "?" + params.join("&"), removeCallback, null);
}
}
function colorHandler(o) {
// Success
};
function colorFailureHandler(o) {
alert("Failed to set color");
};
// Color picker functions
function pickColor(color) {
document.getElementById("color2").style.background = color;
// Update the calendar color property
var params = new Array();
params[0] = "ref=" + spaceRef;
params[1] = "color=" + color;
var url = getContextPath() + "/wcservice/calendar/setColor";
var colorCallback = {
success:colorHandler,
failure:colorFailureHandler,
argument: { ref:spaceRef, color:color }
};
var request = YAHOO.util.Connect.asyncRequest("POST", url, colorCallback, null);
};
//YAHOO.util.Event.addListener("window", "load", retrieveAvailableCalendars);

View File

@@ -0,0 +1,11 @@
var CalendarUtil = {
DAYTAB: 2,
setDayView: function(day, tabs) {
var thedate = new Date(_currentDateForMonthView);
thedate.setDate(day);
_currentDateForDayView = thedate; // global refers to the current day
callEventRetrieverDayView(); // load the events for the given date
tabs.set('activeIndex', CalendarUtil.DAYTAB);
}
};

View File

@@ -0,0 +1,134 @@
function createDayTextBoxNode(e)
{
var obj;
if (window.event)
obj = window.event.srcElement;
else
obj = e.target;
if (obj.tagName != 'TD') return false;
var newBox = document.createElement('input');
newBox.className = "inputBox";
newBox.value = defaultCaption;
newBox.size = 80;
newBox.onblur = function(e) { initiateSaveDayEvent(e); }
//newBox.onblur = function(e) { removeTextBoxNode(e); }
newBox.onkeypress = function(e) { checkDayKeyPressed(e); }
obj.appendChild(newBox);
newBox.focus();
}
function initiateSaveDayEvent(e)
{
saveDayEvent(e);
removeTextBoxNode(e);
}
function saveDayEvent(e)
{
var newBox;
if (window.event)
newBox = window.event.srcElement;
else
newBox = e.target;
var ownerTR = newBox.parentNode.parentNode;
var timeTD = ownerTR.firstChild;
var whatEvent = trim(newBox.value);
if (whatEvent.length <= 0)
{
return false;
}
if (!ValidateString(whatEvent))
{
return false;
}
showSavingIndicator('d');
var fromDate = _currentDateForDayView;
var toDate = _currentDateForDayView;
var fromTime;
if (window.event)
fromTime = timeTD.innerText;
else
fromTime = timeTD.textContent;
var x = fromTime.split(":");
var y = ":00";
var toTime = x[0];
if (x[1] == "00")
y = ":30";
else
toTime = parseInt(x[0]) + 1;
toTime += y;
var whereEvent = defaultPlace;
var descriptionEvent = "";
var fromMonth = fromDate.getMonth() + 1;
var toMonth = toDate.getMonth() + 1;
var colorEvent = defaultColor;
var data = "";
data += "s=" + spaceRef;
data += "&";
data += "what=" + whatEvent;
data += "&";
data += "fd=" + fromDate.getFullYear() + "/" + fromMonth + "/" + fromDate.getDate();
data += "&";
data += "ft=" + fromTime;
data += "&";
data += "td=" + toDate.getFullYear() + "/" + toMonth + "/" + toDate.getDate();
data += "&";
data += "tt=" + toTime;
data += "&";
data += "where=" + whereEvent;
data += "&";
data += "desc=" + descriptionEvent;
data += "&";
data += "color=" + colorEvent;
var sUrl = getContextPath() + '/wcservice/calendar/SaveCalendarEvent?';
sUrl += data;
var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callbackDayViewSaveEvent, null);
}
function checkDayKeyPressed(e)
{
var key;
if (window.event)
key = window.event.keyCode;
else
key = e.which;
if (key == 13)
{
//saveDayEvent(e);
window.focus();
return false;
}
else
return true;
}
var handleSuccessDayViewSaveEvent = function(o)
{
hideSavingIndicator('d');
refreshAllViews();
}
var handleFailureDayViewSaveEvent = function(o)
{
hideSavingIndicator('d');
alert("Unable to Save, " + o.statusText);
}
var callbackDayViewSaveEvent =
{
success:handleSuccessDayViewSaveEvent,
failure:handleFailureDayViewSaveEvent,
argument: { foo:"foo", bar:"bar" }
};

View File

@@ -0,0 +1,140 @@
var _currentSelectedDate = new Date();
function createWeekTextBoxNode(e, currYear, currMonth, currDate)
{
_currentSelectedDate.setDate(currDate);
_currentSelectedDate.setMonth(currMonth);
_currentSelectedDate.setFullYear(currYear);
var obj;
if (window.event)
obj = window.event.srcElement;
else
obj = e.target;
if (obj.tagName != 'TD') return false;
var newBox = document.createElement('input');
newBox.className = "inputBox";
newBox.value = defaultCaption;
newBox.size = 10;
newBox.onblur = function(e) { initiateSaveWeekEvent(e); }
//newBox.onblur = function(e) { removeTextBoxNode(e); }
newBox.onkeypress = function(e) { checkWeekKeyPressed(e); }
obj.appendChild(newBox);
newBox.focus();
}
function initiateSaveWeekEvent(e)
{
saveWeekEvent(e);
removeTextBoxNode(e);
}
function saveWeekEvent(e)
{
var newBox;
if (window.event)
newBox = window.event.srcElement;
else
newBox = e.target;
var ownerTR = newBox.parentNode.parentNode;
var timeTD = ownerTR.firstChild;
var whatEvent = trim(newBox.value);
if (whatEvent.length <= 0)
{
return false;
}
if (!ValidateString(whatEvent))
{
return false;
}
showSavingIndicator('w');
var fromDate = _currentSelectedDate;
var toDate = _currentSelectedDate;
var fromTime;
if (window.event)
fromTime = timeTD.innerText;
else
fromTime = timeTD.textContent;
var x = fromTime.split(":");
var y = ":00";
var toTime = x[0];
if (x[1] == "00")
y = ":30";
else
toTime = parseInt(x[0]) + 1;
toTime += y;
var whereEvent = defaultPlace;
var descriptionEvent = "";
var fromMonth = fromDate.getMonth() + 1;
var toMonth = toDate.getMonth() + 1;
var colorEvent = defaultColor;
var data = "";
data += "s=" + spaceRef;
data += "&";
data += "what=" + whatEvent;
data += "&";
data += "fd=" + fromDate.getFullYear() + "/" + fromMonth + "/" + fromDate.getDate();
data += "&";
data += "ft=" + fromTime;
data += "&";
data += "td=" + toDate.getFullYear() + "/" + toMonth + "/" + toDate.getDate();
data += "&";
data += "tt=" + toTime;
data += "&";
data += "where=" + whereEvent;
data += "&";
data += "desc=" + descriptionEvent;
data += "&";
data += "color=" + colorEvent;
var sUrl = getContextPath() + '/wcservice/calendar/SaveCalendarEvent?';
sUrl += data;
var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callbackWeekViewSaveEvent, null);
}
function checkWeekKeyPressed(e)
{
var key;
if (window.event)
key = window.event.keyCode;
else
key = e.which;
if (key == 13)
{
//saveWeekEvent(e);
window.focus();
return false;
}
else
return true;
}
var handleSuccessWeekViewSaveEvent = function(o)
{
hideSavingIndicator('w');
refreshAllViews();
}
var handleFailureWeekViewSaveEvent = function(o)
{
hideSavingIndicator('w');
alert("Unable to Save, " + o.statusText);
}
var callbackWeekViewSaveEvent =
{
success:handleSuccessWeekViewSaveEvent,
failure:handleFailureWeekViewSaveEvent,
argument: { foo:"foo", bar:"bar" }
};

View File

@@ -0,0 +1,97 @@
/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
YAHOO.util.Color = function() {
var hexchars = "0123456789ABCDEF";
var real2int = function(n) {
return Math.min(255, Math.round(n*256));
};
return {
/**
* HSV to RGB. h[0,360], s[0,1], v[0,1]
*/
hsv2rgb: function(h,s,v) {
var r,g,b,i,f,p,q,t;
i = Math.floor((h/60)%6);
f = (h/60)-i;
p = v*(1-s);
q = v*(1-f*s);
t = v*(1-(1-f)*s);
switch(i) {
case 0: r=v; g=t; b=p; break;
case 1: r=q; g=v; b=p; break;
case 2: r=p; g=v; b=t; break;
case 3: r=p; g=q; b=v; break;
case 4: r=t; g=p; b=v; break;
case 5: r=v; g=p; b=q; break;
}
//alert([h,s,v] + "-" + [r,g,b]);
return [real2int(r), real2int(g), real2int(b)];
},
rgb2hsv: function(r,g,b) {
var min,max,delta,h,s,v;
min = Math.min(Math.min(r,g),b);
max = Math.max(Math.max(r,g),b);
delta = max-min;
switch (max) {
case min: h=0; break;
case r: h=(g-b)/delta;
if (g<b) {
h+=360;
}
break;
case g: h=((b-r)/delta)+120; break;
case b: h=((r-g)/delta)+240; break;
}
s = (max==0) ? 0 : 1-(mix/max);
return {"h": h, "s": s, "v": max};
},
rgb2hex: function (r,g,b) {
return this.int2hex(r) + this.int2hex(g) + this.int2hex(b);
},
/**
* Converts an int [0,255] to hex [00,FF]
*/
int2hex: function(n) {
n = n || 0;
n = parseInt(n, 10);
if (isNaN(n)) n = 0;
n = Math.round(Math.min(Math.max(0, n), 255));
return hexchars.charAt((n - n % 16) / 16) + hexchars.charAt(n % 16);
},
hex2dec: function(hexchar) {
return hexchars.indexOf(hexchar.toUpperCase());
},
hex2rgb: function(s) {
var rgb = [];
rgb[0] = (this.hex2dec(s.substr(0, 1)) * 16) + this.hex2dec(s.substr(1, 1));
rgb[1] = (this.hex2dec(s.substr(2, 1)) * 16) + this.hex2dec(s.substr(3, 1));
rgb[2] = (this.hex2dec(s.substr(4, 1)) * 16) + this.hex2dec(s.substr(5, 1));
// gLogger.debug("hex2rgb: " + str + ", " + rgb.toString());
return rgb;
},
isValidRGB: function(a) {
if ((!a[0] && a[0] !=0) || isNaN(a[0]) || a[0] < 0 || a[0] > 255) return false;
if ((!a[1] && a[1] !=0) || isNaN(a[1]) || a[1] < 0 || a[1] > 255) return false;
if ((!a[2] && a[2] !=0) || isNaN(a[2]) || a[2] < 0 || a[2] > 255) return false;
return true;
}
}
}();

View File

@@ -0,0 +1,167 @@
function baseConverter (number,ob,nb) {
number = number + "";
number = number.toUpperCase();
var list = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var dec = 0;
for (var i = 0; i <= number.length; i++) {
dec += (list.indexOf(number.charAt(i))) * (Math.pow(ob , (number.length - i - 1)));
}
number = "";
var magnitude = Math.floor((Math.log(dec))/(Math.log(nb)));
for (var i = magnitude; i >= 0; i--) {
var amount = Math.floor(dec/Math.pow(nb,i));
number = number + list.charAt(amount);
dec -= amount*(Math.pow(nb,i));
}
if(number.length==0)number=0;
return number;
}
// Converts a RGB color to HSV
function toHSV(rgbColor){
rgbColor = rgbColor.replace('#','');
red = baseConverter(rgbColor.substr(0,2),16,10);
green = baseConverter(rgbColor.substr(2,2),16,10);
blue = baseConverter(rgbColor.substr(4,2),16,10);
if(red.length==0)red=0;
if(green.length==0)green=0;
if(blue.length==0)blue=0;
red = red/255;
green = green/255;
blue = blue/255;
maxValue = Math.max(red,green,blue);
minValue = Math.min(red,green,blue);
var hue = 0;
if(maxValue==minValue){
hue = 0;
saturation=0;
}else{
if(red == maxValue){
hue = (green - blue) / (maxValue-minValue)/1;
}else if(green == maxValue){
hue = 2 + (blue - red)/1 / (maxValue-minValue)/1;
}else if(blue == maxValue){
hue = 4 + (red - green) / (maxValue-minValue)/1;
}
saturation = (maxValue-minValue) / maxValue;
}
hue = hue * 60;
valueBrightness = maxValue;
if(valueBrightness/1<0.5){
//saturation = (maxValue - minValue) / (maxValue + minValue);
}
if(valueBrightness/1>= 0.5){
//saturation = (maxValue - minValue) / (2 - maxValue - minValue);
}
returnArray = [hue,saturation,valueBrightness];
return returnArray;
}
function toRgb(hue,saturation,valueBrightness){
Hi = Math.floor(hue / 60);
if(hue==360)Hi=0;
f = hue/60 - Hi;
p = (valueBrightness * (1- saturation)).toPrecision(2);
q = (valueBrightness * (1 - (f * saturation))).toPrecision(2);
t = (valueBrightness * (1 - ((1-f)*saturation))).toPrecision(2);
switch(Hi){
case 0:
red = valueBrightness;
green = t;
blue = p;
break;
case 1:
red = q;
green = valueBrightness;
blue = p;
break;
case 2:
red = q;
green = valueBrightness;
blue = t;
break;
case 3:
red = p;
green = q;;
blue = valueBrightness;
break;
case 4:
red = t;
green = p;
blue = valueBrightness;
break;
case 5:
red = valueBrightness;
green = p;
blue = q;
break;
}
if(saturation==0){
red = valueBrightness;
green = valueBrightness;
blue = valueBrightness;
}
red*=255;
green*=255;
blue*=255;
red = Math.round(red);
green = Math.round(green);
blue = Math.round(blue);
red = baseConverter(red,10,16);
green = baseConverter(green,10,16);
blue = baseConverter(blue,10,16);
red = red + "";
green = green + "";
blue = blue + "";
while(red.length<2){
red = "0" + red;
}
while(green.length<2){
green = "0" + green;
}
while(blue.length<2){
blue = "0" + "" + blue;
}
rgbColor = "#" + red + "" + green + "" + blue;
return rgbColor.toUpperCase();
}
function findColorByDegrees(rgbColor,degrees){
rgbColor = rgbColor.replace('#','');
myArray = toHSV(rgbColor);
myArray[0]+=degrees;
if(myArray[0]>=360)myArray[0]-=360;
if(myArray[0]<0)myArray[0]+=360;
return toRgb(myArray[0],myArray[1],myArray[2]);
}
function findColorByBrightness(rgbColor,brightness){
rgbColor = rgbColor.replace('#','');
myArray = toHSV(rgbColor);
myArray[2]+=brightness/100;
if(myArray[2]>1)myArray[2]=1;
if(myArray[2]<0)myArray[2]=0;
myArray[1]+=brightness/100;
if(myArray[1]>1)myArray[1]=1;
if(myArray[1]<0)myArray[1]=0;
return toRgb(myArray[0],myArray[1],myArray[2]);
}

View File

@@ -0,0 +1,109 @@
function selectColor() {
var color = document.getElementById("selectedColorBox").value;
if (window.opener != null)
{
var mainWinTxtColor = window.opener.document.getElementById(window.colorControl);
if (mainWinTxtColor != null)
{
mainWinTxtColor.value = color;
mainWinTxtColor.style.backgroundColor = color;
}
}
window.close();
}
function showColor(color) {
document.getElementById("selectedColor").style.backgroundColor = color;
document.getElementById("selectedColorBox").value = color;
}
var colors = new Array(
"#000000","#000033","#000066","#000099","#0000cc","#0000ff","#330000","#330033",
"#330066","#330099","#3300cc","#3300ff","#660000","#660033","#660066","#660099",
"#6600cc","#6600ff","#990000","#990033","#990066","#990099","#9900cc","#9900ff",
"#cc0000","#cc0033","#cc0066","#cc0099","#cc00cc","#cc00ff","#ff0000","#ff0033",
"#ff0066","#ff0099","#ff00cc","#ff00ff","#003300","#003333","#003366","#003399",
"#0033cc","#0033ff","#333300","#333333","#333366","#333399","#3333cc","#3333ff",
"#663300","#663333","#663366","#663399","#6633cc","#6633ff","#993300","#993333",
"#993366","#993399","#9933cc","#9933ff","#cc3300","#cc3333","#cc3366","#cc3399",
"#cc33cc","#cc33ff","#ff3300","#ff3333","#ff3366","#ff3399","#ff33cc","#ff33ff",
"#006600","#006633","#006666","#006699","#0066cc","#0066ff","#336600","#336633",
"#336666","#336699","#3366cc","#3366ff","#666600","#666633","#666666","#666699",
"#6666cc","#6666ff","#996600","#996633","#996666","#996699","#9966cc","#9966ff",
"#cc6600","#cc6633","#cc6666","#cc6699","#cc66cc","#cc66ff","#ff6600","#ff6633",
"#ff6666","#ff6699","#ff66cc","#ff66ff","#009900","#009933","#009966","#009999",
"#0099cc","#0099ff","#339900","#339933","#339966","#339999","#3399cc","#3399ff",
"#669900","#669933","#669966","#669999","#6699cc","#6699ff","#999900","#999933",
"#999966","#999999","#9999cc","#9999ff","#cc9900","#cc9933","#cc9966","#cc9999",
"#cc99cc","#cc99ff","#ff9900","#ff9933","#ff9966","#ff9999","#ff99cc","#ff99ff",
"#00cc00","#00cc33","#00cc66","#00cc99","#00cccc","#00ccff","#33cc00","#33cc33",
"#33cc66","#33cc99","#33cccc","#33ccff","#66cc00","#66cc33","#66cc66","#66cc99",
"#66cccc","#66ccff","#99cc00","#99cc33","#99cc66","#99cc99","#99cccc","#99ccff",
"#cccc00","#cccc33","#cccc66","#cccc99","#cccccc","#ccccff","#ffcc00","#ffcc33",
"#ffcc66","#ffcc99","#ffcccc","#ffccff","#00ff00","#00ff33","#00ff66","#00ff99",
"#00ffcc","#00ffff","#33ff00","#33ff33","#33ff66","#33ff99","#33ffcc","#33ffff",
"#66ff00","#66ff33","#66ff66","#66ff99","#66ffcc","#66ffff","#99ff00","#99ff33",
"#99ff66","#99ff99","#99ffcc","#99ffff","#ccff00","#ccff33","#ccff66","#ccff99",
"#ccffcc","#ccffff","#ffff00","#ffff33","#ffff66","#ffff99","#ffffcc","#ffffff"
);
function convertRGBToHex(col) {
var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi");
var rgb = col.replace(re, "$1,$2,$3").split(',');
if (rgb.length == 3) {
r = parseInt(rgb[0]).toString(16);
g = parseInt(rgb[1]).toString(16);
b = parseInt(rgb[2]).toString(16);
r = r.length == 1 ? '0' + r : r;
g = g.length == 1 ? '0' + g : g;
b = b.length == 1 ? '0' + b : b;
return "#" + r + g + b;
}
return col;
}
function convertHexToRGB(col) {
if (col.indexOf('#') != -1) {
col = col.replace(new RegExp('[^0-9A-F]', 'gi'), '');
r = parseInt(col.substring(0, 2), 16);
g = parseInt(col.substring(2, 4), 16);
b = parseInt(col.substring(4, 6), 16);
return "rgb(" + r + "," + g + "," + b + ")";
}
return col;
}
function renderColorMap() {
var html = "";
var inputColor = convertRGBToHex('ff88ff');
html += '<table border="0" cellspacing="1" cellpadding="0">'
+ '<tr>';
for (var i=0; i<colors.length; i++) {
html += '<td bgcolor="' + colors[i] + '">'
+ '<a href="javascript:selectColor();" onfocus="showColor(\'' + colors[i] + '\');" onmouseover="showColor(\'' + colors[i] + '\');">'
+ '<img border="0" src="/alfresco/images/calendar/spacer.gif" width="10" height="10" title="' + colors[i] + '" alt="' + colors[i] + '" /></a></td>';
if ((i+1) % 18 == 0)
html += '</tr><tr>';
}
html += '<tr><td colspan="18">'
+ '<table width="100%" border="0" cellspacing="0" cellpadding="0">'
+ '<tr><td>'
+ '<img id="selectedColor" style="background-color:' + 'ff88ff' + '" border="0" src="/alfresco/images/calendar/spacer.gif" width="80" height="16" />'
+ '</td><td align="right">'
+ '<input id="selectedColorBox" name="selectedColorBox" type="text" size="7" maxlength="7" style="width:65px" value="' + inputColor + '" />'
+ '</td></tr>'
+ '</table>'
+ '</td></tr>'
+ '</table>';
document.write(html);
}

View File

@@ -0,0 +1,81 @@
YAHOO.example.ColorPicker = function() {
var Slider=YAHOO.widget.Slider;
var Color=YAHOO.util.Color;
var Dom=YAHOO.util.Dom;
var pickerSize=180;
var hue,picker,panel;
// hue, int[0,359]
var getH = function() {
var h = (pickerSize - hue.getValue()) / pickerSize;
h = Math.round(h*360);
return (h == 360) ? 0 : h;
}
// saturation, int[0,1], left to right
var getS = function() {
return picker.getXValue() / pickerSize;
}
// value, int[0,1], top to bottom
var getV = function() {
return (pickerSize - picker.getYValue()) / pickerSize;
}
var swatchUpdate = function() {
var h=getH(), s=getS(), v=getV();
Dom.get("hval").value = h;
Dom.get("sval").value = Math.round(s*100);
Dom.get("vval").value = Math.round(v*100);
var rgb = Color.hsv2rgb(h, s, v);
var styleDef = "rgb(" + rgb.join(",") + ")";
Dom.setStyle("swatch", "background-color", styleDef);
Dom.get("rval").value = rgb[0];
Dom.get("gval").value = rgb[1];
Dom.get("bval").value = rgb[2];
Dom.get("hexval").value = Color.rgb2hex(rgb[0], rgb[1], rgb[2]);
};
var hueUpdate = function(newOffset) {
YAHOO.log("hue update: " + newOffset , "warn");
var rgb = Color.hsv2rgb(getH(), 1, 1);
var styleDef = "rgb(" + rgb.join(",") + ")";
Dom.setStyle("pickerDiv", "background-color", styleDef);
swatchUpdate();
};
pickerUpdate = function(newOffset) {
YAHOO.log("picker update [" + newOffset.x + ", " + newOffset.y + "]" , "warn");
swatchUpdate();
};
return {
init: function () {
hue = Slider.getVertSlider("hueBg", "hueThumb", 0, pickerSize);
hue.subscribe("change", hueUpdate);
picker = Slider.getSliderRegion("pickerDiv", "selector",
0, pickerSize, 0, pickerSize);
picker.subscribe("change", pickerUpdate);
hueUpdate(0);
panel = new YAHOO.util.DD("ddPicker");
panel.setHandleElId("pickerHandle");
}
}
}();
//YAHOO.util.Event.on(window, "load", YAHOO.example.ColorPicker.init);

View File

@@ -0,0 +1,64 @@
var _currentActiveEditingEvent = null;
function editEvent(eventId)
{
_currentActiveEditingEvent = eventId;
if (_currentActiveEditingEvent == null) return false;
retrieveCalendarEvent();
}
function populateEventDetailsForEdit(response)
{
var _details = response.split("^");
if (_details.length <=0)
{
alert("Unable to Retrieve details of Event");
return false;
}
var _fromDate = new Date(_details[1]);
var _toDate = new Date(_details[3]);
document.getElementById("txtWhatEvent").value = _details[0];
document.getElementById("hidFromDate").value = _details[1];
document.getElementById("txtFromDate").value = _fromDate.toDateString();
document.getElementById("lstFromTime").value = _details[2];
document.getElementById("hidToDate").value = _details[3];
document.getElementById("txtToDate").value = _toDate.toDateString();
document.getElementById("lstToTime").value = _details[4];
document.getElementById("txtWhereEvent").value = _details[5];
document.getElementById("txtDescriptionEvent").value = _details[6];
document.getElementById("txtColor").value = _details[7];
tabView.set('activeIndex', 3); //tabView: the main YUI TabView Control - defined in FTL.
document.getElementById("txtWhatEvent").focus();
}
var handleSuccessRetrieveEvent = function(o)
{
populateEventDetailsForEdit(o.responseText);
}
var handleFailureRetrieveEvent = function(o)
{
alert("Unable to Retrieve Event Details, " + o.statusText);
}
var callbackRetrieveEvent =
{
success:handleSuccessRetrieveEvent,
failure:handleFailureRetrieveEvent,
argument: { foo:"foo", bar:"bar" }
};
function retrieveCalendarEvent()
{
var sUrl = getContextPath() + '/wcservice/calendar/RetrieveEventDetails?';
var postData = "e=" + _currentActiveEditingEvent;
sUrl += postData;
var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callbackRetrieveEvent, null);
}

View File

@@ -0,0 +1,70 @@
function showSavingIndicator(mode)
{
var obj = null;
switch(mode)
{
case 'd':
{
obj = document.getElementById("spnCurrentDisplayDay");
break;
}
case 'w':
{
obj = document.getElementById("spnCurrentDisplayWeek");
break;
}
case 'c':
{
obj = document.getElementById("spnEventCapture");
break;
}
}
if (obj == null) return false;
var newImg = document.createElement('img');
newImg.src = "/alfresco/yui/img/indicator.gif";
var txt = document.createTextNode(' Saving...');
obj.appendChild(newImg);
obj.appendChild(txt);
}
function hideSavingIndicator(mode)
{
var obj = null;
switch(mode)
{
case 'd':
{
obj = document.getElementById("spnCurrentDisplayDay");
break;
}
case 'w':
{
obj = document.getElementById("spnCurrentDisplayWeek");
break;
}
case 'c':
{
obj = document.getElementById("spnEventCapture");
break;
}
}
if (obj == null) return false;
while (obj.hasChildNodes())
obj.removeChild(obj.firstChild);
}
function removeTextBoxNode(e)
{
var txtNode;
if (window.event)
txtNode = window.event.srcElement;
else
txtNode = e.target;
var owner = txtNode.parentNode;
owner.removeChild(txtNode);
}

View File

@@ -0,0 +1,44 @@
var _currentDateForDayView = new Date();
var handleSuccessDayView = function(o)
{
var response = o.responseText;
var _divDayView = document.getElementById("divDayView");
if (_divDayView != null) {
_divDayView.innerHTML = response;
document.getElementById("spnCurrentDisplayDayDayView").innerHTML = _currentDateForDayView.toDateString();
}
}
var handleFailureDayView = function(o)
{
alert("Unable to retrieve, " + o.statusText);
}
var callbackDayView =
{
success:handleSuccessDayView,
failure:handleFailureDayView,
argument: { foo:"foo", bar:"bar" }
};
function callEventRetrieverDayView()
{
var sUrl = getContextPath() + '/wcservice/calendar/RetrieveDayEvents?';
var month = _currentDateForDayView.getMonth() + 1;
var postData = "s=" + spaceRef + "&d=" + _currentDateForDayView.getFullYear() + "/" + month + "/" + _currentDateForDayView.getDate();
sUrl += postData;
var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callbackDayView, null);
}
function callLoadersDayView(change)
{
if (isNaN(change)) change = 0;
if (change == 0) _currentDateForDayView = new Date();
_currentDateForDayView.setDate(_currentDateForDayView.getDate() + change);
//document.getElementById("spnCurrentDisplayDayDayView").innerHTML = _currentDateForDayView.toDateString();
callEventRetrieverDayView();
}
YAHOO.util.Event.addListener(window, "load", callLoadersDayView);

View File

@@ -0,0 +1,54 @@
var _currentDateForMonthView = new Date();
function setCurrentMonthView()
{
_currentDateForMonthView = new Date();
callEventRetrieverMonthView();
}
function addMonthsMonthView(n)
{
_currentDateForMonthView.setMonth(_currentDateForMonthView.getMonth() + n);
callEventRetrieverMonthView();
}
function addYearsMonthView(n)
{
_currentDateForMonthView.setFullYear(_currentDateForMonthView.getFullYear() + n);
callEventRetrieverMonthView();
}
var handleSuccessMonthView = function(o)
{
var response = o.responseText;
var _divMonthView = document.getElementById("divMonthView");
if (_divMonthView != null)
_divMonthView.innerHTML = response;
}
var handleFailureMonthView = function(o)
{
alert("Unable to retrieve, " + o.statusText);
}
var callbackMonthView =
{
success:handleSuccessMonthView,
failure:handleFailureMonthView,
argument: { foo:"foo", bar:"bar" }
};
function callEventRetrieverMonthView()
{
var _arrMonths = MonthsArray();
var month = _currentDateForMonthView.getMonth() + 1;
document.getElementById("spnCurrentDisplayMonthMonthView").innerHTML = _arrMonths[month-1] + ", " + _currentDateForMonthView.getFullYear();
var sUrl = getContextPath() + '/wcservice/calendar/RetrieveMonthEvents?';
var postData = "s=" + spaceRef + "&d=" + _currentDateForMonthView.getFullYear() + "/" + month + "/" + _currentDateForMonthView.getDate();
sUrl += postData;
var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callbackMonthView, null);
}
YAHOO.util.Event.addListener(window, "load", callEventRetrieverMonthView);

View File

@@ -0,0 +1,49 @@
var _currentDateForWeekView = new Date();
function setCurrentDateForWeekView(change)
{
if (isNaN(change)) change = 0;
if (change == 0) _currentDateForWeekView = new Date();
_currentDateForWeekView.setDate(_currentDateForWeekView.getDate() + change);
}
var handleSuccessWeekView = function(o)
{
var response = o.responseText;
var _divWeekView = document.getElementById("divWeekView");
if (_divWeekView != null)
_divWeekView.innerHTML = response;
//document.getElementById("spnCurrentDisplayWeekWeekView").innerHTML = response[1];
}
var handleFailureWeekView = function(o)
{
alert("Unable to retrieve, " + o.statusText);
}
var callbackWeekView =
{
success:handleSuccessWeekView,
failure:handleFailureWeekView,
argument: { foo:"foo", bar:"bar" }
};
function callEventRetrieverWeekView()
{
var month = _currentDateForWeekView.getMonth() + 1;
var sUrl = getContextPath() + '/wcservice/calendar/RetrieveWeekEvents?';
var postData = "s=" + spaceRef + "&d=" + _currentDateForWeekView .getFullYear() + "/" + month + "/" + _currentDateForWeekView .getDate();
sUrl += postData;
var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callbackWeekView, null);
}
function callLoadersWeekView(change)
{
if (isNaN(change)) change = 0;
setCurrentDateForWeekView(change);
callEventRetrieverWeekView();
}
YAHOO.util.Event.addListener(window, "load", callLoadersWeekView);

View File

@@ -0,0 +1,200 @@
var currentBox = null;
var currentVisibleBox = null;
// Variables to hold Event Default values.
var defaultCaption = "";
var defaultPlace = "";
var defaultFromDate = new Date();
var defaultFromDateString = "";
var defaultFromTime = "";
var defaultToDate = new Date();
var defaultToDateString = "";
var defaultToTime = "";
var defaultColor = "";
YAHOO.namespace("example.calendar");
function handleSelect(type, args, obj)
{
var dates = args[0];
var date = dates[0];
var year = date[0], month = date[1], day = date[2];
var dateValue = month + "/" + day + "/" + year;
var dateData = new Date();
dateData.setFullYear(year, month-1, day);
if (currentBox != null)
{
currentBox.value = dateValue;
}
if (currentVisibleBox != null)
{
currentVisibleBox.value = dateData.toDateString();
}
ToggleCalendar(0, null);
}
function init()
{
YAHOO.example.calendar.cal1 = new YAHOO.widget.Calendar("cal1","cal1Container", { mindate:"1/1/2006", maxdate:"12/31/2008" });
YAHOO.example.calendar.cal1.selectEvent.subscribe(handleSelect, YAHOO.example.calendar.cal1, true);
YAHOO.example.calendar.cal1.render();
tabView = new YAHOO.widget.TabView('divCalendarMainContainer');
document.onclick = function(e) { HideCalendar(e); }
PopulateTimes();
retrieveEventDefaults();
initCalendarProperties();
}
function ToggleCalendar(mode, txtBox)
{
if (isNaN(mode)) mode = 0;
var calendar = document.getElementById("cal1Container");
if (calendar == null) return;
calendar.style.display = mode == 1 ? "inline" : "none";
if (txtBox == null) return;
if (mode == 1)
{
calendar.style.left = txtBox.offsetParent.offsetLeft + txtBox.offsetLeft;
calendar.style.top = txtBox.offsetParent.offsetTop + txtBox.offsetHeight;
}
currentVisibleBox = txtBox;
if (txtBox.id == "txtFromDate")
currentBox = document.getElementById("hidFromDate");
else if (txtBox.id == "txtToDate")
currentBox = document.getElementById("hidToDate");
}
function HideCalendar(e)
{
var obj = null;
if (window.event)
obj = window.event.srcElement;
else
obj = e.target;
if (obj.id != "txtFromDate" && obj.id != "txtToDate")
ToggleCalendar(0);
}
function PopulateTimes()
{
var _arr = HoursArray();
for (i=0; i<_arr.length; i++)
{
var _option1 = document.createElement("OPTION");
_option1.text = _arr[i];
_option1.value = _arr[i];
document.getElementById("lstFromTime").options.add(_option1);
var _option2 = document.createElement("OPTION");
_option2.text = _arr[i];
_option2.value = _arr[i];
document.getElementById("lstToTime").options.add(_option2);
}
}
/////////////
function initSuccessHandler(o) {
var result = o.responseText;
var _div = document.getElementById("calendarSubscribe");
if (_div != null) {
_div.innerHTML = result;
}
}
function initFailureHandler(o) {
alert("Failed to initialise calendar properties");
}
function initCalendarProperties() {
var url = getContextPath() + "/wcservice/calendar/calendarInit";
var initCallback = {
success:initSuccessHandler,
failure:initFailureHandler
};
var request = YAHOO.util.Connect.asyncRequest("GET", url + "?ref=" + spaceRef, initCallback, null);
}
/////////////
YAHOO.util.Event.addListener(window, "load", init);
var handleSuccessInitEvent = function(o)
{
populateEventDefaults(o.responseText);
}
var handleFailureInitEvent = function(o)
{
alert("Unable to Retrieve Default values for Events, " + o.statusText);
}
var callbackInitEvent =
{
success:handleSuccessInitEvent,
failure:handleFailureInitEvent,
argument: { foo:"foo", bar:"bar" }
};
function retrieveEventDefaults()
{
var sUrl = getContextPath() + '/wcservice/calendar/RetrieveEventDefaults?';
var postData = "s=" + spaceRef;
sUrl += postData;
var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callbackInitEvent, null);
}
function populateEventDefaults(response)
{
var _details = response.split("^");
if (_details.length <=0)
{
alert("Unable to Retrieve Event Defaults");
return false;
}
defaultCaption = _details[0];
var _fromDate = new Date(_details[1]);
defaultFromDate = new Date(_fromDate);
var x = _fromDate.getMonth() + 1;
defaultFromDateString = x + "/" + _fromDate.getDate() + "/" + _fromDate.getFullYear();
defaultFromTime = _fromDate.getHours() + ":" + _fromDate.getMinutes().toString().pad(2, "0", 1);
var _toDate = new Date(_details[2]);
defaultToDate = new Date(_toDate);
var y = _toDate.getMonth() + 1;
defaultToDateString = y + "/" + _toDate.getDate() + "/" + _toDate.getFullYear();
defaultToTime = _toDate.getHours() + ":" + _toDate.getMinutes().toString().pad(2, "0", 1);
defaultPlace = _details[3];
defaultColor = _details[4];
document.getElementById("txtWhatEvent").value = defaultCaption;
document.getElementById("hidFromDate").value = defaultFromDateString;
document.getElementById("txtFromDate").value = _fromDate.toDateString();
document.getElementById("lstFromTime").value = defaultFromTime;
document.getElementById("hidToDate").value = defaultToDateString;
document.getElementById("txtToDate").value = _toDate.toDateString();
document.getElementById("lstToTime").value = defaultToTime;
document.getElementById("txtWhereEvent").value = defaultPlace;
document.getElementById("txtColor").value = defaultColor;
}

View File

@@ -0,0 +1,585 @@
/************************************************************************************************************
(C) www.dhtmlgoodies.com, October 2005
This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.
Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.
Thank you!
www.dhtmlgoodies.com
Alf Magne Kalleland
************************************************************************************************************/
var MSIE = navigator.userAgent.indexOf('MSIE')>=0?true:false;
var navigatorVersion = navigator.appVersion.replace(/.*?MSIE (\d\.\d).*/g,'$1')/1;
var form_widget_amount_slider_handle = '/alfresco/images/calendar/slider_handle.gif';
var slider_handle_image_obj = false;
var sliderObjectArray = new Array();
var slider_counter = 0;
var slideInProgress = false;
var handle_start_x;
var event_start_x;
var currentSliderIndex;
function form_widget_cancel_event()
{
return false;
}
function getImageSliderHeight(){
if(!slider_handle_image_obj){
slider_handle_image_obj = new Image();
slider_handle_image_obj.src = form_widget_amount_slider_handle;
}
if(slider_handle_image_obj.width>0){
return;
}else{
setTimeout('getImageSliderHeight()',50);
}
}
function positionSliderImage(e,theIndex,inputObj)
{
if(this)inputObj = this;
if(!theIndex)theIndex = inputObj.getAttribute('sliderIndex');
var handleImg = document.getElementById('slider_handle' + theIndex);
var ratio = sliderObjectArray[theIndex]['width'] / (sliderObjectArray[theIndex]['max']-sliderObjectArray[theIndex]['min']);
var currentValue = sliderObjectArray[theIndex]['formTarget'].value-sliderObjectArray[theIndex]['min'];
handleImg.style.left = currentValue * ratio + 'px';
setColorByRGB();
}
function adjustFormValue(theIndex)
{
var handleImg = document.getElementById('slider_handle' + theIndex);
var ratio = sliderObjectArray[theIndex]['width'] / (sliderObjectArray[theIndex]['max']-sliderObjectArray[theIndex]['min']);
var currentPos = handleImg.style.left.replace('px','');
sliderObjectArray[theIndex]['formTarget'].value = Math.round(currentPos / ratio) + sliderObjectArray[theIndex]['min'];
}
function initMoveSlider(e)
{
if(document.all)e = event;
slideInProgress = true;
event_start_x = e.clientX;
handle_start_x = this.style.left.replace('px','');
currentSliderIndex = this.id.replace(/[^\d]/g,'');
return false;
}
function startMoveSlider(e)
{
if(document.all)e = event;
if(!slideInProgress)return;
var leftPos = handle_start_x/1 + e.clientX/1 - event_start_x;
if(leftPos<0)leftPos = 0;
if(leftPos/1>sliderObjectArray[currentSliderIndex]['width'])leftPos = sliderObjectArray[currentSliderIndex]['width'];
document.getElementById('slider_handle' + currentSliderIndex).style.left = leftPos + 'px';
adjustFormValue(currentSliderIndex);
if(sliderObjectArray[currentSliderIndex]['onchangeAction']){
eval(sliderObjectArray[currentSliderIndex]['onchangeAction']);
}
}
function stopMoveSlider()
{
slideInProgress = false;
}
function form_widget_amount_slider(targetElId,formTarget,width,min,max,onchangeAction)
{
if(!slider_handle_image_obj){
getImageSliderHeight();
}
slider_counter = slider_counter +1;
sliderObjectArray[slider_counter] = new Array();
sliderObjectArray[slider_counter] = {"width":width - 9,"min":min,"max":max,"formTarget":formTarget,"onchangeAction":onchangeAction};
formTarget.setAttribute('sliderIndex',slider_counter);
formTarget.onchange = positionSliderImage;
var parentObj = document.createElement('DIV');
parentObj.style.width = width + 'px';
parentObj.style.height = '12px'; // The height of the image
parentObj.style.position = 'relative';
parentObj.id = 'slider_container' + slider_counter;
document.getElementById(targetElId).appendChild(parentObj);
var obj = document.createElement('DIV');
obj.className = 'form_widget_amount_slider';
obj.innerHTML = '<span></span>';
obj.style.width = width + 'px';
obj.id = 'slider_slider' + slider_counter;
obj.style.position = 'absolute';
obj.style.bottom = '0px';
parentObj.appendChild(obj);
var handleImg = document.createElement('IMG');
handleImg.style.position = 'absolute';
handleImg.style.left = '0px';
handleImg.style.zIndex = 5;
handleImg.src = slider_handle_image_obj.src;
handleImg.id = 'slider_handle' + slider_counter;
handleImg.onmousedown = initMoveSlider;
if(document.body.onmouseup){
if(document.body.onmouseup.toString().indexOf('stopMoveSlider')==-1){
alert('You allready have an onmouseup event assigned to the body tag');
}
}else{
document.body.onmouseup = stopMoveSlider;
document.body.onmousemove = startMoveSlider;
}
handleImg.ondragstart = form_widget_cancel_event;
parentObj.appendChild(handleImg);
positionSliderImage(false,slider_counter);
}
var namedColors = new Array('AliceBlue','AntiqueWhite','Aqua','Aquamarine','Azure','Beige','Bisque','Black','BlanchedAlmond','Blue','BlueViolet','Brown',
'BurlyWood','CadetBlue','Chartreuse','Chocolate','Coral','CornflowerBlue','Cornsilk','Crimson','Cyan','DarkBlue','DarkCyan','DarkGoldenRod','DarkGray',
'DarkGreen','DarkKhaki','DarkMagenta','DarkOliveGreen','Darkorange','DarkOrchid','DarkRed','DarkSalmon','DarkSeaGreen','DarkSlateBlue','DarkSlateGray',
'DarkTurquoise','DarkViolet','DeepPink','DeepSkyBlue','DimGray','DodgerBlue','Feldspar','FireBrick','FloralWhite','ForestGreen','Fuchsia','Gainsboro',
'GhostWhite','Gold','GoldenRod','Gray','Green','GreenYellow','HoneyDew','HotPink','IndianRed','Indigo','Ivory','Khaki','Lavender','LavenderBlush',
'LawnGreen','LemonChiffon','LightBlue','LightCoral','LightCyan','LightGoldenRodYellow','LightGrey','LightGreen','LightPink','LightSalmon','LightSeaGreen',
'LightSkyBlue','LightSlateBlue','LightSlateGray','LightSteelBlue','LightYellow','Lime','LimeGreen','Linen','Magenta','Maroon','MediumAquaMarine',
'MediumBlue','MediumOrchid','MediumPurple','MediumSeaGreen','MediumSlateBlue','MediumSpringGreen','MediumTurquoise','MediumVioletRed','MidnightBlue',
'MintCream','MistyRose','Moccasin','NavajoWhite','Navy','OldLace','Olive','OliveDrab','Orange','OrangeRed','Orchid','PaleGoldenRod','PaleGreen',
'PaleTurquoise','PaleVioletRed','PapayaWhip','PeachPuff','Peru','Pink','Plum','PowderBlue','Purple','Red','RosyBrown','RoyalBlue','SaddleBrown',
'Salmon','SandyBrown','SeaGreen','SeaShell','Sienna','Silver','SkyBlue','SlateBlue','SlateGray','Snow','SpringGreen','SteelBlue','Tan','Teal','Thistle',
'Tomato','Turquoise','Violet','VioletRed','Wheat','White','WhiteSmoke','Yellow','YellowGreen');
var namedColorRGB = new Array('#F0F8FF','#FAEBD7','#00FFFF','#7FFFD4','#F0FFFF','#F5F5DC','#FFE4C4','#000000','#FFEBCD','#0000FF','#8A2BE2','#A52A2A','#DEB887',
'#5F9EA0','#7FFF00','#D2691E','#FF7F50','#6495ED','#FFF8DC','#DC143C','#00FFFF','#00008B','#008B8B','#B8860B','#A9A9A9','#006400','#BDB76B','#8B008B',
'#556B2F','#FF8C00','#9932CC','#8B0000','#E9967A','#8FBC8F','#483D8B','#2F4F4F','#00CED1','#9400D3','#FF1493','#00BFFF','#696969','#1E90FF','#D19275',
'#B22222','#FFFAF0','#228B22','#FF00FF','#DCDCDC','#F8F8FF','#FFD700','#DAA520','#808080','#008000','#ADFF2F','#F0FFF0','#FF69B4','#CD5C5C','#4B0082',
'#FFFFF0','#F0E68C','#E6E6FA','#FFF0F5','#7CFC00','#FFFACD','#ADD8E6','#F08080','#E0FFFF','#FAFAD2','#D3D3D3','#90EE90','#FFB6C1','#FFA07A','#20B2AA',
'#87CEFA','#8470FF','#778899','#B0C4DE','#FFFFE0','#00FF00','#32CD32','#FAF0E6','#FF00FF','#800000','#66CDAA','#0000CD','#BA55D3','#9370D8','#3CB371',
'#7B68EE','#00FA9A','#48D1CC','#C71585','#191970','#F5FFFA','#FFE4E1','#FFE4B5','#FFDEAD','#000080','#FDF5E6','#808000','#6B8E23','#FFA500','#FF4500',
'#DA70D6','#EEE8AA','#98FB98','#AFEEEE','#D87093','#FFEFD5','#FFDAB9','#CD853F','#FFC0CB','#DDA0DD','#B0E0E6','#800080','#FF0000','#BC8F8F','#4169E1',
'#8B4513','#FA8072','#F4A460','#2E8B57','#FFF5EE','#A0522D','#C0C0C0','#87CEEB','#6A5ACD','#708090','#FFFAFA','#00FF7F','#4682B4','#D2B48C','#008080',
'#D8BFD8','#FF6347','#40E0D0','#EE82EE','#D02090','#F5DEB3','#FFFFFF','#F5F5F5','#FFFF00','#9ACD32');
var color_picker_div = false;
var color_picker_active_tab = false;
var color_picker_form_field = false;
var color_picker_active_input = false;
function baseConverter (number,ob,nb) {
number = number + "";
number = number.toUpperCase();
var list = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var dec = 0;
for (var i = 0; i <= number.length; i++) {
dec += (list.indexOf(number.charAt(i))) * (Math.pow(ob , (number.length - i - 1)));
}
number = "";
var magnitude = Math.floor((Math.log(dec))/(Math.log(nb)));
for (var i = magnitude; i >= 0; i--) {
var amount = Math.floor(dec/Math.pow(nb,i));
number = number + list.charAt(amount);
dec -= amount*(Math.pow(nb,i));
}
if(number.length==0)number=0;
return number;
}
function colorPickerGetTopPos(inputObj)
{
var returnValue = inputObj.offsetTop;
while((inputObj = inputObj.offsetParent) != null){
returnValue += inputObj.offsetTop;
}
return returnValue;
}
function colorPickerGetLeftPos(inputObj)
{
var returnValue = inputObj.offsetLeft;
while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
return returnValue;
}
function cancelColorPickerEvent(){
return false;
}
function showHideColorOptions(e,inputObj)
{
var thisObj = this;
if(inputObj){
var parentNode = inputObj.parentNode;
thisObj = inputObj;
}else var parentNode = this.parentNode;
var activeColorDiv = false;
var subDiv = parentNode.getElementsByTagName('DIV')[0];
counter=0;
var initZIndex = 10;
var contentDiv = document.getElementById('color_picker_content').getElementsByTagName('DIV')[0];
do{
if(subDiv.tagName=='DIV' && subDiv.className!='colorPickerCloseButton'){
if(subDiv==thisObj){
thisObj.className='colorPickerTab_active';
thisObj.style.zIndex = 50;
var img = thisObj.getElementsByTagName('IMG')[0];
img.src = "/alfresco/images/calendar/tab_right_active.gif"
img.src = img.src.replace(/inactive/,'active');
contentDiv.style.display='block';
activeColorDiv = contentDiv;
}else{
subDiv.className = 'colorPickerTab_inactive';
var img = subDiv.getElementsByTagName('IMG')[0];
img.src = "/alfresco/images/calendar/tab_right_inactive.gif";
if(activeColorDiv)
subDiv.style.zIndex = initZIndex - counter;
else
subDiv.style.zIndex = counter;
contentDiv.style.display='none';
}
counter++;
}
subDiv = subDiv.nextSibling;
if(contentDiv.nextSibling)contentDiv = contentDiv.nextSibling;
}while(subDiv);
document.getElementById('colorPicker_statusBarTxt').innerHTML = '&nbsp;';
}
function createColorPickerTopRow(inputObj){
var tabs = ['RGB','Named colors','Color slider'];
var tabWidths = [37,90,70];
var div = document.createElement('DIV');
div.className='colorPicker_topRow';
inputObj.appendChild(div);
var currentWidth = 0;
for(var no=0;no<tabs.length;no++){
var tabDiv = document.createElement('DIV');
tabDiv.onselectstart = cancelColorPickerEvent;
tabDiv.ondragstart = cancelColorPickerEvent;
if(no==0){
suffix = 'active';
color_picker_active_tab = this;
}else suffix = 'inactive';
tabDiv.id = 'colorPickerTab' + no;
tabDiv.onclick = showHideColorOptions;
if(no==0)tabDiv.style.zIndex = 50; else tabDiv.style.zIndex = 1 + (tabs.length-no);
tabDiv.style.left = currentWidth + 'px';
tabDiv.style.position = 'absolute';
tabDiv.className='colorPickerTab_' + suffix;
var tabSpan = document.createElement('SPAN');
tabSpan.innerHTML = tabs[no];
tabDiv.appendChild(tabSpan);
var tabImg = document.createElement('IMG');
tabImg.src = "/alfresco/images/calendar/tab_right_" + suffix + ".gif";
tabDiv.appendChild(tabImg);
div.appendChild(tabDiv);
if(navigatorVersion<6 && MSIE){ /* Lower IE version fix */
tabSpan.style.position = 'relative';
tabImg.style.position = 'relative';
tabImg.style.left = '-3px';
tabDiv.style.cursor = 'hand';
}
currentWidth = currentWidth + tabWidths[no];
}
var closeButton = document.createElement('DIV');
closeButton.className='colorPickerCloseButton';
closeButton.innerHTML = 'x';
closeButton.onclick = closeColorPicker;
closeButton.onmouseover = toggleCloseButton;
closeButton.onmouseout = toggleOffCloseButton;
div.appendChild(closeButton);
}
function toggleCloseButton()
{
this.style.color='#FFF';
this.style.backgroundColor = '#317082';
}
function toggleOffCloseButton()
{
this.style.color='';
this.style.backgroundColor = '';
}
function closeColorPicker()
{
color_picker_div.style.display='none';
}
function createWebColors(inputObj){
var webColorDiv = document.createElement('DIV');
webColorDiv.style.paddingTop = '1px';
inputObj.appendChild(webColorDiv);
for(var r=15;r>=0;r-=3){
for(var g=0;g<=15;g+=3){
for(var b=0;b<=15;b+=3){
var red = baseConverter(r,10,16) + '';
var green = baseConverter(g,10,16) + '';
var blue = baseConverter(b,10,16) + '';
var color = '#' + red + red + green + green + blue + blue;
var div = document.createElement('DIV');
div.style.backgroundColor=color;
div.innerHTML = '<span></span>';
div.className='colorSquare';
div.title = color;
div.onclick = chooseColor;
div.setAttribute('rgbColor',color);
div.onmouseover = colorPickerShowStatusBarText;
div.onmouseout = colorPickerHideStatusBarText;
webColorDiv.appendChild(div);
}
}
}
}
function createNamedColors(inputObj){
var namedColorDiv = document.createElement('DIV');
namedColorDiv.style.paddingTop = '1px';
namedColorDiv.style.display='none';
inputObj.appendChild(namedColorDiv);
for(var no=0;no<namedColors.length;no++){
var color = namedColorRGB[no];
var div = document.createElement('DIV');
div.style.backgroundColor=color;
div.innerHTML = '<span></span>';
div.className='colorSquare';
div.title = namedColors[no];
div.onclick = chooseColor;
div.onmouseover = colorPickerShowStatusBarText;
div.onmouseout = colorPickerHideStatusBarText;
div.setAttribute('rgbColor',color);
namedColorDiv.appendChild(div);
}
}
function colorPickerHideStatusBarText()
{
document.getElementById('colorPicker_statusBarTxt').innerHTML = '&nbsp;';
}
function colorPickerShowStatusBarText()
{
var txt = this.getAttribute('rgbColor');
if(this.title.indexOf('#')<0)txt = txt + " (" + this.title + ")";
document.getElementById('colorPicker_statusBarTxt').innerHTML = txt;
}
function createAllColorDiv(inputObj){
var allColorDiv = document.createElement('DIV');
allColorDiv.style.display='none';
allColorDiv.className = 'js_color_picker_allColorDiv';
allColorDiv.style.paddingLeft = '3px';
allColorDiv.style.paddingTop = '5px';
allColorDiv.style.paddingBottom = '5px';
inputObj.appendChild(allColorDiv);
var labelDiv = document.createElement('DIV');
labelDiv.className='colorSliderLabel';
labelDiv.innerHTML = 'R';
allColorDiv.appendChild(labelDiv);
var innerDiv = document.createElement('DIV');
innerDiv.className = 'colorSlider';
innerDiv.id = 'sliderRedColor';
allColorDiv.appendChild(innerDiv);
var innerDivInput = document.createElement('DIV');
innerDivInput.className='colorInput';
var input = document.createElement('INPUT');
input.id = 'js_color_picker_red_color';
input.maxlength = 3;
input.style.width = '48px';
input.style.fontSize = '11px';
input.name = 'redColor';
input.value = 0;
innerDivInput.appendChild(input);
allColorDiv.appendChild(innerDivInput);
var labelDiv = document.createElement('DIV');
labelDiv.className='colorSliderLabel';
labelDiv.innerHTML = 'G';
allColorDiv.appendChild(labelDiv);
var innerDiv = document.createElement('DIV');
innerDiv.className = 'colorSlider';
innerDiv.id = 'sliderGreenColor';
allColorDiv.appendChild(innerDiv);
var innerDivInput = document.createElement('DIV');
innerDivInput.className='colorInput';
var input = document.createElement('INPUT');
input.id = 'js_color_picker_green_color';
input.maxlength = 3;
input.style.width = '48px';
input.style.fontSize = '11px';
input.name = 'GreenColor';
input.value = 0;
innerDivInput.appendChild(input);
allColorDiv.appendChild(innerDivInput);
var labelDiv = document.createElement('DIV');
labelDiv.className='colorSliderLabel';
labelDiv.innerHTML = 'B';
allColorDiv.appendChild(labelDiv);
var innerDiv = document.createElement('DIV');
innerDiv.className = 'colorSlider';
innerDiv.id = 'sliderBlueColor';
allColorDiv.appendChild(innerDiv);
var innerDivInput = document.createElement('DIV');
innerDivInput.className='colorInput';
var input = document.createElement('INPUT');
input.id = 'js_color_picker_blue_color';
input.maxlength = 3;
input.style.width = '48px';
input.style.fontSize = '11px';
input.name = 'BlueColor';
input.value = 0;
innerDivInput.appendChild(input);
allColorDiv.appendChild(innerDivInput);
var colorPreview = document.createElement('DIV');
colorPreview.className='colorPreviewDiv';
colorPreview.id = 'colorPreview';
colorPreview.style.backgroundColor = '#000000';
colorPreview.innerHTML = '<span></span>';
colorPreview.title = 'Click on me to assign color';
allColorDiv.appendChild(colorPreview);
colorPreview.onclick = chooseColorSlider;
var colorCodeDiv = document.createElement('DIV');
colorCodeDiv.className='colorCodeDiv';
var input = document.createElement('INPUT');
input.id = 'js_color_picker_color_code';
colorCodeDiv.appendChild(input);
input.maxLength = 7;
input.style.fontSize = '11px';
input.style.width = '48px';
input.value = '#000000';
input.onchange = setPreviewColorFromTxt;
input.onblur = setPreviewColorFromTxt;
allColorDiv.appendChild(colorCodeDiv);
var clearingDiv = document.createElement('DIV');
clearingDiv.style.clear = 'both';
allColorDiv.appendChild(clearingDiv);
form_widget_amount_slider('sliderRedColor',document.getElementById('js_color_picker_red_color'),170,0,255,"setColorByRGB()");
form_widget_amount_slider('sliderGreenColor',document.getElementById('js_color_picker_green_color'),170,0,255,"setColorByRGB()");
form_widget_amount_slider('sliderBlueColor',document.getElementById('js_color_picker_blue_color'),170,0,255,"setColorByRGB()");
}
function setPreviewColorFromTxt()
{
if(this.value.match(/\#[0-9A-F]{6}/g)){
document.getElementById('colorPreview').style.backgroundColor=this.value;
var r = this.value.substr(1,2);
var g = this.value.substr(3,2);
var b = this.value.substr(5,2);
document.getElementById('js_color_picker_red_color').value = baseConverter(r,16,10);
document.getElementById('js_color_picker_green_color').value = baseConverter(g,16,10);
document.getElementById('js_color_picker_blue_color').value = baseConverter(b,16,10);
positionSliderImage(false,1,document.getElementById('js_color_picker_red_color'));
positionSliderImage(false,2,document.getElementById('js_color_picker_green_color'));
positionSliderImage(false,3,document.getElementById('js_color_picker_blue_color'));
}
}
function chooseColor()
{
color_picker_form_field.value = this.getAttribute('rgbColor');
color_picker_div.style.display='none';
}
function createStatusBar(inputObj)
{
var div = document.createElement('DIV');
div.className='colorPicker_statusBar';
var innerSpan = document.createElement('SPAN');
innerSpan.id = 'colorPicker_statusBarTxt';
div.appendChild(innerSpan);
inputObj.appendChild(div);
}
function chooseColorSlider()
{
color_picker_form_field.value = document.getElementById('js_color_picker_color_code').value;
color_picker_div.style.display='none';
}
function showColorPicker(inputObj,formField)
{
if(!color_picker_div){
color_picker_div = document.createElement('DIV');
color_picker_div.id = 'dhtmlgoodies_colorPicker';
color_picker_div.style.display='none';
document.body.appendChild(color_picker_div);
createColorPickerTopRow(color_picker_div);
var contentDiv = document.createElement('DIV');
contentDiv.id = 'color_picker_content';
color_picker_div.appendChild(contentDiv);
createWebColors(contentDiv);
createNamedColors(contentDiv);
createAllColorDiv(contentDiv);
createStatusBar(color_picker_div);
}
if(color_picker_div.style.display=='none' || color_picker_active_input!=inputObj)color_picker_div.style.display='block'; else color_picker_div.style.display='none';
color_picker_div.style.left = colorPickerGetLeftPos(inputObj) + 'px';
color_picker_div.style.top = colorPickerGetTopPos(inputObj) + inputObj.offsetHeight + 2 + 'px';
color_picker_form_field = formField;
color_picker_active_input = inputObj;
}
function setColorByRGB()
{
var formObj = document.forms[0];
var r = document.getElementById('js_color_picker_red_color').value.replace(/[^\d]/,'');
var g = document.getElementById('js_color_picker_green_color').value.replace(/[^\d]/,'');
var b = document.getElementById('js_color_picker_blue_color').value.replace(/[^\d]/,'');
if(r/1>255)r=255;
if(g/1>255)g=255;
if(b/1>255)b=255;
r = baseConverter(r,10,16) + '';
g = baseConverter(g,10,16) + '';
b = baseConverter(b,10,16) + '';
if(r.length==1)r = '0' + r;
if(g.length==1)g = '0' + g;
if(b.length==1)b = '0' + b;
document.getElementById('colorPreview').style.backgroundColor = '#' + r + g + b;
document.getElementById('js_color_picker_color_code').value = '#' + r + g + b;
}

View File

@@ -0,0 +1,187 @@
var handleSuccessSaveEvent = function(o)
{
hideSavingIndicator('c');
alert("Calendar updated!");
resetEventDetails();
refreshAllViews();
}
var handleFailureSaveEvent = function(o)
{
hideSavingIndicator('c');
alert("Unable to Save, " + o.statusText);
}
var callbackSaveEvent =
{
success:handleSuccessSaveEvent,
failure:handleFailureSaveEvent,
argument: { foo:"foo", bar:"bar" }
};
function saveCalendarEvent(toDelete)
{
if (!validateEventDetails(toDelete)) return;
showSavingIndicator('c');
var sUrl = getContextPath() + '/wcservice/calendar/SaveCalendarEvent?';
var postData = constructCalendarData(toDelete);
sUrl += postData;
var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callbackSaveEvent, null);
}
function constructCalendarData(toDelete)
{
var data = "";
data += "s=" + spaceRef;
data += "&";
data += "what=" + document.getElementById("txtWhatEvent").value;
data += "&";
data += "fd=" + document.getElementById("hidFromDate").value;
data += "&";
data += "ft=" + document.getElementById("lstFromTime").value;
data += "&";
data += "td=" + document.getElementById("hidToDate").value;
data += "&";
data += "tt=" + document.getElementById("lstToTime").value;
data += "&";
data += "where=" + document.getElementById("txtWhereEvent").value;
data += "&";
data += "desc=" + document.getElementById("txtDescriptionEvent").value;
data += "&";
data += "color=" + document.getElementById("txtColor").value;
data += "&";
if (toDelete)
{
data += "d=true";
}
else
{
data += "d=false";
}
if (_currentActiveEditingEvent != null)
{
data += "&";
data += "e=" + _currentActiveEditingEvent;
}
return data;
}
function resetEventDetails()
{
document.getElementById("txtWhatEvent").value = defaultCaption;
document.getElementById("hidFromDate").value = defaultFromDateString;
document.getElementById("txtFromDate").value = defaultFromDate.toDateString();
document.getElementById("lstFromTime").value = defaultFromTime;
document.getElementById("hidToDate").value = defaultToDateString;
document.getElementById("txtToDate").value = defaultToDate.toDateString();
document.getElementById("lstToTime").value = defaultToTime;
document.getElementById("txtWhereEvent").value = defaultPlace;
document.getElementById("txtColor").value = defaultColor;
/*document.getElementById("txtWhatEvent").value = "";
document.getElementById("hidFromDate").value = "";
document.getElementById("txtFromDate").value = "";
document.getElementById("lstFromTime").selectedIndex = 0;
document.getElementById("hidToDate").value = "";
document.getElementById("txtToDate").value = "";
document.getElementById("lstToTime").selectedIndex = 0;
document.getElementById("txtWhereEvent").value = "";
document.getElementById("txtDescriptionEvent").value = "";
document.getElementById("txtColor").value = "";*/
document.getElementById("txtWhatEvent").focus();
_currentActiveEditingEvent = null;
}
function validateEventDetails(toDelete)
{
if (toDelete)
if (_currentActiveEditingEvent == null)
{
alert("No Event Currently selected.\rPlease select an Event first from Month/Week/Day view to delete.");
return false;
}
if (trim(document.getElementById("txtWhatEvent").value) == "")
{
alert("Please enter Event Information!");
document.getElementById("txtWhatEvent").focus();
return false;
}
if (!ValidateString(trim(document.getElementById("txtWhatEvent").value)))
{
document.getElementById("txtWhatEvent").focus();
return false;
}
if (trim(document.getElementById("txtFromDate").value) == "")
{
alert("Please select a valid Starting Date!");
document.getElementById("txtFromDate").focus();
return false;
}
if (trim(document.getElementById("txtToDate").value) == "")
{
alert("Please select a valid Ending Date!");
document.getElementById("txtToDate").focus();
return false;
}
if (!ValidateDateSet())
{
alert("Ending Date must be greater than Starting Date!");
document.getElementById("txtToDate").focus();
return false;
}
return true;
}
function ValidateString(dataValue)
{
for(var j=0; j<dataValue.length; j++)
{
var alphaa = dataValue.charAt(j);
var hh = alphaa.charCodeAt(0);
/*
Allowed Characters:
48-57 -> 0-9
64-91 -> A-Z
96-123 -> a-z
32 -> space bar
44 -> ,
59 -> ;
40 -> (
41 -> )
63 -> ?
33 -> !
45 -> -
95 -> _
*/
if((hh>=48 && hh<=57) || (hh>64 && hh<91) || (hh>96 && hh<123) || (hh==32) || (hh==44) || (hh==59) || (hh==40) || (hh==41) || (hh==63) || (hh==33) || (hh==45) || (hh==95))
{
}
else
{
alert("Event Information has some invalid characters.\rAllowed Characters are 0-9 a-z A-Z , ; ( ) ? ! - _");
return false;
}
}
return true;
}
function ValidateDateSet()
{
var fromDate = new Date(document.getElementById("hidFromDate").value);
var fromTime = document.getElementById("lstFromTime").value.split(":");
fromDate.setHours(fromTime[0]);
fromDate.setMinutes(fromTime[1]);
var toDate = new Date(document.getElementById("hidToDate").value);
var toTime = document.getElementById("lstToTime").value.split(":");
toDate.setHours(toTime[0]);
toDate.setMinutes(toTime[1]);
return !(toDate <= fromDate);
}