--- /dev/null
+#Sat May 16 21:17:03 JST 2009
+eclipse.preferences.version=1
+encoding//src/jp/sourceforge/manganetwork/page/HomePage.html=UTF-8
+encoding//src/jp/sourceforge/manganetwork/page/LoginPage.html=UTF-8
+encoding//src/jp/sourceforge/manganetwork/page/LoginPage.java=UTF-8
+encoding//src/jp/sourceforge/manganetwork/page/MenuApplicationPage.html=UTF-8
+encoding/<project>=UTF-8
--- /dev/null
+#Sat May 16 19:00:18 JST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<tomcatProjectProperties>
+ <rootDir>war</rootDir>
+ <exportSource>false</exportSource>
+ <reloadable>true</reloadable>
+ <redirectLogger>false</redirectLogger>
+ <updateXml>true</updateXml>
+ <warLocation></warLocation>
+ <extraInfo></extraInfo>
+ <webPath>manga</webPath>
+</tomcatProjectProperties>
@Override
protected void init() {
super.init();
+ setEncoding();
+
mountBookmarkablePage("/admin", AdminHomePage.class);
}
+
+ private void setEncoding() {
+ getRequestCycleSettings().setResponseRequestEncoding("UTF-8");
+ getMarkupSettings().setDefaultMarkupEncoding("UTF-8");
+ }
}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <link rel="stylesheet" type="text/css" href="manga/layout/style.css">
+ <wicket:link>
+ <link rel="stylesheet" type="text/css" href="stylesheets/style.css">
+ </wicket:link>
<title></title>
</head>
<body>
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <link rel="stylesheet" type="text/css" href="manga/layout/style.css">
- <script type="text/javascript" src="manga/javascripts/spinelz_lib/prototype.js"></script>
- <script type="text/javascript" src="manga/javascripts/spinelz_lib/scriptaculous.js"></script>
- <script type="text/javascript" src="manga/javascripts/spinelz_lib/spinelz_util.js"></script>
- <script type="text/javascript" src="manga/javascripts/spinelz/menubar.js"></script>
- <link rel="stylesheet" href="manga/stylesheets/spinelz/menubar.css" type="text/css">
-
- <script type="text/javascript">
- var menubar = new MenuBar('menucontents');
- </script>
- <title></title>
- </head>
- <body>
- <div id="header">
- <h1>マンガネットワーク</h1>
- </div>
- <div id="menucontents">
- <div>ホーム</div>
- <div>本
- <div>検索</div>
- <div>登録</div>
- </div>
- <div>ワークフロー
- <div>検索</div>
- <div>登録</div>
- </div>
- <div>連絡
- <div>登録</div>
- </div>
- <div>ユーザ情報
- <div>参照</div>
- </div>
- </div>
- <wicket:child />
- </body>
-</html>
\ No newline at end of file
+ <title>マンガネットワーク</title>
+ <head>
+ <wicket:link>
+ <script type="text/javascript" src="javascripts/spinelz_lib/prototype.js"></script>
+ <script type="text/javascript" src="javascripts/spinelz_lib/scriptaculous.js"></script>
+ <script type="text/javascript" src="javascripts/spinelz_lib/spinelz_util.js"></script>
+ <script type="text/javascript" src="javascripts/spinelz/menubar.js"></script>
+ <link rel="stylesheet" href="stylesheets/spinelz/menubar.css" type="text/css" />
+ </wicket:link>
+ </head>
+ <body>
+ <div id="header">
+ <h1>マンガネットワーク</h1>
+ </div>
+ <div id="menucontents">
+ <div>ホーム</div>
+ <div>本
+ <div>検索</div>
+ <div>登録</div>
+ </div>
+ <div>ワークフロー
+ <div>検索</div>
+ <div>登録</div>
+ </div>
+ <div>連絡
+ <div>登録</div>
+ </div>
+ <div>ユーザ情報
+ <div>参照</div>
+ </div>
+ </div>
+
+ <script type="text/javascript">
+ var menubar = new MenuBar('menucontents');
+ var foo = function() {
+ alert('foo function was called.');
+ }
+ </script>
+
+ <wicket:child />
+
+ </body>
+</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <link rel="stylesheet" type="text/css" href="manga/layout/style.css">
+ <wicket:link>
+ <link rel="stylesheet" type="text/css" href="stylesheets/style.css">
+ </wicket:link>
<title></title>
</head>
<body>
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <link rel="stylesheet" type="text/css" href="manga/layout/style.css">
- <script type="text/javascript" src="manga/javascripts/spinelz_lib/prototype.js"></script>
- <script type="text/javascript" src="manga/javascripts/spinelz_lib/scriptaculous.js"></script>
- <script type="text/javascript" src="manga/javascripts/spinelz_lib/spinelz_util.js"></script>
- <script type="text/javascript" src="manga/javascripts/spinelz/menubar.js"></script>
- <link rel="stylesheet" href="manga/stylesheets/spinelz/menubar.css" type="text/css">
-
- <script type="text/javascript">
- var menubar = new MenuBar('menucontents');
- </script>
- <title></title>
- </head>
- <body>
- <div id="header">
- <h1>マンガネットワーク</h1>
- </div>
- <div id="menucontents">
- <div>ホーム</div>
- <div>本
- <div>検索</div>
- <div>登録</div>
- </div>
- <div>ワークフロー
- <div>検索</div>
- <div>登録</div>
- </div>
- <div>連絡
- <div>登録</div>
- </div>
- <div>ユーザ情報
- <div>参照</div>
- </div>
- </div>
- <wicket:child />
- </body>
-</html>
\ No newline at end of file
+ <title>マンガネットワーク</title>
+ <head>
+ <wicket:link>
+ <script type="text/javascript" src="javascripts/spinelz_lib/prototype.js"></script>
+ <script type="text/javascript" src="javascripts/spinelz_lib/scriptaculous.js"></script>
+ <script type="text/javascript" src="javascripts/spinelz_lib/spinelz_util.js"></script>
+ <script type="text/javascript" src="javascripts/spinelz/menubar.js"></script>
+ <link rel="stylesheet" href="stylesheets/spinelz/menubar.css" type="text/css" />
+ </wicket:link>
+ </head>
+ <body>
+ <div id="header">
+ <h1>マンガネットワーク</h1>
+ </div>
+ <div id="menucontents">
+ <div>ホーム</div>
+ <div>本
+ <div>検索</div>
+ <div>登録</div>
+ </div>
+ <div>ワークフロー
+ <div>検索</div>
+ <div>登録</div>
+ </div>
+ <div>連絡
+ <div>登録</div>
+ </div>
+ <div>ユーザ情報
+ <div>参照</div>
+ </div>
+ </div>
+
+ <script type="text/javascript">
+ var menubar = new MenuBar('menucontents');
+ var foo = function() {
+ alert('foo function was called.');
+ }
+ </script>
+
+ <wicket:child />
+
+ </body>
+</html>
--- /dev/null
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+Accordion = Class.create();
+Accordion.className = {
+ accordion : 'accordion',
+ panel: 'accordion_panel',
+ tab : 'accordion_tab',
+ tabLeftInactive : 'accordion_tabLeftInactive',
+ tabLeftActive: 'accordion_tabLeftActive',
+ tabMiddleInactive : 'accordion_tabMiddleInactive',
+ tabMiddleActive : 'accordion_tabMiddleActive',
+ tabRightInactive : 'accordion_tabRightInactive',
+ tabRightActive : 'accordion_tabRightActive'
+}
+
+Accordion.prototype = {
+
+ initialize: function(element) {
+ var options = Object.extend({
+ cssPrefix: 'custom_',
+ selected: 1,
+ duration: 0.5
+ }, arguments[1] || {});
+
+ this.options = options;
+ this.element = $(element);
+ Element.setStyle(this.element, {visibility: 'hidden'});
+ Element.hide(this.element);
+
+ var customCss = CssUtil.appendPrefix(this.options.cssPrefix, Accordion.className);
+ this.classNames = new CssUtil([Accordion.className, customCss]);
+
+ this.classNames.addClassNames(this.element, 'accordion');
+
+ this.selected = (this.options.selected > 0) ? this.options.selected - 1 : 0 ;
+ this.start();
+
+ Element.setStyle(this.element, {visibility: 'visible'});
+ Element.show(this.element);
+ this.effecting = false;
+ },
+
+ start: function() {
+ this.tabs = [];
+ this.panels = [];
+ this.panelList = [];
+
+ this.tabId = this.element.id + '_tab';
+ this.tabLeftId = this.tabId + '_left';
+ this.tabMiddleId = this.tabId + '_middle';
+ this.tabRightId = this.tabId + '_right';
+ this.panelId = this.element.id + '_panel';
+
+ this.build();
+ },
+
+ build: function() {
+ Element.cleanWhitespace(this.element);
+ this.panelList = this.element.childNodes;
+
+ for (var i = 0; i < this.panelList.length; i++) {
+ if (this.panelList[i].nodeType != 1) {
+ Element.remove(this.panelList[i]);
+ i--;
+ continue;
+ }
+ Element.cleanWhitespace(this.panelList[i]);
+ var navSet = this.panelList[i].childNodes;
+ this.buildTab(navSet[0], i);
+ this.buildPanel(navSet[0], i);
+ }
+ this.selectTab();
+ },
+
+
+ buildTab: function(tabTitle, i) {
+ var tab = Builder.node('div', {id:this.tabId + i});
+ this.classNames.addClassNames(tab, 'tab');
+ var tabLeft = Builder.node('div', {id:this.tabLeftId + i});
+ var tabMiddle = Builder.node('div', {id:this.tabMiddleId + i});
+ tabMiddle.appendChild(tabTitle);
+ var tabRight = Builder.node('div', {id:this.tabRightId + i});
+
+ tab.appendChild(tabLeft);
+ tab.appendChild(tabMiddle);
+ tab.appendChild(tabRight);
+ Event.observe(tab, 'click', this.selectTab.bindAsEventListener(this));
+
+ this.tabs[i] = tab;
+ this.setTabInactive(tab);
+ this.panelList[i].appendChild(tab);
+ },
+
+ buildPanel: function(panelContent, i) {
+ var panel = Builder.node('div', {id:this.panelId + i});
+ this.classNames.addClassNames(panel, 'panel');
+
+ panel.appendChild(panelContent);
+ Element.hide(panel);
+ this.panels[i] = panel;
+ this.panelList[i].appendChild(panel);
+ },
+
+ selectTab: function(e) {
+ if (this.effecting) return;
+ if (!e) {
+ if (!this.panels[this.selected]) this.selected = 0;
+ Element.show(this.panels[this.selected]);
+ this.setTabActive(this.tabs[this.selected]);
+ return;
+ }
+
+ var targetElement = Event.element(e);
+ var targetIndex = this.getTargetIndex(targetElement);
+ if (targetIndex == this.selected) return;
+
+ var currentPanel = this.panels[this.selected];
+ var targetPanel = this.panels[targetIndex];
+ this.setTabInactive(this.tabs[this.selected]);
+ this.setTabActive(this.tabs[targetIndex]);
+
+ this.effecting = true;
+ new Effect.Parallel(
+ [
+ new Effect.BlindUp(currentPanel, {sync: true}),
+ new Effect.BlindDown(targetPanel, {sync: true})
+ ],
+ {
+ duration: this.options.duration,
+ beforeStart: function() { this.effecting = true; }.bind(this),
+ afterFinish: function() { this.effecting = false; }.bind(this)
+ }
+ );
+
+ this.selected = targetIndex;
+ },
+
+ setTabActive: function(tab) {
+ var tabChildren = tab.childNodes;
+
+ this.classNames.refreshClassNames(tabChildren[0], 'tabLeftActive');
+ this.classNames.refreshClassNames(tabChildren[1], 'tabMiddleActive');
+ this.classNames.refreshClassNames(tabChildren[2], 'tabRightActive');
+ },
+
+ setTabInactive: function(tab) {
+ var tabChildren = tab.childNodes;
+
+ this.classNames.refreshClassNames(tabChildren[0], 'tabLeftInactive');
+ this.classNames.refreshClassNames(tabChildren[1], 'tabMiddleInactive');
+ this.classNames.refreshClassNames(tabChildren[2], 'tabRightInactive');
+ },
+
+ getTargetIndex: function(element) {
+ while(element) {
+ if (element.id && element.id.indexOf(this.tabId, 0) >= 0) {
+ var index = element.id.substring(this.tabId.length);
+ if (!isNaN(index)) {
+ return index;
+ }
+ }
+ element = element.parentNode;
+ }
+ }
+}
--- /dev/null
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var AjaxHistory = {
+ _callback: null,
+ _currentIframeHash: '',
+ _currentLocationHash: '',
+ _prefix: 'ajax_history_',
+ add: function(hash) {
+ AjaxHistoryPageManager.setHash(this._prefix + hash);
+ },
+ checkIframeHash: function() {
+ var iframeHash = AjaxHistoryIframeManager.getHash().substr(this._prefix.length);
+ if(this._currentIframeHash != iframeHash) {
+ this._currentIframeHash = iframeHash;
+ this._currentLocationHash = iframeHash;
+ AjaxHistoryPageManager.setHash((iframeHash) ? this._prefix + iframeHash : '');
+ this.doEvent(iframeHash);
+ } else {
+ this.checkLocationHash();
+ }
+ },
+ checkHash: function() {
+ if(UserAgent.isIE()) {
+ this.checkIframeHash();
+ } else {
+ this.checkLocationHash();
+ }
+ },
+ checkLocationHash: function() {
+ var locationHash = AjaxHistoryPageManager.getHash().substr(this._prefix.length);
+ if(this._currentLocationHash != locationHash) {
+ this._currentLocationHash = locationHash;
+ if(UserAgent.isIE()) {
+ AjaxHistoryIframeManager.setHash(this._prefix + locationHash);
+ } else {
+ this.doEvent(locationHash);
+ }
+ }
+ },
+ doEvent: function(hash) {
+ if(this._callback) {
+ this._callback.call(null, hash);
+ }
+ },
+ init: function(callback) {
+ this._callback = callback;
+ if(UserAgent.isIE()) {
+ AjaxHistoryIframeManager.create();
+ }
+ var self = this;
+ var hashHandler = function() {self.checkHash();}
+ setInterval(hashHandler, 100);
+ }
+}
+
+var AjaxHistoryIframeManager = {
+ _id : 'ajax_history_frame',
+ _element: null,
+ _src: IECover.src,
+ create: function() {
+ document.write('<iframe id="' + this._id + '" src="' + this._src + '" style="display: none;"></iframe>');
+ this._element = $(this._id);
+ },
+ getHash: function() {
+ var iframeDocument = this._element.contentWindow.document;
+ return iframeDocument.location.hash.replace(/^#/, '');
+ },
+ setHash: function(query) {
+ var iframeDocument = this._element.contentWindow.document;
+ iframeDocument.open();
+ iframeDocument.close();
+ iframeDocument.location.hash = query;
+ }
+}
+
+var AjaxHistoryPageManager = {
+ _delimiter: '#',
+ _location: 'window.location.href',
+ _query: '',
+ getLocation: function() {
+ return eval(this._location);
+ },
+ getHash: function() {
+ var url_elements = this.getLocation().split(this._delimiter);
+ return (url_elements.length > 1) ? url_elements[url_elements.length - 1] : this._query;
+ },
+ getUrl: function() {
+ var url_elements = this.getLocation().split(this._delimiter);
+ return url_elements[0];
+ },
+ setHash: function(query) {
+ window.location.hash = query;
+ }
+}
--- /dev/null
+// Copyright (c) 2006 spinelz.org (http://script.spinelz.org/)
+//
+// This code is substantially based on code from script.aculo.us which has the
+// following copyright and permission notice
+//
+// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
+
+var Balloon = Class.create()
+Balloon.classNames = {
+ tooltip: 'balloon_tooltip',
+ top: 'balloon_top',
+ topLeft: 'balloon_top_left',
+ topMiddle: 'balloon_top_middle',
+ topRight: 'balloon_top_right',
+ middle: 'balloon_middle',
+ middleLeft: 'balloon_middle_left',
+ middleRight: 'balloon_middle_right',
+ middleLeftRowT: 'balloon_middle_left_row',
+ middleLeftRowB: 'balloon_middle_left_row',
+ middleRightRowT: 'balloon_middle_right_row',
+ middleRightRowB: 'balloon_middle_right_row',
+ leftArrow: 'balloon_left_arrow',
+ rightArrow: 'balloon_right_arrow',
+ leftUpArrow: 'balloon_left_up_arrow',
+ leftDownArrow: 'balloon_left_down_arrow',
+ rightUpArrow: 'balloon_right_up_arrow',
+ rightDownArrow: 'balloon_right_down_arrow',
+ body: 'balloon_body',
+ bottom: 'balloon_bottom',
+ bottomLeft: 'balloon_bottom_left',
+ bottomMiddle: 'balloon_bottom_middle',
+ bottomRight: 'balloon_bottom_right'
+}
+Balloon.allBalloons = [];
+Balloon.closeAll = function(){
+ Balloon.allBalloons.each(function(b){
+ b.close();
+ });
+}
+Balloon.eventSetting = false;
+Balloon.prototype = {
+ initialize : function (target, message){
+ this.target = $(target);
+
+ this.options = Object.extend({
+ cssPrefix: 'custom_',
+ trigger: this.target,
+ tipId: this.target.id + '_balloon',
+ events: ['click'],
+ width: 300,
+ height: 200
+ }, arguments[2] || {});
+
+ var customCss = CssUtil.appendPrefix(this.options.cssPrefix, Balloon.classNames);
+ this.classNames = new CssUtil([Balloon.classNames, customCss]);
+
+ this.tipNode = this._buildTipNode(message);
+ Element.hide(this.tipNode);
+ this._setMessage(message);
+ document.body.appendChild(this.tipNode);
+ this._setEvent();
+ Balloon.allBalloons.push(this)
+ this._setSize();
+ },
+
+ _setEvent: function() {
+ var self = this;
+ this.options.events.each(function(e) {
+ Event.observe(self.options.trigger, e, self.open.bindAsEventListener(self));
+ });
+
+ Event.observe(this.tipNode, 'click', this.close.bind(this), true)
+
+ if (!Balloon.eventSetting) {
+ Event.observe(document, 'click', Balloon.closeAll, true);
+ Balloon.eventSetting = true;
+ }
+ },
+
+ _buildTipNode : function() {
+ var tipNode = Builder.node('div', {id: this.options.tipId});
+ this.classNames.addClassNames(tipNode, 'tooltip');
+ tipNode.appendChild(this._buildTop());
+ tipNode.appendChild(this._buildMiddle());
+ tipNode.appendChild(this._buildBottom());
+ return tipNode;
+ },
+
+ _setMessage: function(message) {
+ var type = message.constructor;
+ if (type == String) {
+ this.body.innerHTML = message;
+ } else if (type == Object) {
+ this.body.appendChild(message);
+ }
+ },
+
+ _buildTop: function() {
+ return this._buildMulti('top', ['topLeft', 'topMiddle', 'topRight'], true);
+ },
+
+ _buildBottom: function() {
+ return this._buildMulti('bottom', ['bottomLeft', 'bottomMiddle', 'bottomRight'], true);
+ },
+
+ _buildMiddle: function() {
+ this.middle = Builder.node('div');
+ this.classNames.addClassNames(this.middle, 'middle');
+ this.middle.appendChild(
+ this._buildMulti('middleLeft', ['middleLeftRowT', 'leftArrow', 'middleLeftRowB'], true));
+ this.middle.appendChild(this._buildMulti('body', [], true));
+ this.middle.appendChild(
+ this._buildMulti('middleRight', ['middleRightRowT', 'rightArrow', 'middleRightRowB'], true));
+ return this.middle;
+ },
+
+ _buildMulti: function(main, subs, hold) {
+ var topNode = Builder.node('div');
+ this.classNames.addClassNames(topNode, main);
+ if (hold) this[main] = topNode;
+ var self = this;
+ var node = null;
+ subs.each(function(s) {
+ node = Builder.node('div');
+ self.classNames.addClassNames(node, s);
+ topNode.appendChild(node);
+ if (hold) self[s] = node;
+ });
+ return topNode;
+ },
+
+ _setPosition: function() {
+ var scrollPosition = Position.realOffset(this.tipNode);
+ var screenWidth = document.documentElement.clientWidth;
+ var screenHeight = document.documentElement.clientHeight;
+
+ var positionList = Position.cumulativeOffset(this.target);
+ var dimension = Element.getDimensions(this.target);
+ var tipNodeLeft = Math.round(positionList[0] + dimension.width);
+ var tipDimension = Element.getDimensions(this.tipNode);
+ var tipNodeTop = Math.round(positionList[1] - tipDimension.height / 2);
+
+ var addLR = 'left';
+ var remLR = 'right';
+
+ if((tmpY = tipNodeTop - scrollPosition[1]) < 0) {
+ tipNodeTop -= tmpY;
+ }
+ if( (tipNodeLeft+tipDimension.width) > (screenWidth+scrollPosition[0]) ) {
+ tipNodeLeft = Math.round(positionList[0] - tipDimension.width);
+ addLR = 'right';
+ remLR = 'left';
+ }
+
+ var y = positionList[1] - tipNodeTop;
+ this._setArrow(addLR, y);
+ this._unsetArrow(remLR);
+
+ Element.setStyle(this.tipNode, {
+ top: tipNodeTop + 'px',
+ left: tipNodeLeft + 'px',
+ zIndex: ZindexManager.getIndex()
+ });
+ },
+
+ _setArrow: function(lr, y) {
+ var headerH = (this.options.height - this.middleH) / 2;
+ var topH, bottomH, h, ud;
+ var minH = 10; // for ie
+ if (lr == 'left') {
+ h = this.middleH - this.leftArrowH;
+ } else {
+ h = this.middleH - this.rightArrowH;
+ }
+ if (headerH > y) {
+ topH = minH;
+ bottomH = h - topH;
+ ud = 'up';
+ } else if ((this.middleH + headerH) < y) {
+ bottomH = minH;
+ topH = h - bottomH;
+ ud = 'down';
+ } else {
+ topH = y - headerH;
+ topH = (topH < minH) ? minH : topH;
+ bottomH = h - topH;
+ ud = 'up';
+ }
+ if (lr == 'left') {
+ if (ud == 'up') {
+ this.classNames.refreshClassNames(this.leftArrow, 'leftUpArrow');
+ Element.setStyle(this.leftArrow, {height: this.leftArrowH + 'px'});
+ Element.setStyle(this.middleLeftRowT, {height: topH + 'px'});
+ Element.setStyle(this.middleLeftRowB, {height: bottomH + 'px'});
+ } else {
+ this.classNames.refreshClassNames(this.leftArrow, 'leftDownArrow');
+ Element.setStyle(this.leftArrow, {height: this.leftArrowH + 'px'});
+ Element.setStyle(this.middleLeftRowT, {height: topH + 'px'});
+ Element.setStyle(this.middleLeftRowB, {height: bottomH + 'px'});
+ }
+ } else {
+ if (ud == 'up') {
+ this.classNames.refreshClassNames(this.rightArrow, 'rightUpArrow');
+ Element.setStyle(this.rightArrow, {height: this.rightArrowH + 'px'});
+ Element.setStyle(this.middleRightRowT, {height: topH + 'px'});
+ Element.setStyle(this.middleRightRowB, {height: bottomH + 'px'});
+ } else {
+ this.classNames.refreshClassNames(this.rightArrow, 'rightDownArrow');
+ Element.setStyle(this.rightArrow, {height: this.rightArrowH + 'px'});
+ Element.setStyle(this.middleRightRowT, {height: topH + 'px'});
+ Element.setStyle(this.middleRightRowB, {height: bottomH + 'px'});
+ }
+ }
+ },
+
+ _unsetArrow: function(direction) {
+ if (direction == 'left') {
+ var h = (this.middleH - this.leftArrowH) / 2;
+ this.classNames.refreshClassNames(this.leftArrow, 'middleLeftRowB');
+ Element.setStyle(this.leftArrow, {height: this.leftArrowH + 'px'});
+ Element.setStyle(this.middleLeftRowT, {height: h + 'px'});
+ Element.setStyle(this.middleLeftRowB, {height: h + 'px'});
+ } else {
+ var h = (this.middleH - this.rightArrowH) / 2;
+ this.classNames.refreshClassNames(this.rightArrow, 'middleRightRowB');
+ Element.setStyle(this.rightArrow, {height: this.rightArrowH + 'px'});
+ Element.setStyle(this.middleRightRowT, {height: h + 'px'});
+ Element.setStyle(this.middleRightRowB, {height: h + 'px'});
+ }
+ },
+
+ _setSize: function() {
+ var width = this.options.width;
+ var height = this.options.height;
+ Element.setStyle(this.tipNode, {
+ width: width + 'px',
+ height: height + 'px'
+ });
+
+ var topH = parseInt(Element.getStyle(this.top, 'height'));
+ var bottomH = parseInt(Element.getStyle(this.bottom, 'height'));
+ var middleH = this.options.height - topH - bottomH;
+
+ var style = {height: middleH + 'px'};
+ Element.setStyle(this.middle, style);
+ Element.setStyle(this.middleLeft, style);
+ Element.setStyle(this.middleRight, style);
+ Element.setStyle(this.body, style);
+
+ this.leftArrowH = parseInt(Element.getStyle(this.leftArrow, 'height'));
+ this.rightArrowH = parseInt(Element.getStyle(this.rightArrow, 'height'));
+ this.middleH = middleH;
+ },
+
+ open : function() {
+ if (!Element.visible(this.tipNode)) {
+ this._setPosition();
+ Effect.Appear(this.tipNode);
+ }
+ },
+
+ close : function(){
+ if (Element.visible(this.tipNode)) {
+ this._setPosition();
+ Effect.Fade(this.tipNode);
+ }
+ }
+}
--- /dev/null
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var AbstractBarChart = Class.create();
+AbstractBarChart.prototype = {
+
+ initialize: function(element, params) {
+ this.options = Object.extend({
+ title: '',
+ graduation: true,
+ graduationMin: 0,
+ graduationMax: 30,
+ graduationInterval: 10,
+ graduationRange: 50,
+ titleFont: 'normal bold 20px serif'
+ }, arguments[2] || {});
+
+ this.fontSize = 'normal normal 12px serif';
+ this.graduationLine = '2px solid gray';
+ this.element = $(element);
+ Element.setStyle(this.element, {visibility: 'hidden'});
+ Element.hide(this.element);
+ this.params = params;
+
+ this.init();
+
+ this.hide();
+ this.refresh();
+ Element.setStyle(this.element, {visibility: 'visible'});
+ Element.show(this.element);
+ },
+
+ build: function() {
+ return Builder.node(
+ 'DIV',
+ [this.buildTitle(), this.buildGraduationLine(), this.buildContent()]);
+ },
+
+ buildTitle: function() {
+ return Builder.node(
+ 'DIV',
+ {style: 'font: ' + this.options.titleFont + '; margin-bottom: 5px; text-align: center;'},
+ [this.options.title]
+ );
+ },
+
+ show: function() {
+ Element.show(this.element);
+ },
+
+ hide: function() {
+ Element.hide(this.element);
+ },
+
+ refresh: function(subject) {
+ if (this.chart) this.remove();
+
+ this.chart = this.build();
+ this.element.appendChild(this.chart);
+ },
+
+ getParam: function(name) {
+ return this.params.detect(function(child) {
+ return (child.getName() == name);
+ });
+ },
+
+ remove: function() {
+ var chart = this.chart;
+ var element = this.element;
+
+ $A(this.element.childNodes).any(function(child) {
+ if (child == chart) {
+ element.removeChild(child);
+ return true;
+ }
+ return false;
+ });
+
+ this.chart = null;
+ },
+
+ getChartSize: function() {
+ return this.getPlusChartSize() + this.getMinusChartSize();
+ },
+
+ getPlusChartSize: function() {
+ if (this.options.graduationMax <= 0) return 0;
+ return this.options.graduationMax / this.options.graduationInterval * this.options.graduationRange;
+ },
+
+ getMinusChartSize: function() {
+ if (this.options.graduationMin >= 0) return 0;
+ return Math.abs(this.options.graduationMin) / this.options.graduationInterval * this.options.graduationRange;
+ },
+
+ getBarSize: function(param) {
+ var size = param.getValue() / this.options.graduationInterval * this.options.graduationRange;
+ return Math.abs(size);
+ },
+
+ getFontSize: function() {
+ var arr = this.fontSize.split(' ');
+ if (arr.length == 0) return 0;
+
+ var size = arr.detect(function(child) {
+ return child.match(/px$/);
+ });
+ if (!size) return 0;
+
+ var index = size.indexOf('px');
+ if (index < 1) return 0;
+
+ size = size.substring(0, index);
+ if (isNaN(size)) return 0;
+
+ return parseInt(size);
+ }
+}
+
+var HorizontalBarChart = Class.create();
+Object.extend(Object.extend(HorizontalBarChart.prototype, AbstractBarChart.prototype), {
+
+ init: function() {
+ this.nameWidth = 125;
+ this.valueWidth = 50;
+ this.itemInterval = 35;
+ this.adjustWidth = (document.all) ? 5 : 0;
+ },
+
+ buildGraduationLine: function() {
+ if (!this.options.graduation)
+ return Builder.node('DIV', {style: 'margin-bottom: 5px; text-align: center;'});
+
+ var array = new Array();
+ var i = this.options.graduationMin;
+ //var width = (document.all) ? this.options.graduationRange : this.options.graduationRange - 2;
+ var width = this.options.graduationRange;
+
+ var style = new StyleManager();
+ style.cache('border-left', this.graduationLine);
+ style.cache('height', '5px');
+ style.cache('font-size', '5px');
+
+ while (i <= this.options.graduationMax) {
+
+ var j = i + this.options.graduationInterval;
+ if (j <= this.options.graduationMax)
+ style.add('border-top', this.graduationLine);
+
+ var elm = Builder.node(
+ 'DIV',
+ {style: 'float: left; font: ' + this.fontSize + '; width: ' + width + 'px;'},
+ [
+ Builder.node('DIV', [i]),
+ Builder.node('DIV', {style: style.output()})
+ ]
+ );
+
+ array.push(elm);
+ i = j;
+ style.clear();
+ }
+ return Builder.node('DIV', {style: 'margin-left: ' + (this.nameWidth + this.valueWidth) + 'px; padding-bottom: ' + this.itemInterval + 'px;'}, array);
+ },
+
+ buildContent: function() {
+ var nodes = new Array();
+
+ var valueStyle = new StyleManager();
+ valueStyle.cache('font', this.fontSize);
+ valueStyle.cache('text-align', 'right');
+
+ for (var i = 0; i < this.params.length; i++) {
+ var child = this.params[i];
+
+ var maxSize;
+ if (child.getValue() > 0) maxSize = this.getPlusChartSize();
+ else maxSize = this.getMinusChartSize();
+
+ var barSize = this.getBarSize(child);
+ barSize = (barSize > maxSize) ? maxSize : barSize;
+
+ var barNode;
+ if (child.options.image) {
+ if (child.getValue() > 0) {
+
+ barNode = Builder.node('DIV',
+ [
+ Builder.node(
+ 'IMG',
+ {
+ src: child.options.image,
+ alt: 'bar',
+ width: barSize + 'px',
+ height: child.options.imageHeight + 'px',
+ style: 'float: left; margin-left: ' + (this.getMinusChartSize() + this.valueWidth) + 'px;'
+ }),
+ Builder.node(
+ 'DIV',
+ {style: 'font: ' + this.fontSize + ';'},
+ [child.getValue()])
+ ]);
+ } else {
+ // IE fix
+ var leftMargin = this.getMinusChartSize() - barSize;
+ var width;
+ if (document.all && leftMargin > 125) {
+ width = leftMargin + this.valueWidth;
+ leftMargin = 0;
+ } else {
+ width = this.valueWidth;
+ }
+
+ valueStyle.add('margin-left', leftMargin + 'px');
+ valueStyle.add('width', width + 'px');
+ valueStyle.add('float', 'left');
+
+ barNode = Builder.node(
+ 'DIV',
+ [
+ Builder.node('DIV', {style: valueStyle.output()}, [child.getValue()]),
+ Builder.node('IMG', {src: child.options.image, alt: 'bar', width: barSize + 'px', height: child.options.imageHeight + 'px'})
+ ]);
+ }
+
+ } else {
+ if (child.getValue() > 0) {
+ barNode = Builder.node(
+ 'DIV',
+ {style: 'font: ' + this.fontSize + '; margin-left: ' + (this.getMinusChartSize() + this.nameWidth + this.valueWidth + this.adjustWidth) + 'px; border-left: ' + barSize + 'px solid ' + child.options.color + ';'},
+ [child.getValue()]
+ );
+ } else {
+ var width = (document.all) ? (this.valueWidth + barSize) : this.valueWidth;
+
+ valueStyle.add('margin-left', (this.nameWidth + this.getMinusChartSize() - barSize) + 'px');
+ valueStyle.add('width', width + 'px');
+ valueStyle.add('border-right', barSize + 'px solid ' + child.options.color);
+
+ barNode = Builder.node(
+ 'DIV',
+ [
+ Builder.node('DIV', {style: valueStyle.output()}, [child.getValue()])
+ ]
+ );
+ }
+ }
+
+ var elm = Builder.node(
+ 'DIV',
+ {style: 'margin-bottom: 10px;'},
+ [
+ Builder.node('DIV', {style: 'text-align: right; font: ' + this.fontSize + ';float: left; width: ' + this.nameWidth + 'px;'}, [child.getName()]),
+ barNode
+ ]);
+
+ nodes.push(elm);
+ valueStyle.clear();
+ }
+
+ return nodes;
+ }
+});
+
+var VerticalBarChart = Class.create();
+Object.extend(Object.extend(VerticalBarChart.prototype, AbstractBarChart.prototype), {
+
+ init: function() {
+ },
+
+ buildGraduationLine: function() {
+ if (!this.options.graduation) return Builder.node('DIV');
+
+ var numberArray = new Array();
+ var lineArray = new Array();
+ var i = this.options.graduationMax;
+ var next;
+ var lineHeight = (document.all) ? this.options.graduationRange : this.options.graduationRange - 2;
+ var marginTop = lineHeight - this.getFontSize();
+
+ var numberStyle = new StyleManager();
+ numberStyle.cache('font', this.fontSize);
+
+ var lineStyle = new StyleManager();
+ lineStyle.cache('font', this.fontSize);
+
+ while (i >= this.options.graduationMin) {
+ next = i - this.options.graduationInterval;
+ lineHeight = (document.all) ? lineHeight - 0.3: lineHeight - 0.1;
+
+ if (i == this.options.graduationMax) {
+ lineStyle.add('margin-top', '0px');
+
+ } else if (next < this.options.graduationMin) {
+ numberStyle.add('margin-top', marginTop + 'px');
+ lineStyle.add('border-left', this.graduationLine);
+ lineStyle.add('border-top', this.graduationLine);
+ lineStyle.add('border-bottom', this.graduationLine)
+ lineStyle.add('height', lineHeight + 'px');
+ lineStyle.add('width', '100%');
+
+ } else {
+ numberStyle.add('margin-top', marginTop + 'px');
+ lineStyle.add('border-left', this.graduationLine);
+ lineStyle.add('border-top', this.graduationLine);
+ lineStyle.add('height', lineHeight + 'px');
+ lineStyle.add('width', '100%');
+ }
+
+ numberArray.push(Builder.node('DIV', {style: numberStyle.output()}, [i]));
+
+ if (i == this.options.graduationMax) {
+ lineArray.push(Builder.node('DIV', {style: lineStyle.output()}, [Builder.node('BR')]));
+ } else {
+ lineArray.push(Builder.node('DIV', {style: lineStyle.output()}));
+ }
+
+ numberStyle.clear();
+ lineStyle.clear();
+
+ marginTop -= (document.all) ? 0.05 : 0.1;
+ i = next;
+ }
+
+ return [
+ Builder.node('DIV', {style: 'float: left; margin-left: 10px; width: 25px; text-align: right;'}, numberArray),
+ Builder.node('DIV', {style: 'float: left; margin-right: 10px; margin-left: 10px; width: 5px;'}, lineArray)
+ ];
+ },
+
+ buildContent: function() {
+ var nodes = new Array();
+
+ for (var i = 0; i < this.params.length; i++) {
+ var child = this.params[i];
+
+ var maxSize;
+ if (child.getValue() > 0) maxSize = this.getPlusChartSize();
+ else maxSize = this.getMinusChartSize();
+
+ var barSize = this.getBarSize(child);
+ barSize = (barSize > maxSize) ? maxSize : barSize;
+
+ var bar;
+ if (child.options.image) {
+ bar = Builder.node('IMG', {src: child.getImage(), alt: 'bar', width: '10px', height: barSize + 'px'});
+ } else {
+ bar = Builder.node('DIV', {style: 'border-top: ' + barSize + 'px solid ' + child.options.color + '; width: 10px; font-size: 0;'});
+ }
+
+ var elm;
+ if (child.getValue() > 0) {
+ elm = Builder.node(
+ 'DIV',
+ {style: 'float: left; margin-right: 10px; width: 25px;'},
+ [
+ Builder.node('DIV', {style: 'margin-top: ' + (maxSize - barSize) + 'px; font: ' + this.fontSize + ';'}, [child.getValue()]),
+ bar,
+ Builder.node('DIV', {style: 'margin-top: ' + (this.getMinusChartSize() + 15) + 'px; font: ' + this.fontSize + '; padding-top: 5px; width: 10px;'}, [child.getName()])
+ ]);
+ } else {
+ elm = Builder.node(
+ 'DIV',
+ {style: 'float: left; margin-right: 10px; width: 25px;'},
+ [
+ Builder.node('DIV', {style: 'margin-top: ' + (this.getPlusChartSize() + this.getFontSize()) + 'px'}),
+ bar,
+ Builder.node('DIV', {style: 'font: ' + this.fontSize + ';'}, [child.getValue()]),
+ Builder.node('DIV', {style: 'margin-top: ' + (maxSize + 15 - (this.getFontSize() + barSize)) + 'px; font: ' + this.fontSize + '; padding-top: 5px; width: 10px;'}, [child.getName()])
+ ]);
+ }
+
+ nodes.push(elm);
+ }
+
+ nodes.push(Builder.node('DIV', {style: 'clear: left;'}));
+ return nodes;
+ }
+});
+
+var ChartParameter = Class.create();
+ChartParameter.prototype = {
+
+ initialize: function(name, value) {
+ if (isNaN(value)) throw '[ChartParameter] value property must be number!(' + value + ')';
+
+ this.name = name;
+ this.value = value;
+
+ this.options = Object.extend({
+ color: '#FF0000',
+ barHeight: '15',
+ image: false,
+ imageHeight: '15',
+ action: false
+ }, arguments[2] || {});
+ },
+
+ getName: function() {
+ return this.name;
+ },
+
+ getValue: function() {
+ return this.value;
+ },
+
+ setValue: function(value) {
+ if (!value || isNaN(value)) this.value = 0;
+ else this.value = value;
+ },
+
+ getImage: function() {
+ return this.options.image;
+ }
+}
+
+var StyleManager = Class.create();
+StyleManager.prototype = {
+
+ initialize: function() {
+ this.cacheItems = new Array();
+ this.items = new Array();
+ },
+
+ cache: function(style) {
+ if (typeof(style) == 'object')
+ this.cacheItems.push(style);
+ else if (arguments[1])
+ this.cacheItems.push(new StyleItem(style, arguments[1]));
+ },
+
+ add: function(style) {
+ if (typeof(style) == 'object')
+ this.items.push(style);
+ else if (arguments[1])
+ this.items.push(new StyleItem(style, arguments[1]));
+ },
+
+ get: function(name) {
+ return this.items.detect(function(child) {
+ return child.getName() == name;
+ });
+ },
+
+ remove: function(name) {
+ this.items = this.items.findAll(function(child) {
+ return child.getName() != name;
+ });
+ },
+
+ clear: function(name) {
+ this.items = new Array();
+ },
+
+ modify: function(name, value) {
+ var item = this.get(name);
+
+ if (item) item.setValue(value);
+ else this.add(name, value);
+ },
+
+ output: function() {
+ var style = '';
+
+ this.cacheItems.each(function(child) {
+ style += child.toString();
+ });
+
+ this.items.each(function(child) {
+ style += child.toString();
+ });
+
+ return style;
+ }
+}
+
+var StyleItem = Class.create();
+StyleItem.prototype = {
+
+ initialize: function(name, value) {
+ this.name = name;
+ this.value = value;
+ },
+
+ setName: function(name) {
+ this.name = name;
+ },
+
+ setValue: function(value) {
+ this.value = value;
+ },
+
+ getName: function() {
+ return this.name;
+ },
+
+ getValue: function() {
+ return this.value;
+ },
+
+ toString: function() {
+ return this.getName() + ':' + this.getValue() + '; ';
+ }
+}
+
--- /dev/null
+// Copyright (c) 2006 spinelz.org (http://script.spinelz.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var Calendar = Class.create();
+Calendar.className = {
+ container: 'calendar',
+ header: 'calendar_header',
+ preYears: 'calendar_preYears',
+ nextYears: 'calendar_nextYears',
+ years: 'calendar_years',
+ mark: 'calendar_mark',
+ ym: 'calendar_ym',
+ table: 'calendar_table',
+ thRight: 'right',
+ tdRight: 'right',
+ tdBottom: 'bottom',
+ date: 'calendar_date',
+ holiday: 'calendar_holiday',
+ regularHoliday: 'calendar_regularHoliday',
+ schedule: 'calendar_schedule',
+ highlightDay: 'calendar_highlightDay',
+ scheduleListContainer: 'calendar_scheduleListContainer',
+ scheduleItem: 'calendar_scheduleItem',
+ scheduleTimeArea: 'calendar_scheduleItemTimeArea',
+ scheduleHandler: 'calendar_scheduleHandler',
+ holidayName: 'calendar_holidayName',
+// holidayContainer: 'calendar_holidayContainer',
+ dateContainer: 'calendar_dateContainer',
+ tableHeader: 'calendar_tableHeader',
+ rowContent: 'calendar_rowContent',
+ selected: 'calendar_selected',
+
+ nextYearMark: 'calendar_nextYearMark',
+ nextMonthMark: 'calendar_nextMonthMark',
+ nextWeekMark: 'calendar_nextWeekMark',
+ preYearMark: 'calendar_preYearMark',
+ preMonthMark: 'calendar_preMonthMark',
+ preWeekMark: 'calendar_preWeekMark',
+
+ weekTable: 'calendar_weekContainerTable',
+ weekMainTable: 'calendar_weekMainTable',
+ timeLine: 'calendar_timeline',
+ timeLineTimeTop: 'calendar_timelineTimeTop',
+ timeLineTime: 'calendar_timelineTime',
+ headerColumn: 'calendar_headerColumn',
+ columnTopDate: 'calendar_columnTopDate',
+ columnDate: 'calendar_columnDate',
+ columnDateOdd: 'calendar_columnOddDate',
+ scheduleItemSamll: 'calendar_scheduleItemSmall',
+ scheduleItemLarge: 'calendar_scheduleItemLarge',
+ scheduleItemNoBorder: 'calendar_scheduleItemNoBorder',
+ scheduleItemSelect: 'calendar_scheduleItemSelect',
+ deleteImg: 'calendar_deleteImage',
+ privateImg: 'calendar_privateImage',
+ scheduleContainer: 'calendar_weekScheduleContainer',
+ selector: 'calendar_selector',
+ cover: 'calendar_cover'
+}
+
+Calendar.smallClassName = {
+ container: 'calendar_small',
+ header: 'calendar_header_small',
+ calendar: 'calendar_calendar_small',
+ table: 'calendar_tableSmall'
+}
+
+Calendar.size = {
+ large: 'large',
+ small: 'small'
+}
+
+/**
+ * Calendar Class
+ */
+Calendar.prototype = {
+
+ initialize: function(element) {
+ this.building = true;
+ this.element = $(element);
+ Element.setStyle(this.element, {visibility: 'hidden'});
+ Element.hide(this.element);
+
+ this.options = Object.extend({
+ initDate: new Date(),
+ cssPrefix: 'custom_',
+ holidays: [],
+ schedules: [],
+ size: Calendar.size.large,
+ regularHoliday: [0, 6],
+ displayIndexes: [0, 1, 2, 3, 4, 5, 6],
+ displayTime: [{hour: 0, min: 0}, {hour: 24, min: 0}],
+ weekIndex: 0,
+ dblclickListener: null,
+ afterSelect: Prototype.emptyFunction,
+ beforeRefresh: Prototype.emptyFunction,
+ changeSchedule: Prototype.emptyFunction,
+ changeCalendar: Prototype.emptyFunction,
+ displayType: 'month',
+ highlightDay: true,
+ beforeRemoveSchedule: function() {return true;},
+ dblclickSchedule: null,
+ updateTirm: Prototype.emptyFunction,
+ displayTimeLine: true,
+ clickDateText: null,
+ monthHeaderFormat: null,
+ weekHeaderFormat: null,
+ weekSubHeaderFormat: null,
+ dayHeaderFormat: null,
+ dayOfWeek: DateUtil.dayOfWeek
+ }, arguments[1] || {});
+
+ this.options.holidays = this.toHolidayHash(this.options.holidays);
+// this.options.schedules = this.toScheduleHash(this.options.schedules);
+
+ this.setIndex();
+
+ this.classNames = null;
+ if (this.options.size == Calendar.size.large) {
+ this.classNames = Calendar.className;
+ } else {
+ this.classNames = $H({}).merge(Calendar.className);
+ this.classNames = this.classNames.merge(Calendar.smallClassName);
+ }
+ var customCss = CssUtil.appendPrefix(this.options.cssPrefix, this.classNames);
+ this.classNames = new CssUtil([this.classNames, customCss]);
+
+ this.date = this.options.initDate;
+
+ this.calendar = this.build();
+ this.element.appendChild(this.calendar);
+
+ Event.observe(document, "mouseup", this.onMouseUp.bindAsEventListener(this));
+ Element.setStyle(this.element, {visibility: 'visible'});
+ Element.show(this.element);
+ this.builder.afterBuild();
+ this.windowResize = this.onResize.bind(this);
+ if (this.options.size != 'small') Event.observe(window, "resize", this.windowResize);
+ this.building = false;
+ },
+
+ onResize: function() {
+ try {
+ var oldDimentions = this.builder.containerDimensions;
+ var dimentions = Element.getDimensions(this.builder.container);
+ if (dimentions.height != oldDimentions.height || dimentions.width != oldDimentions.width) {
+ this.refresh();
+ }
+ } catch(e) {}
+ },
+
+ destroy: function() {
+ Event.stopObserving(window, 'resize', this.windowResize);
+ },
+
+ setIndex: function() {
+ var options = this.options;
+ var bottom = [];
+ var up = [];
+ var index = null;
+ options.displayIndexes.sort();
+ options.displayIndexes.each(function(i) {
+ if (index == null) {
+ if (options.weekIndex <= i) {
+ index = i;
+ up.push(i);
+ } else {
+ bottom.push(i);
+ }
+ } else {
+ up.push(i);
+ }
+ });
+ options.displayIndexes = up.concat(bottom);
+ this.setLastWday();
+ },
+
+ setLastWday: function() {
+ var firstIndex = this.options.weekIndex;
+ var sat = 6;
+ var sun = 0;
+ var week = $R(firstIndex, sat, false).toArray();
+ if (firstIndex != sun) {
+ week = week.concat($R(sun, firstIndex - 1, false).toArray());
+ }
+ this.lastWday = week.last();
+ this.wdays = week;
+ },
+
+ build: function() {
+ if (this.builder) {
+ this.builder.destroy();
+ }
+
+ if (this.options.displayType == 'week') {
+ this.builder = new CalendarWeek(this);
+ } else if (this.options.displayType == 'day') {
+ this.builder = new CalendarDay(this);
+ } else {
+ this.builder = new CalendarMonth(this);
+ }
+
+ this.builder.beforeBuild();
+ return this.builder.build();
+ },
+
+ /*** Calendar ***/
+ /********************************** public method **********************************/
+ undo: function() {
+ if (this.cached) {
+ this.cached.start = this.cached.start_old;
+ this.cached.finish = this.cached.finish_old;
+ this.cached = null;
+ this.refreshSchedule();
+ }
+ },
+
+ hideSatSun: function() {
+ var sun = 0;
+ var sat = 6;
+ this.options.displayIndexes = this.options.displayIndexes.without(sun, sat);
+ this.setIndex();
+ this.refresh();
+ },
+
+ showSatSun: function() {
+ var sun = 0;
+ var sat = 6;
+ var indexes = this.options.displayIndexes;
+ if (!indexes.include(sun)) {
+ indexes.push(sun);
+ }
+ if (!indexes.include(sat)) {
+ indexes.push(sat);
+ }
+ this.setIndex();
+ this.refresh();
+ },
+
+ changeDisplayIndexes: function(indexes) {
+ this.options.displayIndexes = indexes;
+ this.setIndex();
+ this.refresh();
+ },
+
+ changeDisplayTime: function(time) {
+ this.options.displayTime = time;
+ this.refresh();
+ },
+
+ refresh: function() {
+ try {
+ if (!this.building) {
+ this.building = true;
+ this.options.beforeRefresh(this);
+ this.destroy();
+ this.selectedBase = null;
+ Element.remove(this.calendar);
+ this.calendar = this.build();
+ this.element.appendChild(this.calendar);
+ this.builder.afterBuild();
+ if (this.options.size != 'small') Event.observe(window, 'resize', this.windowResize);
+ this.building = false;
+ }
+ } catch (e) {}
+ },
+
+ changeCalendar: function(event) {
+ this.builder.changeCalendar(event);
+ },
+
+ changeDisplayType: function(type) {
+ this.options.displayType = type;
+ this.refresh();
+ },
+
+ selectDate: function(event) {
+ var calendar = this;
+ this.abstractSelect(event, function(date, element) {
+ if (calendar.selectedBase || calendar.hasSelectedDate()) {
+ if (event.ctrlKey) {
+ if (Element.hasClassName(element, Calendar.className.selected)) {
+ calendar.addSelectedClass(element);
+ return;
+ }
+ } else if (calendar.selectedBase) {
+ var selectedId = calendar.selectedBase.id;
+ $(selectedId).className = calendar.selectedBase.className;
+ calendar.clearSelected();
+ if (selectedId == element.id) {
+ calendar.selectedBase = null;
+ return;
+ }
+ }
+ }
+
+ calendar.selectedBase = {id: element.id, date: date, className: element.className};
+ calendar.addSelectedClass(element);
+ if (date && calendar.options.displayType == 'month' && calendar.options.size == Calendar.size.small) {
+ calendar.options.afterSelect(date, calendar);
+ }
+ });
+
+ if (calendar.options.displayType != 'month' || calendar.options.size != Calendar.size.small) {
+ this.mouseDown = true;
+ }
+ },
+
+ clearSelect: function() {
+ // BETA
+ this.selectedBase = null;
+ this.clearSelected();
+ },
+
+ showDayOfWeek: function(dayOfWeek) {
+ var indexes = this.options.displayIndexes;
+ this.recurrence(dayOfWeek, function(d) {
+ if (!indexes.include(d)) {
+ indexes.push(d);
+ }
+ });
+ this.setIndex();
+ this.refresh();
+ },
+
+ hideDayOfWeek: function(dayOfWeek) {
+ var indexes = this.options.displayIndexes;
+ var self = this;
+ this.recurrence(dayOfWeek, function(d) {
+ var index = self.findIndex(indexes, d);
+ if (index) {
+ indexes.remove(index);
+ } else if (!index.isNaN) {
+ indexes.shift();
+ }
+ });
+ this.refresh();
+ },
+
+ addHoliday: function(object) {
+ object = this.inspectArgument(object);
+ var newHash = this.toHolidayHash(object);
+ this.options.holidays = this.options.holidays.merge(newHash);
+ this.refresh();
+ },
+
+ removeHoliday: function(date) {
+ var calendar = this;
+ date = calendar.inspectDateArgument(date);
+ if (!date) return;
+
+ this.recurrence(date, function(d) {
+ var key = d.toDateString();
+ if (calendar.options.holidays[key])
+ delete calendar.options.holidays[key];
+ });
+ this.refresh();
+ },
+
+ refreshHoliday: function(object, rebuild) {
+ object = this.inspectArgument(object);
+ this.options.holidays = this.toHolidayHash(object);
+ if (rebuild) this.refresh();
+ },
+
+ clearHoliday: function() {
+ this.refreshHoliday([], true);
+ },
+
+ getHoliday: function(date) {
+ date = this.inspectDateArgument(date);
+ if (!date) return;
+
+ var calendar = this;
+ var holidays = [];
+ this.recurrence(date, function(o) {
+ var h = calendar.options.holidays[o.toDateString()];
+ if (h) holidays.push(h);
+ });
+
+ return holidays;
+ },
+
+ addSchedule: function(schedule) {
+ var schedules = this.options.schedules;
+ if (schedule.constructor == Array) {
+ schedule.each(function(s) {
+ var find = schedules.detect(function(tmp) {return s.id == tmp.id});
+ if (!find) schedules.push(s);
+ });
+ } else {
+ var find = schedules.detect(function(tmp) {return tmp.id == schedule.id});
+ if (!find) schedules.push(schedule);
+ }
+ this.refreshSchedule();
+ },
+
+ replaceSchedule: function(schedules) {
+ this.options.schedules = schedules;
+ this.refreshSchedule();
+ },
+
+ removeSchedule: function(ids, refresh) {
+ if (ids.constructor != Array) ids = [ids];
+ var self = this;
+ ids.each(function(id) {
+ var index = null;
+ self.options.schedules.each(function(s, i) {
+ if (s.id == id) {
+ index = i;
+ throw $break;
+ }
+ });
+
+ if (index != null) {
+ var schedule = self.options.schedules[index];
+ if (schedule) {
+ self.options.schedules.remove(index);
+ }
+ }
+ });
+ if (refresh) this.refreshSchedule();
+ },
+
+ refreshSchedule: function() {
+ this.builder.scheduleNodes.each(function(node) {
+ Element.remove(node);
+ });
+ this.builder.afterBuild();
+ },
+
+ mergeSchedule: function(schedule) {
+ var index = -1;
+ this.options.schedules.each(function(s, i) {
+ if (s.id == schedule.id) {
+ index = i;
+ throw $break;
+ }
+ });
+ if (index != -1) {
+ this.options.schedules[index] = schedule;
+ this.refreshSchedule();
+ } else {
+ this.addSchedule(schedule);
+ }
+ },
+
+ clearSchedule: function() {
+ this.options.schedules = [];
+ this.refreshSchedule();
+ },
+
+ getSchedule: function(object) {
+ var result = [];
+ var calendar = this;
+ object = this.inspectArgument(object || {});
+
+ this.recurrence(object, function(o) {
+ var schedule = calendar.options.schedules[o.date.toDateString()];
+ if (!schedule) return;
+
+ if (o.start) {
+ schedule = schedule.detect(function(s) {
+ return ((s.start.hour == o.start.hour) && (s.start.min == o.start.min));
+ });
+ if (schedule) result.push(schedule);
+ } else if (o.number) {
+ schedule = schedule[o.number];
+ if (schedule) result.push(schedule);
+ } else {
+ result = result.concat(schedule);
+ }
+ });
+
+ return result;
+ },
+
+ getSelected: function() {
+ return this.element.getElementsByClassName(Calendar.className.selected, this.element);
+ },
+
+ changeSchedule: function() {
+ var calendar = this;
+ return function(drag, drop) {
+ var array = drag.id.split('_');
+ var i = array.pop();
+ var date = array.pop();
+
+ date = calendar.getDate(date);
+ var newDate = calendar.getDate(drop);
+
+ var schedule = calendar.getSchedule({date: date, number: i});
+ if (schedule.length != 1) return;
+
+ schedule = schedule.pop();
+ schedule.date = newDate;
+ calendar.removeSchedule({date: date, number: i}, false);
+ calendar.addSchedule(schedule);
+
+ calendar.options.changeSchedule(schedule);
+ }
+ },
+
+ getSelectedDates: function() {
+ return this.builder.getSelectedDates();
+ },
+
+ getSelectedTerm: function() {
+ return this.builder.getSelectedTerm();
+ },
+
+ /********************************** private method **********************************/
+ abstractSelect: function(event, method) {
+ this.builder.abstractSelect(event, method);
+ },
+
+ createRange: function(a, b) {
+ var range = null;
+ if (a <= b)
+ range = $R(a, b);
+ else
+ range = $R(b, a);
+ return range;
+ },
+
+ formatTime: function(time) {
+ var hour = (time.hour < 10) ? '0' + time.hour : time.hour;
+ var min = (time.min < 10) ? '0' + time.min : time.min;
+ return hour + ':' + min;
+ },
+
+ clearSelected: function() {
+ var elements = this.getSelected();
+ var self = this;
+ elements.each(function(e) {
+ if (Element.hasClassName(e, Calendar.className.selected))
+ self.removeSelectedClass(e);
+ });
+ },
+
+ onDblClick: function(event) {
+ this.abstractSelect(event, this.options.dblclickListener);
+ },
+
+ onMouseUp: function(event) {
+ var e = event || window.event;
+ var calendar = this;
+ if (calendar.mouseDown) {
+ setTimeout(function() {
+ calendar.mouseDown = false;
+ calendar.options.afterSelect(event);
+ }, 10);
+ }
+ },
+
+ setRegularHolidayClass: function(node) {
+ this.classNames.refreshClassNames(node, 'regularHoliday');
+ },
+
+ setHolidayClass: function(node) {
+ this.classNames.refreshClassNames(node, 'holiday');
+ },
+
+ setWorkdayClass: function(node) {
+ this.classNames.refreshClassNames(node, 'date');
+ },
+
+ setScheduleClass: function(node) {
+ this.classNames.refreshClassNames(node, 'schedule');
+ },
+
+ addHighlightClass: function(node) {
+ Element.addClassName(node, Calendar.className.highlightDay);
+ },
+
+ addSelectedClass: function(node) {
+ Element.addClassName(node, Calendar.className.selected);
+ },
+
+ removeSelectedClass: function(node) {
+ Element.removeClassName(node, Calendar.className.selected);
+ },
+
+ getDatasWithMonthAndYear: function(array) {
+ var calendar = this;
+ var result = array.findAll(function(h) {
+ return calendar.isSameYearAndMonth(h.date);
+ });
+
+ return result;
+ },
+
+ isSameYearAndMonth: function(a, b) {
+ if (a.constructor == Date) {
+ if (!b) b = this.date;
+ return ((a.getYear() == b.getYear()) && (a.getMonth() == b.getMonth()));
+ } else {
+ return (a.year == b.year && a.month == b.month && a.day == a.day);
+ }
+ },
+
+ isSameDate: function(a, b) {
+ if (a.constructor == Date) {
+ if (!b) b = this.date;
+ return (this.isSameYearAndMonth(a, b) && (a.getDate() == b.getDate()));
+ } else {
+ return (this.isSameYearAndMonth(a, b) && a.day == b.day);
+ }
+ },
+
+ isSameTime: function(a, b) {
+ return ((a.hour == b.hour) && (a.min == b.min));
+ },
+
+ betweenDate: function(schedule, date) {
+ var start = this.toDateNumber(schedule.start);
+ var finish = this.toDateNumber(schedule.finish);
+ date = this.toDateNumber(date);
+ return start <= date && date <= finish;
+ },
+
+ toDateNumber: function(date) {
+ if (date.constructor == Date) {
+ return date.getFullYear() * 10000 + date.getMonth() * 100 + date.getDate();
+ } else {
+ return date.year * 10000 + date.month * 100 + date.day;
+ }
+ },
+
+ getTimeDiff: function(a, b) {
+ var time = {hour: b.hour - a.hour, min: b.min - a.min};
+ if (time.min >= 60) {
+ time.hour++;
+ time.min -= 60;
+ } else if (time.min < 0) {
+ time.hour--;
+ time.min += 60;
+ }
+ return time;
+ },
+
+ findIndex: function(array, value) {
+ var index = null;
+ array.each(function(v, i) {
+ if (v == value) {
+ index = i;
+ throw $break;
+ }
+ });
+ return index;
+ },
+
+ recurrence: function(object, method) {
+ var calendar = this;
+ if (object.constructor == Array) {
+ object.each(function(o) {calendar.recurrence(o, method)});
+ } else if (object.keys) {
+ object.each(function(pair) {calendar.recurrence(pair[1], method)});
+ } else {
+ method(object);
+ }
+ },
+
+ toHolidayHash: function(object) {
+ var calendar = this;
+ var hash = {};
+
+ this.recurrence(object, function(o) {
+ if (!o.name) return;
+ if (o.date.constructor == Object)
+ o.date = new Date(o.date.year, o.date.month, o.date.day);
+
+ hash[o.date.toDateString()] = o;
+ });
+ return $H(hash);
+ },
+
+// toScheduleHash: function(object) {
+// var calendar = this;
+// var hash = {};
+//
+// this.recurrence(object, function(o) {
+// if (!o.description) return;
+// if (o.date.constructor == Object)
+// o.date = new Date(o.date.year, o.date.month, o.date.day);
+//
+// var date = o.date.toDateString();
+// o.date = date;
+//
+// if (hash[date]) {
+// hash[date].push(o);
+// hash[date].sort(calendar.sortSchedule);
+// } else {
+// hash[date] = [o];
+// }
+// });
+// return $H(hash);
+// },
+
+ inspectArgument: function(object, time) {
+ return this.builder.inspectArgument(object, time);
+ },
+
+ inspectDateArgument: function(date) {
+ return this.builder.inspectDateArgument(date);
+ },
+
+ sortSchedule: function(a, b) {
+ if (a.start.hour == b.start.hour) {
+ if (a.start.min == b.start.min)
+ return 0;
+ if (a.start.min < b.start.min)
+ return -1;
+ return 1;
+ }
+ if (a.start.hour < b.start.hour) return -1;
+
+ return 1;
+ },
+
+ hasSelectedDate: function() {
+ return (this.getSelected().length != 0);
+ },
+
+ getDate: function(element) {
+ return this.builder.getDate(element);
+ },
+
+ isRegularHoliday: function(day) {
+ return this.options.regularHoliday.include(day);
+ },
+
+ isHoliday: function(date) {
+ return this.options.holidays[date.toDateString()];
+ },
+
+ isScheduleDay: function(date) {
+ return this.options.schedules[date.toDateString()];
+ },
+
+ cacheSchedule: function(schedule) {
+ this.cached = schedule;
+ schedule.start_old = Object.clone(schedule.start);
+ schedule.finish_old = Object.clone(schedule.finish);
+ }
+}
+
+
+/**
+ * AbstractCalendar Class
+ */
+var AbstractCalendar = Class.create();
+AbstractCalendar.id = {
+ container: 'container',
+ scheduleContainer: 'scheduleContainer',
+ selector: 'selector'
+}
+AbstractCalendar.prototype = {
+ destroy: Prototype.emptyFunction,
+ beforeBuild: Prototype.emptyFunction,
+
+ build: function() {
+ this.header = this.buildHeader();
+ var node = Builder.node(
+ 'DIV',
+ {
+ id: this.getContainerId(),
+ className: this.calendar.classNames.joinClassNames('container')
+ },
+ [this.header, this.buildCalendar()]);
+
+ return node;
+ },
+
+ buildHeader: function() {
+ var headerNodes = Builder.node('TR');
+ headerNodes.appendChild(this.buildHeaderLeft());
+ headerNodes.appendChild(this.buildHeaderCenter());
+ headerNodes.appendChild(this.buildHeaderRight());
+
+ className = this.calendar.classNames.joinClassNames('header');
+ var tbody = Builder.node('TBODY', [headerNodes]);
+ return Builder.node('TABLE', {className: className}, [tbody]);
+ },
+
+ buildSelector: function() {
+ // create selector
+ var selector = Builder.node('DIV', {id: this.getSelectorId()});
+ this.calendar.classNames.addClassNames(selector, 'selector');
+ Element.setOpacity(selector, 0.6);
+ Element.hide(selector);
+ Element.setStyle(selector, {zIndex: ZindexManager.getIndex()})
+ return selector;
+ },
+
+ buildCover: function() {
+ this.cover = Builder.node('div', {id: this.calendar.element.id.appendSuffix('cover')});
+ this.calendar.classNames.addClassNames(this.cover, 'cover');
+ Event.observe(this.cover, 'mousedown', this.calendar.selectDate.bindAsEventListener(this.calendar));
+ if (this.calendar.options.displayType != 'month' || this.calendar.options.size != 'samll') {
+ Event.observe(this.cover, 'mousemove', this.multipleSelection.bindAsEventListener(this));
+ }
+ return this.cover;
+ },
+
+ buildScheduleContainer: function() {
+ this.container = Builder.node('DIV', {style: 'position: relative', id: this.getScheduleContainerId()});
+ return this.container;
+ },
+
+ // the default is empty.
+ // overwride this method.
+ setScheduleContainerEvent: Prototype.emptyFunction,
+
+ changeCalendar: function(event) {
+ var element = Event.element(event);
+ var date = this.calendar.date;
+ var oldDate = new Date(date.toDateString());
+
+ if (Element.hasClassName(element, Calendar.className.preYearMark)) {
+ date.setFullYear(date.getFullYear() - 1);
+ } else if (Element.hasClassName(element, Calendar.className.preMonthMark)) {
+ date.setDate(1);
+ date.setMonth(date.getMonth() - 1);
+ } else if (Element.hasClassName(element, Calendar.className.preWeekMark)) {
+ date.setDate(date.getDate() - 7);
+ } else if (Element.hasClassName(element, Calendar.className.nextYearMark)) {
+ date.setFullYear(date.getFullYear() + 1);
+ } else if (Element.hasClassName(element, Calendar.className.nextMonthMark)) {
+ date.setDate(1);
+ date.setMonth(date.getMonth() + 1);
+ } else if (Element.hasClassName(element, Calendar.className.nextWeekMark)) {
+ date.setDate(date.getDate() + 7);
+ }
+
+ this.calendar.options.changeCalendar(date, oldDate);
+ this.calendar.refresh();
+ },
+
+ clickDeleteImage: function(schedule) {
+ if (this.calendar.options.beforeRemoveSchedule(schedule)) {
+ this.calendar.removeSchedule(schedule.id, true);
+ }
+ },
+
+ showDeleteImage: function(img) {
+ Element.show(img);
+ },
+
+ hideDeleteImage: function(img) {
+ Element.hide(img);
+ },
+
+ _constrain: function(n, lower, upper) {
+ if (n > upper) return upper;
+ else if (n < lower) return lower;
+ else return n;
+ },
+
+ getContainerId: function() {
+ return this.calendar.element.id.appendSuffix(AbstractCalendar.id.container);
+ },
+
+ getScheduleContainerId: function() {
+ return this.calendar.element.id.appendSuffix(AbstractCalendar.id.scheduleContainer);
+ },
+
+ setColumnWidth: function() {
+ var adjustSize = this.getAdjustSize();
+ var container = $(this.getScheduleContainerId()) || this.container;
+ var indexes = this.calendar.options.displayIndexes;
+ this.column.width = container.offsetWidth / indexes.length - adjustSize;
+ if (this.column.width < 0) this.column.width = 0;
+ },
+
+ setCover: function() {
+ var container = $(this.getScheduleContainerId()) || this.container;
+ if (!this.cover) {
+ container.appendChild(this.buildCover());
+ }
+ Element.setStyle(this.cover, {height: Element.getHeight(container) + 'px'});
+ },
+
+ getDragDistance: function() {
+ var adjustSize = this.getAdjustSize();
+// return [this.column.width + adjustSize, this.column.height];
+ return [this.column.width + adjustSize, this.column.height / 2];
+ },
+
+ getWeek: function() {
+ var date = this.calendar.date;
+ var baseDay = date.getDay();
+ var baseDayIndex = date.getDay();
+ var findBaseDay = false;
+
+ return this.calendar.options.displayIndexes.map(function(week, i) {
+ var diff = week - baseDay;
+ if (!findBaseDay && (diff > 0)) diff -= 7;
+ if (baseDayIndex == week) findBaseDay = true;
+ return DateUtil.afterDays(date, diff);
+ });
+ },
+
+ isSameStartDate: function(schedule, date) {
+ return ((date.getFullYear() == schedule.start.year) &&
+ (date.getMonth() == schedule.start.month) && (date.getDate() == schedule.start.day));
+ },
+
+ isSameFinishDate: function(schedule, date) {
+ return ((date.getFullYear() == schedule.finish.year) &&
+ (date.getMonth() == schedule.finish.month) && (date.getDate() == schedule.finish.day));
+ },
+
+ getSelectorId: function() {
+ return this.calendar.element.id.appendSuffix(AbstractCalendar.id.selector);
+ },
+
+ clickDateText: function(event, date) {
+ Event.stop(event);
+ this.calendar.date = date;
+ this.calendar.options.displayType = 'day';
+ this.calendar.refresh();
+ },
+
+ getAdjustSize: function() {
+ return UserAgent.isIE() ? 3 : 3;
+ },
+
+ setContainerInfo: function() {
+ this.container = $(this.getScheduleContainerId());
+ this.containerDimensions = Element.getDimensions(this.container);
+ this.containerOffset = Position.cumulativeOffset(this.container);
+ },
+
+ mouseOverSubSchedule: function(items) {
+ items.each(function(item) {
+ Element.addClassName(item, Calendar.className.scheduleItemSelect);
+ });
+ },
+
+ mouseOutSubSchedule: function(items) {
+ items.each(function(item) {
+ Element.removeClassName(item, Calendar.className.scheduleItemSelect);
+ });
+ },
+
+ toDate: function(hash) {
+ return DateUtil.toDate(hash);
+ }
+}
+
+
+/**
+ * CalenderMonth Class
+ */
+var CalendarMonth = Class.create();
+CalendarMonth.id = {
+ year: 'year',
+ month: 'month',
+ column: 'column',
+ nextYear: 'nextYear',
+ nextMonth: 'nextMonth',
+ preYear: 'preYear',
+ preMonth: 'preMonth',
+ calTable: 'calTable',
+ scheduleContainer: 'scheduleContainer',
+ container: 'container'
+}
+Object.extend(CalendarMonth.prototype, AbstractCalendar.prototype);
+Object.extend(CalendarMonth.prototype, {
+
+ initialize: function(calendar) {
+ this.calendar = calendar;
+ this.week = this.getWeek();
+ },
+
+ /*** Month ***/
+ /********************************** build functions **********************************/
+ buildHeaderLeft: function() {
+ var container = Builder.node('TD');
+ this.calendar.classNames.addClassNames(container, 'preYears');
+
+ var id = this.calendar.element.id.appendSuffix(CalendarMonth.id.preYear);
+ var node = Builder.node('DIV', {id: id});
+ this.calendar.classNames.addClassNames(node, 'preYearMark');
+ Event.observe(node, "click", this.calendar.changeCalendar.bindAsEventListener(this.calendar));
+ container.appendChild(node);
+
+ id = this.calendar.element.id.appendSuffix(CalendarMonth.id.preMonth);
+ node = Builder.node('DIV', {id: id});
+ this.calendar.classNames.addClassNames(node, 'preMonthMark');
+ Event.observe(node, "click", this.calendar.changeCalendar.bindAsEventListener(this.calendar));
+ container.appendChild(node);
+
+ return container;
+ },
+
+ buildHeaderCenter: function() {
+ var text = [];
+ if (this.calendar.options.monthHeaderFormat) {
+ var date = this.calendar.date;
+ var templ = new Template(this.calendar.options.monthHeaderFormat);
+ text = [templ.evaluate({year: date.getFullYear(), month: date.getMonth() + 1}), ' '];
+ }
+ var contents = [];
+
+ var id = this.calendar.element.id.appendSuffix(CalendarMonth.id.month);
+ var node = Builder.node('SPAN', {id: id}, [text[0] || DateUtil.months[this.calendar.date.getMonth()]]);
+ this.calendar.classNames.addClassNames(node, 'ym');
+ contents.push(node);
+
+ id = this.calendar.element.id.appendSuffix(CalendarMonth.id.year);
+ node = Builder.node('SPAN', {id: id}, [text[1] || this.calendar.date.getFullYear()]);
+ this.calendar.classNames.addClassNames(node, 'ym');
+ contents.push(node);
+
+ var container = Builder.node('TD', contents);
+ this.calendar.classNames.addClassNames(container, 'years');
+
+ return container;
+ },
+
+ buildHeaderRight: function() {
+ var container = Builder.node('TD');
+ this.calendar.classNames.addClassNames(container, 'nextYears');
+
+ var id = this.calendar.element.id.appendSuffix(CalendarMonth.id.nextMonth);
+ var node = Builder.node('DIV', {id: id});
+ this.calendar.classNames.addClassNames(node, 'nextMonthMark');
+ Event.observe(node, "click", this.calendar.changeCalendar.bindAsEventListener(this.calendar));
+ container.appendChild(node);
+
+ id = this.calendar.element.id.appendSuffix(CalendarMonth.id.nextYear);
+ node = Builder.node('DIV', {id: id});
+ this.calendar.classNames.addClassNames(node, 'nextYearMark');
+ Event.observe(node, "click", this.calendar.changeCalendar.bindAsEventListener(this.calendar));
+ container.appendChild(node);
+
+ return container;
+ },
+
+ buildCalendar: function() {
+ var container = Builder.node('DIV');
+ var scheduleContainer = Builder.node('DIV',
+ {id: this.getScheduleContainerId(), style: 'position: relative'},
+ [this.buildTableData()]);
+ this.setScheduleContainerEvent(scheduleContainer);
+
+ // create selector
+ var selector = this.buildSelector();
+ scheduleContainer.appendChild(selector);
+ return Builder.node('DIV', [this.buildTableHeader(), scheduleContainer]);
+ },
+
+ buildTableHeader: function() {
+ var weekArray = new Array();
+ var self = this;
+ var tbody = Builder.node('TBODY');
+ var tr = Builder.node('TR', weekArray);
+ var width = 100 / this.calendar.options.displayIndexes.length + '%';
+ var lastIndex = this.calendar.options.displayIndexes.last();
+
+ tbody.appendChild(tr);
+
+ this.calendar.options.displayIndexes.each(function(i) {
+ var id = self.calendar.element.id.appendSuffix(CalendarMonth.id.column);
+ var text = self.calendar.options.dayOfWeek[i];
+ var node = Builder.node('TH', {id: id.appendSuffix(i)}, [text]);
+ node.width = width;
+ weekArray.push(node);
+ if (lastIndex == i) {
+ self.calendar.classNames.addClassNames(node, 'thRight');
+ }
+ Event.observe(node, 'click', self.selectDay.bindAsEventListener(self));
+ tr.appendChild(node);
+ });
+
+ return Builder.node('TABLE',
+ {className: this.calendar.classNames.joinClassNames('table')}, [tbody]);
+ },
+
+ buildTableData: function() {
+ var indexes = this.calendar.options.displayIndexes;
+ var today = new Date();
+ var year = this.calendar.date.getFullYear();
+ var month = this.calendar.date.getMonth();
+ var firstDay = DateUtil.getFirstDate(year, month).getDay();
+ var lastDate = DateUtil.getLastDate(year, month).getDate();
+ var trs = new Array();
+ var tds = new Array();
+ var width = 100 / indexes.length + '%';
+ var lastIndex = indexes.last();
+ var node, hday, sday, tmp_date, isOutside, i = null;
+
+ // set start index
+ var weekIndex = this.calendar.options.weekIndex;
+ var length = DateUtil.dayOfWeek.length * 5;
+ var i = null;
+ var day = 1;
+ if (weekIndex <= firstDay) {
+ i = weekIndex;
+ length += i;
+ } else {
+ i = weekIndex - 7;
+ length -= i;
+ }
+
+ var diff = firstDay - weekIndex;
+ if (diff < 0) diff + indexes.length;
+ if ((lastDate + diff) > length) {
+ length += indexes.length;
+ }
+
+ var wday = weekIndex;
+
+ var find = 0;
+ for (; i < length; i++) {
+ if (indexes.include(wday)) {
+ if (i < firstDay) {
+ tmp_date = new Date(
+ this.calendar.date.getFullYear(),
+ this.calendar.date.getMonth(),
+ i - firstDay + 1
+ );
+ node = Builder.node('TD');
+ node.innerHTML = ' ';
+ node.date = tmp_date;
+ node.width = width;
+ tds.push(node);
+ } else if (day > lastDate) {
+ tmp_date = new Date(
+ this.calendar.date.getFullYear(),
+ this.calendar.date.getMonth(),
+ day
+ );
+ node = Builder.node('TD');
+ node.innerHTML = ' ';
+ node.date = tmp_date;
+ tds.push(node);
+ } else {
+ if (i == firstDay) length += find;
+ tmp_date = new Date(
+ this.calendar.date.getFullYear(),
+ this.calendar.date.getMonth(),
+ day
+ );
+ hday = this.calendar.options.holidays[tmp_date.toDateString()];
+
+ if (this.calendar.options.size == Calendar.size.large) {
+ node = this.buildLargeRow(tmp_date, hday, sday, today);
+ if (this.calendar.options.dblclickListener) {
+ Event.observe(node, 'dblclick', this.calendar.onDblClick.bindAsEventListener(this.calendar));
+ }
+ } else {
+ sday = this.calendar.options.schedules.detect(function(schedule) {
+ var startDate = DateUtil.toDate(schedule.start);
+ return tmp_date.sameDate(startDate)
+ });
+ node = this.buildSmallRow(tmp_date, hday, sday, today);
+ Event.observe(node, 'mousedown', this.calendar.selectDate.bindAsEventListener(this.calendar));
+ }
+
+ node.width = width;
+ node.date = tmp_date;
+
+ tds.push(node);
+ }
+ find++;
+ }
+
+ if (i >= firstDay) {
+ day++;
+ }
+
+ if (wday == lastIndex) {
+ trs.push(Builder.node('TR', tds));
+ this.calendar.classNames.addClassNames(tds[tds.length - 1], 'tdRight');
+ tds = new Array();
+ }
+
+ if (wday >= 6) {
+ wday = 0;
+ } else {
+ wday++;
+ }
+ }
+
+ this.rowMax = trs.length - 1;
+ var tbody = Builder.node('TBODY', [trs]);
+ this.calendarTable = Builder.node(
+ 'TABLE',
+ {
+ id: this.getCalendarTableId(),
+ className: this.calendar.classNames.joinClassNames('table')
+ },
+ [tbody]);
+ return this.calendarTable;
+ },
+
+ buildLargeRow: function(date, holiday, schedule, today) {
+ var calendar = this;
+ var row = Builder.node('TD', {id: this.getDateId(date)});
+ var dateContainer = Builder.node('DIV');
+
+ this.calendar.classNames.addClassNames(dateContainer, 'dateContainer');
+ row.appendChild(dateContainer);
+
+ var dateNode = null;
+ var clickDateText = this.calendar.options.clickDateText;
+ if (clickDateText) {
+ dateNode = Builder.node('A', {href: '#'}, [date.getDate()]);
+ Event.observe(dateContainer, 'mousedown', clickDateText.bindAsEventListener(this, date));
+ } else if (clickDateText == null) {
+ dateNode = Builder.node('A', {href: '#'}, [date.getDate()]);
+ Event.observe(dateContainer, 'mousedown', this.clickDateText.bindAsEventListener(this, date));
+ } else {
+ dateNode = Builder.node('SPAN', [date.getDate()]);
+ Element.setStyle(dateNode, {textDecoration: 'none'});
+ }
+ if (date.days() == today.days()) {
+ this.calendar.addHighlightClass(dateNode);
+ }
+ dateContainer.appendChild(dateNode);
+
+ if (holiday) {
+ this.calendar.setHolidayClass(row);
+ var name = Builder.node(
+ 'SPAN',
+ {className: this.calendar.classNames.joinClassNames('holidayName')},
+ holiday.name
+ );
+ dateContainer.appendChild(name);
+ if (holiday.onclick) {
+ Event.observe(name, "click", holiday.onclick.bindAsEventListener(this));
+ }
+ } else if (this.calendar.isRegularHoliday(date.getDay())) {
+ this.calendar.setRegularHolidayClass(row);
+ } else {
+ this.calendar.setWorkdayClass(row);
+ }
+
+ return row;
+ },
+
+ buildSmallRow: function(date, holiday, schedule, today) {
+ var row = Builder.node('TD', {id: this.getDateId(date)}, [date.getDate()]);
+ if (schedule) {
+ this.calendar.setScheduleClass(row);
+ var first = schedule[0];
+ if (first) row.title = first.description.stripTags();
+ } else if (holiday) {
+ this.calendar.setHolidayClass(row);
+ row.title = holiday.name.stripTags();
+ } else if (this.calendar.isRegularHoliday(date.getDay())) {
+ this.calendar.setRegularHolidayClass(row);
+ } else {
+ this.calendar.setWorkdayClass(row);
+ }
+
+ if (date.days() == today.days()) {
+ this.calendar.addHighlightClass(row);
+ }
+ return row;
+ },
+
+ beforeBuild: function() {
+ this.column = {};
+ var rule = CssUtil.getCssRuleBySelectorText('.' + Calendar.className.table + ' td');
+ this.column.height = parseInt(rule.style['height'], 10);
+
+ rule = CssUtil.getCssRuleBySelectorText('.' + Calendar.className.dateContainer);
+ this.column.dateTextHeight = parseInt(rule.style['height'], 10);
+ },
+
+ /**********************************
+ ***** for make schedule item *****
+ **********************************/
+ buildSchedule: function(schedule) {
+ var id = 'scheduleItem_' + schedule.id;
+ var canEdit = (schedule.edit == undefined || schedule.edit);
+ var item = Builder.node('DIV', {id: id});
+ var start = DateUtil.toDate(schedule.start);
+ var finish = DateUtil.toDate(schedule.finish);
+ if (start.sameDate(finish)) {
+ this.calendar.classNames.addClassNames(item, 'scheduleItemNoBorder');
+ } else {
+ this.calendar.classNames.addClassNames(item, 'scheduleItemLarge');
+ }
+
+ if (canEdit) {
+ var deleteImg = Builder.node('DIV',
+ {
+ id: 'scheduleDeleteImg_' + schedule.id,
+ className: this.calendar.classNames.joinClassNames('deleteImg')
+ }
+ );
+ Element.hide(deleteImg);
+ item.appendChild(deleteImg);
+
+ // set click event on a image.
+ Event.observe(deleteImg, 'click', this.clickDeleteImage.bind(this, schedule));
+ Event.observe(item, 'mouseover', this.showDeleteImage.bind(this, deleteImg));
+ Event.observe(item, 'mouseout', this.hideDeleteImage.bind(this, deleteImg));
+ }
+
+ // set dblclick event on a schedule item.
+ if (this.calendar.options.dblclickSchedule) {
+ Event.observe(
+ item, 'dblclick', this.calendar.options.dblclickSchedule.bind(this, schedule));
+ }
+
+ // drag handler
+ var handler = null;
+ if (canEdit) {
+ handler = Builder.node('DIV', {className: this.calendar.classNames.joinClassNames('scheduleHandler')});
+ item.appendChild(handler);
+ }
+
+ var icon = null;
+ if (schedule.icon) {
+ icon = Builder.node('IMG', {src: schedule.icon, alt: 'icon', style: 'float: left;'});
+ item.appendChild(icon);
+ }
+
+ // private mark
+ if (!schedule.publicity) {
+ icon = Builder.node('DIV', {id: 'private_img_' + schedule.id});
+ this.calendar.classNames.addClassNames(icon, 'privateImg');
+ item.appendChild(icon);
+ }
+
+ var body = Builder.node('DIV');
+ var text = this.getTimeText(schedule.start, schedule.finish);
+ text = Builder.node('DIV', {id: id + '_text', style: 'float: left;'}, [text]);
+ this.calendar.classNames.addClassNames(text, 'scheduleTimeArea');
+ item.appendChild(text);
+ var description = schedule.description.unescapeHTML();
+ item.appendChild(Builder.node('DIV', {id: id + '_description'}, [description]));
+
+ item.title = description;
+ item.schedule = schedule;
+
+ return [item, handler];
+ },
+
+ adjustScheduleStyle: function(item, rowIndex, cellIndex, holder) {
+ var self = this;
+ var height = parseInt(Element.getStyle(item, 'height'), 10);
+ var top = parseInt(Element.getStyle(item, 'top'), 10);
+ var range = this.getScheduleRange(item);
+ var tops = [];
+
+ holder.each(function(holded) {
+ var holdedRange = self.getScheduleRange(holded);
+ if (range.any(function(r) {return holdedRange.include(r)})) {
+ tops.push(holded.topIndex);
+ }
+ });
+
+ var index = $R(0, tops.length, true).detect(function(i) {return !tops.include(i)});
+ if (isNaN(index)) index = tops.length;
+ item.topIndex = index;
+ Element.setStyle(item, {top: top + (height + 2) * index + 'px'});
+ },
+
+ getScheduleRange: function(item) {
+ return $R(0, item.length, true).map(function(i) {return item.cellIndex + i});
+ },
+
+ setScheduleBaseStyle: function(item, rowIndex, cellIndex, length) {
+ var oneDay = this.column.height;
+ var top = oneDay * rowIndex + this.column.dateTextHeight;
+ var adjustSize = this.getAdjustSize();
+ Element.setStyle(item, {
+ top: top + 'px',
+ width: this.column.width * length + adjustSize * (length - 1) + 'px',
+ left: this.column.width * cellIndex + cellIndex * adjustSize + 'px'
+ });
+ },
+
+ afterBuild: function() {
+ this.scheduleNodes = [];
+ if (this.calendar.options.size != Calendar.size.small) {
+ this.setContainerInfo();
+ this.setColumnWidth();
+ this.setCover();
+ this.setSelector();
+ var self = this;
+ var indexes = this.calendar.options.displayIndexes;
+ var distance = this.getDragDistance();
+ var holders = $R(0, $(this.getCalendarTableId()).rows.length).map(function() {return []});
+ var date = this.calendar.date;
+ var calStartDate = DateUtil.getFirstDate(date.getFullYear(), date.getMonth());
+ var calStart = calStartDate.days();
+ var calFinish = DateUtil.getLastDate(date.getFullYear(), date.getMonth()).days();
+
+ self.calendar.options.schedules.each(function(schedule, index) {
+ var startDate = self.toDate(schedule.start);
+ var start = startDate.days();
+ var finishDate = self.toDate(schedule.finish);
+ var finish = finishDate.days();
+ var days = self.getDayDiff(schedule);
+
+ if ((start >= calStart && start <= calFinish) || (finish >= calStart && finish <= calFinish)) {
+ if (!calStartDate.sameMonth(startDate)) startDate = calStartDate;
+ self.setSchedule(schedule, holders, distance, days);
+ }
+ });
+ }
+ },
+
+ setSchedule: function(schedule, holders, distance, days) {
+ var items = [];
+ var rowMax = 6;
+ var startDate = DateUtil.toDate(schedule.start);
+ var date = startDate;
+ var indexes = this.calendar.options.displayIndexes;
+ var targetDate = this.calendar.options.initDate;
+
+ while (days >= 0) {
+ if (date.getMonth() != startDate.getMonth()) break;
+ var lastWday = this.getLastWday(date);
+
+ var length = days + 1;
+ var firstDay = date.getDay();
+ var finishDate = date.advance({days: length - 1});
+
+ if (finishDate.getTime() > lastWday.getTime()) {
+ finishDate = lastWday;
+ length = finishDate.days() - date.days() + 1;
+ }
+ var finishDay = finishDate.getDay();
+ var wdays = null;
+ if (firstDay <= finishDay) {
+ wdays = $R(firstDay, finishDay, false);
+ } else {
+ wdays = $R(0, finishDay, false).toArray().concat($R(firstDay, rowMax, false).toArray());
+ }
+ var itemLength = wdays.findAll(function(day) {
+ return indexes.include(day);
+ }).length;
+
+ var cellDate = new Date(date.getTime());
+ while (cellDate.days() <= finishDate.days()) {
+ if (cellDate.getMonth() == targetDate.getMonth()) {
+ var cellPosition = this.getCellPosition(cellDate.getDate());
+ if (cellPosition) {
+ var rowIndex = cellPosition.rowIndex;
+ var cellIndex = cellPosition.cellIndex;
+
+ // create a schedule node.
+ var result = this.buildSchedule(schedule);
+ var item = result.first();
+ item.length = itemLength;
+ item.cellIndex = cellIndex;
+ this.container.appendChild(item);
+
+ // set style(position and size) of a schedule item.
+ this.setScheduleBaseStyle(item, rowIndex, cellIndex, itemLength);
+ var left = this.adjustScheduleStyle(item, rowIndex, cellIndex, holders[rowIndex]);
+
+ if (schedule.edit == undefined || schedule.edit) {
+ this.setDraggable(item, result.last(), distance);
+ this.setResize(item);
+ }
+
+ holders[rowIndex].push(item);
+ this.scheduleNodes.push(item);
+ break;
+ } else if (indexes.include(cellDate.getDay())) {
+ itemLength--;
+ }
+ } else if (indexes.include(cellDate.getDay())) {
+ itemLength--;
+ }
+ cellDate = cellDate.advance({days: 1});
+ }
+
+ if (items.length == 0) {
+ days -= length;
+ } else {
+ days =- 7;
+ }
+
+ var date = finishDate.advance({days: 1});
+ if (item) items.push(item);
+ }
+
+ var self = this;
+ items.each(function(item) {
+ Event.observe(item, 'mouseover', self.mouseOverSubSchedule.bind(this, items));
+ Event.observe(item, 'mouseout', self.mouseOutSubSchedule.bind(this, items));
+ });
+ },
+
+ getLastWday: function(date) {
+ var index = this.calendar.wdays.indexOf(date.getDay()) + 1;
+ return date.advance({days: this.calendar.wdays.length - index});
+ },
+
+ setSelector: function() {
+ var selector = $(this.getSelectorId());
+ Element.setStyle(selector, {
+ width: this.column.width + 'px',
+ height: this.column.height - 2 + 'px'
+ });
+ },
+
+ // set draggalbe event
+ setDraggable: function(item, handle, distance) {
+ var self = this;
+ var offset = Position.cumulativeOffset(this.container);
+ var selector = $(this.getSelectorId());
+ var cWidth = this.column.width;
+ var cHeight = this.column.height;
+ var rowMax = this.rowMax;
+ var cellMax = this.calendar.options.displayIndexes.length - 1;
+ var adjustSize = this.getAdjustSize();
+
+ new Draggable(item,
+ {
+ handle: handle,
+ scroll: window,
+ starteffect: Prototype.emptyFunction,
+ endeffect: Prototype.emptyFunction,
+ onStart: function(draggalbe) {
+ Element.show(selector);
+ },
+ onDrag: function(draggable, event) {
+ var element = draggable.element;
+ var top = parseInt(Element.getStyle(element, 'top'), 10);
+ var rowIndex = Math.floor(top / cHeight);
+ var left = parseInt(Element.getStyle(element, 'left'), 10);
+ var cellIndex = Math.floor(left / cWidth);
+
+ if ((cellIndex >= 0 && rowIndex >= 0) &&
+ (cellIndex <= cellMax && rowIndex <= rowMax)) {
+ Element.setStyle(selector, {
+ left: cWidth * cellIndex + adjustSize * cellIndex + 'px',
+ top: cHeight * rowIndex + 'px'
+ });
+ }
+ },
+ onEnd: function(draggable) {
+ Element.hide(selector);
+ self.changeSchedule(draggable);
+ }
+ }
+ );
+ },
+
+ // set resize event
+ setResize: function(item) {
+ var self = this;
+ new CalendarResizeableEx(item, {
+ left: 0,
+ top: 0,
+ bottom: 0,
+ distance: this.column.width,
+ restriction: true,
+ resize: function(element) {
+ self.updateTirm(element);
+ }
+ });
+ },
+
+ /********************************** public method **********************************/
+ getDate: function(element) {
+ if (!element) return;
+ var date = this.calendar.date;
+ if (element.constructor == String)
+ return new Date(date.getFullYear(), date.getMonth(), element);
+ else
+ return new Date(date.getFullYear(), date.getMonth(), element.id.getSuffix());
+ },
+
+ abstractSelect: function(event, method) {
+ var element = null;
+ if (this.calendar.options.size == 'large') {
+ element = this.findClickedElement(event);
+ } else {
+ element = Event.element(event);
+ if (element.tagName != 'TD') {
+ element = Element.getParentByTagName(['TD'], element);
+ }
+ }
+ if (element && element.id) {
+ var date = this.getDate(element);
+ method(date, element);
+ }
+ },
+
+ getSelectedTerm: function() {
+ var self = this;
+ var elements = this.calendar.getSelected();
+ if (elements && elements.length > 0) {
+ return [elements.first(), elements.last()].map(function(e) {
+ return self.getDate(e);
+ });
+ }
+ return null;
+ },
+
+ /********************************** private method **********************************/
+ selectDay: function(event) {
+ var calendar = this.calendar;
+ var th = Event.element(event);
+ if (th.tagName != 'TH')
+ th = Element.getParentByTagName('TH', th);
+
+ this.iterateTable({doCell: function(cell) {
+ if ((cell.cellIndex == th.cellIndex) && cell.id)
+ calendar.addSelectedClass(cell);
+ }});
+ },
+
+ inspectArgument: function(object, time) {
+ var self = this;
+ var dates = this.calendar.getSelected();
+ var result = [];
+
+ self.calendar.recurrence(object, function(o) {
+ if (!o.date) {
+ dates.each(function(d) {
+ var param = {};
+ if (!o.date) {
+ param = {date: self.getDate(d)};
+ if (time) {
+ param.start = {hour: 0, min: 0};
+ param.finish = {hour: 0, min: 0};
+ }
+ }
+ Object.extend(param, o);
+ result.push(param);
+ });
+ } else if (o.date.constructor == Object) {
+ o.date = new Date(o.date.year, o.date.month, o.date.day);
+ result.push(o);
+ } else {
+ result.push(o);
+ }
+ });
+ return result;
+ },
+
+ inspectDateArgument: function(date) {
+ if (date) {
+ map = [];
+ this.calendar.recurrence(date, function(d) {
+ if (d.constructor == Object)
+ map.push(new Date(d.year, d.month, d.day));
+ else
+ map.push(d);
+ });
+ return map;
+ } else {
+ var calendar = this;
+ var dates = this.calendar.getSelected();
+ if (dates.length == 0) return null;
+
+ return dates.collect(function(d) {
+ return calendar.getDate(d);
+ });
+ }
+ },
+
+ findClickedElement: function(event) {
+ var container = $(this.getScheduleContainerId());
+ var position = Position.cumulativeOffset(container);
+ var scrollTop = Position.realOffset(container).last();
+ scrollTop -= document.documentElement.scrollTop || document.body.scrollTop;
+ var x = Event.pointerX(event) - position[0];
+ var y = Event.pointerY(event) - position[1] + scrollTop;
+ var rowIndex = Math.floor(y / this.column.height);
+ var cellIndex = Math.floor(x / this.column.width);
+ return $(this.calendarTable.rows[rowIndex].cells[cellIndex]);
+ },
+
+ multipleSelection: function(event) {
+ if (!this.calendar.selectedBase || !this.calendar.mouseDown) return;
+ var self = this;
+ var calendar = this.calendar;
+ var selected = this.calendar.selectedBase;
+
+ this.abstractSelect(event, function(date, element) {
+ var selectedElement = $(selected.id);
+
+ var range = calendar.createRange(
+ parseInt(selectedElement.id.getSuffix()),
+ parseInt(element.id.getSuffix())
+ );
+
+ self.iterateTable({doCell: function(cell) {
+ if (cell.tagName != 'TD' || !cell.id) throw $continue;
+ var id = parseInt(cell.id.getSuffix());
+
+ if (range.include(id)) {
+ calendar.addSelectedClass(cell);
+ } else {
+ calendar.removeSelectedClass(cell);
+ }
+ }});
+ });
+ },
+
+ iterateTable: function() {
+ var options = Object.extend({
+ doTable: null,
+ doRow: null,
+ doCell: null
+ }, arguments[0]);
+
+ var calendar = $(this.getCalendarTableId());
+ if (options.doTable) {
+ options.doTable(calendar)
+ };
+
+ $A(calendar.rows).each(function(row) {
+ if (options.doRow) {
+ options.doRow(row);
+ }
+ $A(row.cells).each(function(cell) {
+ if (options.doCell) {
+ options.doCell(cell);
+ }
+ });
+ });
+ },
+
+ findRow: function(rowIndex) {
+ var table = $(this.getCalendarTableId());
+ return $A(table.rows).detect(function(row) {
+ return row.rowIndex == rowIndex;
+ });
+ },
+
+ findCell: function(rowIndex, cellIndex) {
+ return $A(this.findRow(rowIndex).cells).detect(function(cell) {
+ return cell.cellIndex == cellIndex;
+ });
+ },
+
+ getCalendarTableId: function() {
+ return this.calendar.element.id.appendSuffix(CalendarMonth.id.calTable);
+ },
+
+ getDateId: function(date) {
+ var day = null;
+ if (date.constructor == Date) {
+ day = date.getDate();
+ } else {
+ day = date;
+ }
+ return this.calendar.element.id.appendSuffix(day);
+ },
+
+ getCell: function(day) {
+ return $(this.getDateId(day));
+ },
+
+ getCellPosition: function(day) {
+ var cell = this.getCell(day);
+ if (cell) {
+ var row = Element.getParentByTagName(['tr'], cell);
+ return {cellIndex: cell.cellIndex, rowIndex: row.rowIndex};
+ }
+ },
+
+ changeSchedule: function(draggable) {
+ var element = draggable.element;
+ var schedule = element.schedule;
+
+ var top = parseInt(Element.getStyle(element, 'top'), 10);
+ var rowIndex = Math.floor(top / this.column.height);
+ var left = parseInt(Element.getStyle(element, 'left'), 10);
+ var cellIndex = Math.floor(left / this.column.width);
+ var table = $(this.getCalendarTableId());
+ var rowMax = table.rows.length - 1;
+ var cellMax = this.calendar.options.displayIndexes.length - 1;
+
+ if ((cellIndex >= 0 && rowIndex >= 0) &&
+ (cellIndex <= cellMax && rowIndex <= rowMax)) {
+ var cell = this.findCell(rowIndex, cellIndex);
+ var date = cell.date;
+ var diff = this.getDayDiff(schedule);
+
+ var finish = date.advance({days: diff});
+ if (
+ schedule.start.month == date.getMonth() &&
+ schedule.start.day == date.getDate() &&
+ schedule.finish.month == finish.getMonth() &&
+ schedule.finish.day == finish.getDate()
+ ) {this.calendar.refreshSchedule(); return;}
+
+ schedule.start.month = date.getMonth();
+ schedule.start.day = date.getDate();
+ schedule.finish.month = finish.getMonth();
+ schedule.finish.day = finish.getDate();
+
+ this.calendar.refreshSchedule();
+ this.calendar.options.changeSchedule(schedule);
+ } else {
+ this.calendar.refreshSchedule();
+ }
+ },
+
+ updateTirm: function(element) {
+ var schedule = element.schedule;
+ var width = parseInt(Element.getStyle(element, 'width'));
+ var top = parseInt(Element.getStyle(element, 'top'));
+ var left = parseInt(Element.getStyle(element, 'left'));
+ var cellIndex = Math.round((left + width) / this.column.width) - 1;
+ var rowIndex = Math.round(top / this.column.height);
+ var cell = this.findCell(rowIndex, cellIndex);
+
+ var oldFinish = schedule.finish;
+ var newFinish = cell.date.toHash();
+ newFinish.hour = oldFinish.hour;
+ newFinish.min = oldFinish.min;
+
+ if (DateUtil.toDate(schedule.start).getTime() >= DateUtil.toDate(newFinish).getTime()) {
+ var maxHour = 23;
+ var maxMin = 55;
+ if (schedule.start.hour == maxHour && schedule.start.min == maxMin) {
+ this.calendar.refreshSchedule();
+ this.calendar.options.updateTirm();
+ return;
+ } else {
+ newFinish.hour = maxHour;
+ newFinish.min = maxMin;
+ }
+ }
+ schedule.finish = newFinish;
+
+ this.calendar.refreshSchedule();
+ this.calendar.options.updateTirm(schedule);
+ },
+
+ getTimeText: function(start, finish) {
+ var calendar = this.calendar;
+ return calendar.formatTime(start);
+ },
+
+ getDayDiff: function(schedule) {
+ return DateUtil.numberOfDays(this.toDate(schedule.start), this.toDate(schedule.finish));
+ }
+});
+
+
+/**
+ * CalendarWeek Class
+ */
+var CalendarWeek= Class.create();
+CalendarWeek.id = {
+ columnContainer: 'columnContainer',
+ columnHeader: 'columnHeader',
+ column: 'column',
+ next: 'next',
+ pre: 'pre'
+}
+Object.extend(CalendarWeek.prototype, AbstractCalendar.prototype);
+Object.extend(CalendarWeek.prototype, {
+
+ initialize: function(calendar) {
+ this.calendar = calendar;
+ this.week = this.getWeek();
+ this.setDisplayTime();
+ },
+
+ /*** Week ***/
+ /********************************** build functions **********************************/
+ buildHeaderLeft: function() {
+ var container = Builder.node('TD');
+ this.calendar.classNames.addClassNames(container, 'preYears');
+
+ var id = this.calendar.element.id.appendSuffix(CalendarWeek.id.pre);
+ var node = Builder.node('DIV', {id: id});
+ this.calendar.classNames.addClassNames(node, 'preWeekMark');
+ Event.observe(node, "click", this.calendar.changeCalendar.bindAsEventListener(this.calendar));
+ container.appendChild(node);
+
+ return container;
+ },
+
+ buildHeaderCenter: function() {
+ var contents = [];
+ var texts = [];
+ if (this.calendar.options.weekHeaderFormat) {
+ texts = [this.formatHeaderDate(this.week.first()), '-', this.formatHeaderDate(this.week.last())];
+ }(this.week[0], this.week.last()) || [];
+
+ var node = Builder.node('SPAN', [texts[0] || this.week[0].toDateString()]);
+ this.calendar.classNames.addClassNames(node, 'ym');
+ contents.push(node);
+
+ node = Builder.node('SPAN', [texts[1] || '-']);
+ this.calendar.classNames.addClassNames(node, 'ym');
+ contents.push(node);
+
+ node = Builder.node('SPAN', [texts.last() || this.week.last().toDateString()]);
+ this.calendar.classNames.addClassNames(node, 'ym');
+ contents.push(node);
+
+ var container = Builder.node('TD', contents);
+ this.calendar.classNames.addClassNames(container, 'years');
+
+ return container;
+ },
+
+ formatHeaderDate: function(date) {
+ if (this.calendar.options.weekHeaderFormat) {
+ return new Template(this.calendar.options.weekHeaderFormat).
+ evaluate({year: date.getFullYear(), month: date.getMonth() + 1, day: date.getDate()});
+ }
+ return '';
+ },
+
+ buildHeaderRight: function() {
+ var container = Builder.node('TD', {align: 'right'});
+ this.calendar.classNames.addClassNames(container, 'nextYears');
+
+ var id = this.calendar.element.id.appendSuffix(CalendarWeek.id.next);
+ var node = Builder.node('DIV', {id: id});
+ this.calendar.classNames.addClassNames(node, 'nextWeekMark');
+ Event.observe(node, "click", this.calendar.changeCalendar.bindAsEventListener(this.calendar));
+ container.appendChild(node);
+
+ return container;
+ },
+
+ buildCalendar: function() {
+ var table = Builder.node('TABLE', {id: CalendarWeek.id.columnContainer});
+ var tbody = Builder.node('TBODY');
+
+ this.calendar.classNames.addClassNames(table, 'weekTable');
+ table.appendChild(tbody);
+ var tr = Builder.node('TR');
+ tbody.appendChild(tr);
+
+ if (this.calendar.options.displayTimeLine) {
+ tr.appendChild(this.buildTimeLine());
+ }
+ tr.appendChild(this.buildCalendarContainer());
+
+ return table;
+ },
+
+ buildTimeLine: function() {
+ var time = new Date();
+ var hour = 0, hoursOfDay = 24;
+ time.setHours(hour);
+ time.setMinutes(0);
+ var nodes = [];
+
+ var node = Builder.node('DIV');
+ this.calendar.classNames.addClassNames(node, 'timeLineTimeTop');
+ nodes.push(node);
+ while (hour < hoursOfDay) {
+ if (this.includeDisplayTime(hour)) {
+ node = Builder.node('DIV', [this.formatTime(time)]);
+ this.calendar.classNames.addClassNames(node, 'timeLineTime');
+ nodes.push(node);
+ }
+ hour++;
+ time.setHours(hour);
+ }
+
+ var td = Builder.node('TD', nodes);
+ this.calendar.classNames.addClassNames(td, 'timeLine');
+ return td;
+ },
+
+ buildCalendarContainer: function() {
+ var table = Builder.node('TABLE');
+ var tbody = Builder.node('TBODY');
+ table.appendChild(tbody);
+ this.calendar.classNames.addClassNames(table, 'weekMainTable');
+
+ tbody.appendChild(this.buildCalendarHeader());
+ tbody.appendChild(this.buildCalendarMain());
+
+ return Builder.node('TD', [table]);
+ },
+
+ buildCalendarHeader: function() {
+ var indexes = this.calendar.options.displayIndexes;
+ var ths = [];
+ var self = this;
+ var today = new Date().days();
+ var width = 100 / indexes.length + '%';
+ var clickDateText = this.calendar.options.clickDateText;
+ var subHeaderTempl = (this.calendar.options.weekSubHeaderFormat) ? new Template(this.calendar.options.weekSubHeaderFormat) : null;
+
+ this.week.each(function(w, index) {
+ var text = null;
+ if (subHeaderTempl) {
+ text = subHeaderTempl.evaluate({month: w.getMonth() + 1, day: w.getDate(), wday: self.calendar.options.dayOfWeek[w.getDay()]});
+ } else {
+ text = w.toDateString().split(' ');
+ text.pop();
+ text = text.join(' ');
+ }
+ var link = Builder.node('A', {href: '#'}, [text]);
+ if (w.days() == today) self.calendar.addHighlightClass(link);
+ var node = Builder.node('DIV', [link]);
+ self.calendar.classNames.addClassNames(node, 'headerColumn');
+
+ if (clickDateText) {
+ Event.observe(node, 'mousedown', clickDateText.bindAsEventListener(self, w));
+ } else {
+ Event.observe(node, 'mousedown', self.clickDateText.bindAsEventListener(self, w));
+ }
+
+ var id = self.calendar.element.id.appendSuffix(CalendarWeek.id.column);
+ var th = Builder.node('TH', {id: id.appendSuffix(index)}, [node]);
+ th.width = width;
+ ths.push(th);
+ });
+
+ var table = Builder.node('TABLE');
+ var tbody = Builder.node('TBODY');
+ table.appendChild(tbody);
+ tbody.appendChild(Builder.node('TR', ths));
+ this.calendar.classNames.addClassNames(table, 'weekMainTable');
+ return Builder.node('TR', [Builder.node('TD', [table])]);
+ },
+
+ buildCalendarMain: function() {
+ var indexes = this.calendar.options.displayIndexes;
+ var self = this;
+ var tds = [];
+ var width = 100.0 / indexes.length + '%';
+
+ this.week.each(function(w, index) {
+ var schedules = self.calendar.options.schedules[w.toDateString()];
+ var nodes = [];
+ var i = 0, j = 0;
+
+ while (i < 24) {
+ if (self.includeDisplayTime(i)) {
+ var node = Builder.node('DIV', {id: self.getDateId(w, i)});
+ var hour = i / 1;
+ var min = i % 1 * 60;
+ node.date = new Date(w.getFullYear(), w.getMonth(), w.getDate(), hour, min, 0);
+
+ if (nodes.length == 0) {
+ self.calendar.classNames.addClassNames(node, 'columnTopDate');
+ } else if (i % 1 == 0) {
+ self.calendar.classNames.addClassNames(node, 'columnDate');
+ } else {
+ self.calendar.classNames.addClassNames(node, 'columnDateOdd');
+ }
+ self.setColumnEvent(node);
+ nodes.push(node);
+ }
+ i += 0.5;
+ }
+
+ var td = Builder.node('TD', nodes);
+ td.width = width;
+ tds.push(td);
+ });
+
+ this.calendarTable = Builder.node('TABLE', {style: 'position: relative'});
+ var tbody = Builder.node('TBODY');
+ this.calendarTable.appendChild(tbody);
+ tbody.appendChild(Builder.node('TR', tds));
+ this.calendar.classNames.addClassNames(this.calendarTable, 'weekMainTable');
+ var container = this.buildScheduleContainer();
+ container.appendChild(this.calendarTable);
+ this.setScheduleContainerEvent(container);
+ this.calendar.classNames.addClassNames(container, 'scheduleContainer');
+ return Builder.node('TR', [Builder.node('TD', [container])]);
+ },
+
+ setColumnEvent: function(node) {
+ // do nothing
+ },
+
+ beforeBuild: function() {
+ this.column = {};
+ var rule = CssUtil.getCssRuleBySelectorText('.' + Calendar.className.columnDate);
+ this.column.height = parseInt(rule.style['height'], 10) + 1;
+ },
+
+ /**********************************
+ ***** for make schedule item *****
+ **********************************/
+ buildSchedule: function(schedule) {
+ var id = 'scheduleItem_' + schedule.id;
+ var canEdit = (schedule.edit == undefined || schedule.edit);
+ var item = Builder.node('DIV', {id: id});
+ this.calendar.classNames.addClassNames(item, 'scheduleItemLarge');
+
+ if (canEdit) {
+ var deleteImg = Builder.node('DIV',
+ {
+ id: 'scheduleDeleteImg_' + schedule.id,
+ className: this.calendar.classNames.joinClassNames('deleteImg')
+ });
+ Element.hide(deleteImg);
+ item.appendChild(deleteImg);
+
+ // set event on a image.
+ Event.observe(deleteImg, 'click', this.clickDeleteImage.bind(this, schedule));
+ Event.observe(item, 'mouseover', this.showDeleteImage.bind(this, deleteImg));
+ Event.observe(item, 'mouseout', this.hideDeleteImage.bind(this, deleteImg));
+ }
+
+ // set dblclick event on a schedule item.
+ if (this.calendar.options.dblclickSchedule) {
+ Event.observe(
+ item, 'dblclick', this.calendar.options.dblclickSchedule.bind(this, schedule));
+ }
+
+ // drag handler
+ var handler = null;
+ if (canEdit) {
+ handler = Builder.node('DIV', {className: this.calendar.classNames.joinClassNames('scheduleHandler')});
+ item.appendChild(handler);
+ }
+
+ var icon = null;
+ if (schedule.icon) {
+ icon = Builder.node('IMG', {src: schedule.icon, alt: 'icon', style: 'float: left;'});
+ item.appendChild(icon);
+ }
+
+ // private mark
+ if (!schedule.publicity) {
+ icon = Builder.node('DIV', {id: 'private_img_' + schedule.id});
+ this.calendar.classNames.addClassNames(icon, 'privateImg');
+ item.appendChild(icon);
+ }
+
+ var text = this.getTimeText(schedule.start, schedule.finish);
+ text = Builder.node('DIV', {id: id + '_text'}, [text]);
+ this.calendar.classNames.addClassNames(text, 'scheduleTimeArea');
+
+ item.appendChild(text);
+ var description = schedule.description.unescapeHTML();
+ item.appendChild(Builder.node('DIV', {id: id + '_description'}, [description]));
+ item.title = description;
+ item.schedule = schedule;
+
+ return [item, handler];
+ },
+
+ adjustScheduleStyle: function(item, index, holder) {
+ var schedule = item.schedule;
+ var time = this.convertHours(schedule);
+ var start = time[0];
+ var finish = time[1];
+ var same = [];
+ var self = this;
+
+ holder.each(function(h) {
+ var hTime = self.convertHours(h.schedule);
+ var hStart = hTime[0];
+ var hFinish = hTime[1];
+
+ if (
+ ((hStart <= start) && (hFinish > start)) || ((hStart < finish) && (hFinish >= finish)) ||
+ ((start <= hStart) && (finish > hStart)) || ((start < hFinish) && (finish >= hFinish))
+ ) {
+ same.push(h);
+ }
+ });
+
+ var adjustSize = index * this.getAdjustSize();
+ var left = this.column.width * index + adjustSize;
+ if (same.length == 0) {
+ Element.setStyle(item, {left: left + 'px'});
+ } else {
+ same.push(item);
+ var width = parseInt(Element.getStyle(item, 'width'), 10) / (same.length) - 2;
+ same.each(function(s, i) {
+ var adjustLeft = left + width * i + (2 * i);
+// if (i != 0) adjustLeft += 2;
+ Element.setStyle(s, {
+ width: width + 'px',
+ left: adjustLeft + 'px'
+ });
+ });
+ }
+ return left;
+ },
+
+ setScheduleBaseStyle: function(item) {
+ var schedule = item.schedule;
+ if (!this.calendar.isSameDate(schedule.start, schedule.finish)) {
+ schedule.finish.hour = 24;
+ schedule.finish.min = 0;
+ }
+
+ var time = this.convertHours(schedule);
+ var startTime = time.first();
+ var finishTime = time.last();
+ var oneHour = this.column.height * 2;
+ var diff = this.calendar.getTimeDiff(schedule.start, schedule.finish);
+ var rate = (diff.hour + (diff.min / 60)) || 1;
+
+ var over = 0;
+ var top = 0;
+ var height = 0;
+
+ var includeStart = this.includeDisplayTime(startTime);
+ var includeFinish = this.includeDisplayTime(finishTime);
+ if (!includeStart && !includeFinish) {
+ if ((this.startTime <= startTime && this.startTime <= finishTime) ||
+ (startTime < this.finishTime && finishTime < this.finishTime)) {
+ top = height = 0;
+ Element.hide(item);
+ } else {
+ top = 0;
+ height = oneHour * (this.finishTime - this.startTime) - 3;
+ }
+ } else {
+ if (includeStart) {
+ top = oneHour * (startTime - this.startTime);
+ height = oneHour * rate - 3;
+ } else {
+ top = 0;
+ over = this.startTime - startTime;
+ height = oneHour * (rate - over);
+ }
+
+ if (includeFinish) {
+ } else {
+ over = finishTime - this.finishTime;
+ height -= oneHour * over;
+ }
+ }
+
+ try {
+ Element.setStyle(item, {
+ top: top + 'px',
+ width: this.column.width + 'px',
+ height: height + 'px'
+ });
+ } catch (e) {}
+ },
+
+ afterBuild: function() {
+ this.setContainerInfo();
+ this.setColumnWidth();
+ this.setCover();
+ var self = this;
+ var container = $(this.getScheduleContainerId());
+ var distance = this.getDragDistance();
+ this.scheduleNodes = [];
+ var holders = this.week.map(function() {return []});
+ var weekSize = this.week.legth - 1;
+
+ this.calendar.options.schedules.each(function(schedule) {
+ var items = [];
+ var sub, subItem = null;
+ self.week.each(function(date, index) {
+ if (self.calendar.betweenDate(schedule, date)) {
+ if (self.isSameStartDate(schedule, date) && self.isSameFinishDate(schedule, date)) {
+ items.push(self.setSchedule(schedule, index, holders, container, distance));
+ } else {
+ sub = self.copyOneDaySchedule(schedule, date);
+ subItem = self.setSchedule(sub, index, holders, container, distance);
+ subItem.originalSchedule = schedule;
+ items.push(subItem);
+ }
+ } else if (sub) {
+ throw $break;
+ }
+ });
+
+ items.each(function(item) {
+ Event.observe(item, 'mouseover', self.mouseOverSubSchedule.bind(this, items));
+ Event.observe(item, 'mouseout', self.mouseOutSubSchedule.bind(this, items));
+ });
+ });
+ },
+
+ copyOneDaySchedule: function(schedule, date) {
+ var sub = null;
+ if (this.isSameStartDate(schedule, date)) {
+ sub = this.copySchedule(schedule, date);
+ sub.finish.hour = 24;
+ sub.finish.min = 0;
+ } else if (this.isSameFinishDate(schedule, date)) {
+ sub = this.copySchedule(schedule, date);
+ sub.start.hour = 0;
+ sub.start.min = 0;
+ } else {
+ sub = this.copySchedule(schedule, date);
+ sub.start.hour = 0;
+ sub.start.min = 0;
+ sub.finish.hour = 24;
+ sub.finish.min = 0;
+ }
+ return sub;
+ },
+
+ copySchedule: function(schedule, date) {
+ sub = Object.extend({}, schedule);
+ sub.start = {
+ year: date.getFullYear(),
+ month: date.getMonth(),
+ day: date.getDate(),
+ hour: schedule.start.hour,
+ min: schedule.start.min
+ }
+ sub.finish = {
+ year: date.getFullYear(),
+ month: date.getMonth(),
+ day: date.getDate(),
+ hour: schedule.finish.hour,
+ min: schedule.finish.min
+ }
+ return sub;
+ },
+
+ setSchedule: function(schedule, index, holders, container, distance) {
+ // create a schedule node.
+ var result = this.buildSchedule(schedule);
+ var item = result.first();
+ container.appendChild(item);
+
+ // set style(position and size) of a schedule item.
+ this.setScheduleBaseStyle(item);
+ var left = this.adjustScheduleStyle(item, index, holders[index]);
+ var adjustSize = index * this.getAdjustSize();
+ var snapLeft = this.column.width + adjustSize + 'px';
+
+ if (schedule.edit == undefined || schedule.edit) {
+ this.setDraggable(item, result.last(), container, distance);
+ this.setResize(item);
+ }
+
+ holders[index].push(item);
+ this.scheduleNodes.push(item);
+ return item;
+ },
+
+ getDragDistance: function() {
+ var adjustSize = this.getAdjustSize();
+ return [this.column.width + adjustSize, this.column.height / 2];
+ },
+
+ // set draggalbe event
+ setDraggable: function(item, handle, container, distance) {
+ var self = this;
+ new Draggable(item,
+ {
+ handle: handle,
+ scroll: window,
+ starteffect: Prototype.emptyFunction,
+ endeffect: Prototype.emptyFunction,
+ snap: function(x, y) {
+ var eDimensions = Element.getDimensions(item);
+ var pDimensions = Element.getDimensions(container);
+ var xy = [x, y].map(function(v, i) { return Math.floor(v/distance[i]) * distance[i] });
+ xy = [
+ self._constrain(xy[0], 0, pDimensions.width - eDimensions.width),
+ self._constrain(xy[1], 0, pDimensions.height - eDimensions.height)
+ ];
+ return xy;
+ },
+ onEnd: function(draggable, event) {
+ self.changeSchedule(draggable, event);
+ },
+ change: function(draggable) {
+ self.changeTimeDisplay(draggable.element);
+ }
+ }
+ );
+ },
+
+ // set resize event
+ setResize: function(item) {
+ new CalendarResizeableEx(item, {
+ left: 0,
+ right: 0,
+ distance: this.column.height / 2,
+ restriction: true,
+ resize: function(element) {
+ this.updateTirm(element);
+ }.bind(this),
+ change: function(element) {
+ this.changeTimeDisplay(element);
+ }.bind(this)
+ });
+ },
+
+ /********************************** public method **********************************/
+ getDate: function(element) {
+ return element.date;
+ },
+
+ abstractSelect: function(event, method) {
+ var element = this.findClickedElement(event);
+ if (element) {
+ if (Element.hasClassName(element, Calendar.className.columnDate) ||
+ Element.hasClassName(element, Calendar.className.columnDateOdd) ||
+ Element.hasClassName(element, Calendar.className.columnTopDate)) {
+
+ var date = this.getDate(element);
+ method(date, element);
+ }
+ }
+ },
+
+ getSelectedTerm: function() {
+ var self = this;
+ var elements = this.calendar.getSelected();
+ if (elements && elements.length > 0) {
+ var last = elements.last();
+ if (last) {
+ last = last.date;
+ } else {
+ last = elements.first().date;
+ }
+ last = new Date(last.getFullYear(), last.getMonth(),
+ last.getDate(), last.getHours(), last.getMinutes(), 0);
+ last.setMinutes(last.getMinutes() + 30);
+
+ return [elements.first().date, last];
+ }
+ },
+
+ /*** Week ***/
+ /********************************** private method **********************************/
+ setWidth: function(node) {
+ Element.setStyle(node, {width: this.column.width + 'px'});
+ },
+
+ inspectArgument: function(object, time) {
+ if (object.date) return object;
+
+ var self = this;
+ var dates = this.calendar.getSelected();
+ var result = [];
+ this.calendar.recurrence(object, function(o) {
+ var param = {};
+ if (!o.date) {
+ param = {date: self.getDate(dates[0])};
+ if (!o.start)
+ param.start = dates[0].time;
+ if (!o.finish)
+ param.finish = dates[dates.length - 1].time;
+ }
+ Object.extend(param, o);
+ result.push(param);
+ });
+
+ return result;
+ },
+
+ inspectDateArgument: function(date) {
+ if (date) return date;
+
+ var calendar = this;
+ var dates = this.getSelected();
+ if (dates.length == 0) return null;
+
+ return dates.collect(function(d) {
+ return calendar.getDate(d);
+ });
+ },
+
+ addColumnClass: function(element) {
+ if (document.all)
+ this.calendar.classNames.addClassNames(element, 'columnWin');
+ else
+ this.calendar.classNames.addClassNames(element, 'column');
+ },
+
+ getHeaderId: function() {
+ return this.calendar.element.id.appendSuffix(CalendarWeek.id.columnHeader);
+ },
+
+ getColumnId: function(i) {
+ return this.calendar.element.id.appendSuffix(CalendarWeek.id.column + '_' + i);
+ },
+
+ changeSchedule: function(draggable, event) {
+ var element = draggable.element;
+ var schedule = element.schedule;
+ var time = this.getTimeByElement(element);
+ this.calendar.cacheSchedule(schedule);
+
+ var container = $(this.getScheduleContainerId());
+ var dimensions = Element.getDimensions(container);
+ var offset = Position.cumulativeOffset(container);
+ var scroll = Position.realOffset(container);
+ var scrollLeft = scroll[0] - (document.documentElement.scrollLeft || document.body.scrollLeft || 0);
+ var scrollTop = scroll[1] - (document.documentElement.scrollTop || document.body.scrollTop || 0);
+
+ var x = Event.pointerX(event) + scrollLeft;
+ var y = Event.pointerY(event) + scrollTop;
+
+ if (
+ offset[0] > x ||
+ (offset[0] + dimensions.width) < x ||
+ offset[1] > y ||
+ (offset[1] + dimensions.height) < y
+ ) {this.calendar.refreshSchedule(); return};
+
+ var left = parseInt(Element.getStyle(element, 'left'));
+ var weekIndex = Math.round(left / this.column.width);
+ var date = this.week[weekIndex];
+
+ if (
+ schedule.start.year == date.getFullYear() &&
+ schedule.start.month == date.getMonth() &&
+ schedule.start.day == date.getDate() &&
+ schedule.start.hour == time[0].hour &&
+ schedule.start.min == time[0].min &&
+ schedule.finish.year == date.getFullYear() &&
+ schedule.finish.month == date.getMonth() &&
+ schedule.finish.day == date.getDate() &&
+ schedule.finish.hour == time[1].hour &&
+ schedule.finish.min == time[1].min
+ ) {this.calendar.refreshSchedule(); return};
+
+ if (element.originalSchedule) schedule = element.originalSchedule;
+ var newStart = {
+ year: date.getFullYear(),
+ month: date.getMonth(),
+ day: date.getDate(),
+ hour: time[0].hour,
+ min: time[0].min
+ }
+ var diff = DateUtil.toDate(newStart).getTime() - DateUtil.toDate(schedule.start).getTime();
+ schedule.start = newStart;
+ schedule.finish = new Date(DateUtil.toDate(schedule.finish).getTime() + diff).toHash();
+
+ this.calendar.refreshSchedule();
+ this.calendar.options.changeSchedule(schedule);
+ },
+
+ updateTirm: function(element) {
+ var schedule = element.schedule;
+ var time = this.getTimeByElement(element);
+ this.calendar.cacheSchedule(schedule);
+
+ var left = parseInt(Element.getStyle(element, 'left'));
+ var weekIndex = Math.round(left / this.column.width);
+ var date = this.week[weekIndex];
+
+ var isChange = this.isChengeSchedule(element, time);
+ if (element.originalSchedule) schedule = element.originalSchedule;
+
+ if (isChange.start) {
+ schedule.start.year = date.getFullYear();
+ schedule.start.month = date.getMonth();
+ schedule.start.day = date.getDate();
+ schedule.start.hour = time[0].hour;
+ schedule.start.min = time[0].min;
+ } else if (isChange.finish) {
+ schedule.finish.year = date.getFullYear();
+ schedule.finish.month = date.getMonth();
+ schedule.finish.day = date.getDate();
+ schedule.finish.hour = time[1].hour;
+ schedule.finish.min = time[1].min;
+ } else {
+ return;
+ }
+
+ this.calendar.refreshSchedule();
+ this.calendar.options.updateTirm(schedule);
+ },
+
+ changeTimeDisplay: function(element) {
+ var schedule = element.schedule;
+ var time = this.getTimeByElement(element);
+
+ var textNode = Element.getElementsByClassName(element, Calendar.className.scheduleTimeArea)[0];
+ var text = this.getTimeText(time[0], time[1]);
+ textNode.innerHTML = text;
+ },
+
+ findClickedElement: function(event) {
+ var container = $(this.getScheduleContainerId());
+ var position = Position.cumulativeOffset(container);
+ var scrollTop = Position.realOffset(container).last();
+ scrollTop -= document.documentElement.scrollTop || document.body.scrollTop;
+ var x = Event.pointerX(event) - position[0];
+ var y = Event.pointerY(event) - position[1] + scrollTop;
+
+ var cellIndex = Math.floor(y / this.column.height);
+ var rowIndex = Math.floor(x / this.column.width);
+ return $(this.calendarTable.rows[0].cells[rowIndex]).down(cellIndex);
+ },
+
+ multipleSelection: function(event) {
+ if (!this.calendar.selectedBase || !this.calendar.mouseDown) return;
+ var self = this;
+ var calendar = this.calendar;
+ var selected = this.calendar.selectedBase;
+
+ this.abstractSelect(event, function(date, element) {
+ var selectedElement = $(selected.id);
+ if (selectedElement.date.getDate() != element.date.getDate()) return;
+
+ var nodes = $A(selectedElement.parentNode.childNodes);
+ var ids = [parseInt(selected.id.getSuffix()), parseInt(element.id.getSuffix())];
+ ids.sort(function(a, b) {return a - b;});
+
+ nodes.each(function(n) {
+ if (!n.id) throw $continue;
+ var id = parseInt(n.id.getSuffix());
+ if ((id < ids[0]) || (ids[1] < id)) {
+ calendar.removeSelectedClass(n);
+ } else if (!Element.hasClassName(n, Calendar.className.selected)) {
+ calendar.addSelectedClass(n);
+ }
+ });
+ });
+ },
+
+ getTimeByElement: function(element) {
+ var schedule = element.schedule;
+ var top = parseInt(Element.getStyle(element, 'top'), 10);
+ var height = parseInt(Element.getStyle(element, 'height'), 10);
+ var oneHour = this.column.height * 2;
+ var distance = 0.25;
+
+ var startTime = top / oneHour + this.startTime;
+ startTime = Math.round(startTime / distance) * distance;
+
+ var finishTime = height / oneHour + startTime;
+ finishTime = Math.round(finishTime / distance) * distance;
+
+ var start = {};
+ start.hour = Math.floor(startTime);
+ start.min = (startTime - start.hour) * 60;
+
+ var finish = {};
+ finish.hour = Math.floor(finishTime);
+ finish.min = (finishTime - finish.hour) * 60;
+
+ if (finish.min == 60) {
+ finish.hour += 1;
+ finish.min = 0;
+ }
+
+ return [start, finish];
+ },
+
+ getDateId: function(date, i) {
+ var id = this.calendar.element.id.appendSuffix(date.getDate());
+ return id.appendSuffix(i * 10);
+ },
+
+ dateIdToTime: function(id) {
+ id = id.getSuffix() / 10;
+ var hour = Math.floor(id);
+ return {hour: hour, min: (id - hour) * 60};
+ },
+
+ formatTime: function(date) {
+ var time = date.toTimeString();
+ time = time.split(' ');
+ time = time[0].split(':');
+ time.pop();
+ return time.join(':');
+ },
+
+ /**
+ * hours are 0, 0.5, 1, ..., 23.5, 24
+ */
+ includeDisplayTime: function(hours) {
+ return (this.startTime <= hours) && (hours < this.finishTime);
+ },
+
+ /**
+ * exsample
+ *
+ * {hour: 1, min: 30} => 1.5
+ */
+ convertHours: function(schedule) {
+ return [
+ schedule.start.hour + schedule.start.min / 60,
+ schedule.finish.hour + schedule.finish.min / 60
+ ];
+ },
+
+ setDisplayTime: function() {
+ this.startTime = this.calendar.options.displayTime.first().hour;
+ var finishTime = this.calendar.options.displayTime.last();
+ this.finishTime = Math.ceil(finishTime.hour + finishTime.min / 60);
+ },
+
+ getTimeText: function(start, finish) {
+ var calendar = this.calendar;
+ return calendar.formatTime(start) + ' - ' + calendar.formatTime(finish);
+ },
+
+ isChengeSchedule: function(scheduleElement, newTime) {
+ var schedule = scheduleElement.schedule;
+ var changeStart = ((schedule.start.hour != newTime[0].hour) || (schedule.start.min != newTime[0].min));
+ var changeFinish = ((schedule.finish.hour != newTime[1].hour) || (schedule.finish.min != newTime[1].min));
+
+ if (scheduleElement.originalSchedule) {
+ if (changeStart && changeFinish) {
+ var currentDateStart = DateUtil.toDate(schedule.start).getTime();
+ var OriginalDateStart = DateUtil.toDate(scheduleElement.originalSchedule.start).getTime();
+ if (currentDateStart == OriginalDateStart) {
+ changeFinish = false;
+ } else {
+ changeStart = false;
+ }
+ }
+ }
+ return {start: changeStart, finish: changeFinish};
+ }
+});
+
+
+/**
+ * CalendarDay Class
+ */
+var CalendarDay = Class.create();
+CalendarDay.id = {
+ header: 'dayHeader'
+}
+Object.extend(CalendarDay.prototype, CalendarWeek.prototype);
+Object.extend(CalendarDay.prototype, {
+
+ initialize: function(calendar) {
+ var day = calendar.date.getDay();
+ this.calendar = calendar;
+ this.setDisplayTime();
+
+ this.calendar.options.displayIndexesOld = this.calendar.options.displayIndexes;
+ this.calendar.options.displayIndexes = [day];
+ this.calendar.options.weekIndexOld = this.calendar.options.weekIndex;
+ this.calendar.options.weekIndex = day;
+ this.week = this.getWeek();
+ },
+
+ destroy: function() {
+ this.calendar.options.displayIndexes = this.calendar.options.displayIndexesOld;
+ this.calendar.options.weekIndex = this.calendar.options.weekIndexOld;
+ delete this.calendar.options.displayIndexesOld;
+ delete this.calendar.options.weekIndexOld;
+ },
+
+ /*** Day ***/
+ /********************************** build functions **********************************/
+ buildHeaderCenter: function() {
+ var headerText = this.calendar.date.toDateString();
+ if (this.calendar.options.dayHeaderFormat) {
+ var date = this.calendar.date;
+ headerText = new Template(this.calendar.options.dayHeaderFormat).evaluate(
+ {year: date.getFullYear(), month: date.getMonth() + 1, day: date.getDate()});
+ }
+ var container = Builder.node('TD');
+ this.calendar.classNames.addClassNames(container, 'years');
+
+ var id = this.calendar.element.id.appendSuffix(CalendarDay.id.header);
+ var node = Builder.node('SPAN', {id: id}, [headerText]);
+ this.calendar.classNames.addClassNames(node, 'ym');
+ container.appendChild(node);
+
+ return container;
+ },
+
+ /*** Day ***/
+ /********************************** private method **********************************/
+ changeCalendar: function(event) {
+ var element = Event.element(event);
+ var oldDate = new Date(this.calendar.date.toDateString());
+
+ if (Element.hasClassName(element, Calendar.className.preWeekMark)) {
+ this.calendar.date.setDate(this.calendar.date.getDate() - 1);
+ } else if (Element.hasClassName(element, Calendar.className.nextWeekMark)) {
+ this.calendar.date.setDate(this.calendar.date.getDate() + 1);
+ }
+
+ this.calendar.options.changeCalendar(this.calendar.date, oldDate);
+ this.calendar.refresh();
+ }
+});
+
+
+//
+// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var CalendarResizeableEx = Class.create();
+Object.extend(CalendarResizeableEx.prototype, Resizeable.prototype);
+Object.extend(CalendarResizeableEx.prototype, {
+ initialize: function(element) {
+ var options = Object.extend({
+ top: 6,
+ bottom: 6,
+ left: 6,
+ right: 6,
+ minHeight: 0,
+ minWidth: 0,
+ zindex: 1000,
+ resize: null,
+ distance: 1, // add by spinelz
+ change: Prototype.emptyFunction,
+ restriction: true
+ }, arguments[1] || {});
+
+ this.element = $(element);
+ this.handle = this.element;
+
+ Element.makePositioned(this.element); // fix IE
+
+ this.options = options;
+
+ this.active = false;
+ this.resizing = false;
+ this.currentDirection = '';
+
+ this.eventMouseDown = this.startResize.bindAsEventListener(this);
+ this.eventMouseUp = this.endResize.bindAsEventListener(this);
+ this.eventMouseMove = this.update.bindAsEventListener(this);
+ this.eventCursorCheck = this.cursor.bindAsEventListener(this);
+ this.eventKeypress = this.keyPress.bindAsEventListener(this);
+
+ this.registerEvents();
+ },
+
+ startResize: function(event) {
+ Event.stop(event);
+ if(Event.isLeftClick(event)) {
+
+ // abort on form elements, fixes a Firefox issue
+ var src = Event.element(event);
+ if(src.tagName && (
+ src.tagName=='INPUT' ||
+ src.tagName=='SELECT' ||
+ src.tagName=='BUTTON' ||
+ src.tagName=='TEXTAREA')) return;
+
+ var dir = this.directions(event);
+ if (dir.length > 0) {
+ this.active = true;
+// var offsets = Position.cumulativeOffset(this.element);
+ this.startTop = parseInt(Element.getStyle(this.element, 'top'), 10);
+ this.startLeft = parseInt(Element.getStyle(this.element, 'left'), 10);
+ this.startWidth = parseInt(Element.getStyle(this.element, 'width'), 10);
+ this.startHeight = parseInt(Element.getStyle(this.element, 'height'), 10);
+ this.startX = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
+ this.startY = event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
+
+ this.currentDirection = dir;
+
+ if (this.options.restriction) {
+ var container = this.element.parentNode;
+ this.restDimensions = Element.getDimensions(container);
+ this.restOffset = Position.cumulativeOffset(container);
+ }
+ }
+ }
+ },
+
+ draw: function(event) {
+ Event.stop(event);
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var style = this.element.style;
+
+ if (this.currentDirection.indexOf('n') != -1) {
+ if (this.restOffset[1] >= pointer[1]) return;
+ var pointerMoved = this.startY - pointer[1];
+// var margin = Element.getStyle(this.element, 'margin-top') || "0";
+ var newHeight = this.map(this.startHeight + pointerMoved);
+ if (newHeight > this.options.minHeight) {
+ style.height = newHeight + "px";
+ style.top = this.map(this.startTop - pointerMoved) + "px";
+ }
+ }
+ if (this.currentDirection.indexOf('w') != -1) {
+ var pointerMoved = this.map(this.startX - pointer[0]);
+ var margin = Element.getStyle(this.element, 'margin-left') || "0";
+ var newWidth = this.startWidth + pointerMoved;
+ if (newWidth > this.options.minWidth) {
+ style.left = (this.startLeft - pointerMoved - parseInt(margin)) + "px";
+ style.width = newWidth + "px";
+ }
+ }
+ if (this.currentDirection.indexOf('s') != -1) {
+ var bottom = this.restDimensions.height + this.restOffset[1];
+ var pointerMoved = pointer[1] - this.startY;
+ if (bottom <= pointer[1]) return;
+ var newHeight = this.map(this.startHeight + pointer[1] - this.startY);
+ if (newHeight > this.options.minHeight) {
+ style.height = newHeight + "px";
+// style.top = this.startTop + "px";
+ }
+ }
+ if (this.currentDirection.indexOf('e') != -1) {
+ var newWidth = this.map(this.startWidth + pointer[0] - this.startX);
+ if (newWidth > this.options.minWidth) {
+ style.width = newWidth + "px";
+ }
+ }
+ if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
+ this.options.change(this.element);
+ },
+
+ directions: function(event) {
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var offsets = Position.cumulativeOffset(this.element);
+ var bodyScrollTop = document.documentElement.scrollTop || document.body.scrollTop;
+ var scroll = Position.realOffset(this.element)[1] - bodyScrollTop;
+
+ var cursor = '';
+ if (this.between(pointer[1] - offsets[1] + scroll, 0, this.options.top)) cursor += 'n';
+ if (this.between((offsets[1] + this.element.offsetHeight) - pointer[1] - scroll, 0, this.options.bottom)) cursor += 's';
+ if (this.between(pointer[0] - offsets[0], 0, this.options.left)) cursor += 'w';
+ if (this.between((offsets[0] + this.element.offsetWidth) - pointer[0], 0, this.options.right)) cursor += 'e';
+
+ return cursor;
+ },
+
+ map: function(length) {
+ return Math.round(length / this.options.distance) * this.options.distance;
+ }
+});
--- /dev/null
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var DatePicker = Class.create();
+DatePicker.className = {
+ container: 'datepicker',
+ header: 'datepicker_header',
+ footer: 'datepicker_footer',
+ preYears: 'datepicker_preYears',
+ nextYears: 'datepicker_nextYears',
+ years: 'datepicker_years',
+ calendar: 'datepicker_calendar',
+ date: 'datepicker_date',
+ holiday: 'datepicker_holiday',
+ ym: 'datepicker_ym',
+ table: 'datepicker_table',
+ tableTh: 'datepicker_tableTh',
+ nextMonthMark: 'datepicker_nextMonthMark',
+ nextYearMark: 'datepicker_nextYearMark',
+ preMonthMark: 'datepicker_preMonthMark',
+ preYearMark: 'datepicker_preYearMark',
+ zIndex: null
+}
+DatePicker.prototype = {
+
+ initialize: function(element, target, trigger) {
+ this.element = $(element);
+ Element.setStyle(this.element, {visibility: 'hidden'});
+ this.target = $(target);
+ this.date = new Date();
+
+ this.options = Object.extend({
+ month: this.date.getMonth() + 1,
+ date: this.date.getDate(),
+ year: this.date.getFullYear(),
+ format: DateUtil.toLocaleDateString,
+ cssPrefix: 'custom_',
+ callBack: Prototype.emptyFunction,
+ standTo: false,
+ beforeShow: Prototype.emptyFunction,
+ headerFormat: null,
+ dayOfWeek: DateUtil.dayOfWeek
+ }, arguments[3] || {});
+
+ var customCss = CssUtil.appendPrefix(this.options.cssPrefix, DatePicker.className);
+ this.classNames = new CssUtil([DatePicker.className, customCss]);
+
+ this.format = this.options.format;
+ this.callBack = this.options.callBack;
+
+ this.date.setMonth(this.options.month - 1);
+ this.date.setDate(this.options.date);
+ this.date.setFullYear(this.options.year);
+
+ this.calendar = this.build();
+ this.element.appendChild(this.calendar);
+ this.cover = new IECover(this.element);
+
+ this.doclistener = this.hide.bindAsEventListener(this);
+ Event.observe($(trigger), "click", this.show.bindAsEventListener(this));
+ this.hide();
+ Element.setStyle(this.element, {visibility: 'visible'});
+ },
+
+ build: function() {
+ var node =
+ Builder.node(
+ 'DIV',
+ {className: this.classNames.joinClassNames('container')},
+ [
+ this.buildHeader(),
+ this.buildCalendar(),
+ this.buildFooter()
+ ]);
+
+ return node;
+ },
+
+ buildHeader: function() {
+ var headerNodes = Builder.node('TR');
+ headerNodes.appendChild(this.buildHeaderLeft());
+ headerNodes.appendChild(this.buildHeaderCenter());
+ headerNodes.appendChild(this.buildHeaderRight());
+
+ className = this.classNames.joinClassNames('header');
+ var tbody = Builder.node('TBODY', [headerNodes]);
+ return Builder.node('TABLE', {className: className}, [tbody]);
+ },
+
+ buildFooter: function() {
+ var footer = Builder.node('DIV');
+ this.classNames.addClassNames(footer, 'footer');
+ return footer;
+ },
+
+ buildHeaderLeft: function() {
+ var container = Builder.node('TD');
+ this.classNames.addClassNames(container, 'preYears');
+
+ var id = this.element.id.appendSuffix('preYear');
+ var node = Builder.node('DIV', {id: id});
+ this.classNames.addClassNames(node, 'preYearMark');
+ Event.observe(node, "click", this.changeCalendar.bindAsEventListener(this));
+ container.appendChild(node);
+
+ id = this.element.id.appendSuffix('preMonth');
+ node = Builder.node('DIV', {id: id});
+ this.classNames.addClassNames(node, 'preMonthMark');
+ Event.observe(node, "click", this.changeCalendar.bindAsEventListener(this));
+ container.appendChild(node);
+
+ return container;
+ },
+
+ buildHeaderCenter: function() {
+ var contents = [];
+ var yearMonth = this.getHeaderYearMonth();
+
+ var id = this.element.id.appendSuffix('nextMonth');
+ var node = Builder.node('SPAN', {id: id}, [yearMonth[0]]);
+ this.classNames.addClassNames(node, 'ym');
+ contents.push(node);
+
+ id = this.element.id.appendSuffix('nextYear');
+ node = Builder.node('SPAN', {id: id}, [yearMonth[1]]);
+ this.classNames.addClassNames(node, 'ym');
+ contents.push(node);
+
+ var container = Builder.node('TD', contents);
+ this.classNames.addClassNames(container, 'years');
+
+ return container;
+ },
+
+ getHeaderYearMonth: function() {
+ if (this.options.headerFormat) {
+ var tmpl = new Template(this.options.headerFormat);
+ return [tmpl.evaluate({year: this.date.getFullYear(), month: this.date.getMonth() + 1}), ' '];
+ }
+ return [DateUtil.months[this.date.getMonth()], this.date.getFullYear()];
+ },
+
+ buildHeaderRight: function() {
+ var container = Builder.node('TD');
+ this.classNames.addClassNames(container, 'nextYears');
+
+ var id = this.element.id.appendSuffix('nextMonth');
+ var node = Builder.node('DIV', {id: id});
+ this.classNames.addClassNames(node, 'nextMonthMark');
+ Event.observe(node, "click", this.changeCalendar.bindAsEventListener(this));
+ container.appendChild(node);
+
+ id = this.element.id.appendSuffix('nextYear');
+ node = Builder.node('DIV', {id: id});
+ this.classNames.addClassNames(node, 'nextYearMark');
+ Event.observe(node, "click", this.changeCalendar.bindAsEventListener(this));
+ container.appendChild(node);
+
+ return container;
+ },
+
+ multiBuild: function(tagType, params, className, hover, clickEvent) {
+ var children = [];
+ for (var i = 0; i < params.length; i++) {
+ var node;
+
+ node = Builder.node(tagType, [params[i]]);
+ if (className)
+ this.classNames.addClassNames(node, className);
+
+ if (hover)
+ new Hover(node);
+
+ if (clickEvent)
+ Event.observe(node, "click", clickEvent.bindAsEventListener(this));
+
+ children.push(node);
+ }
+
+ return children;
+ },
+
+ buildCalendar: function() {
+ var className = this.classNames.joinClassNames('table');
+ var node = Builder.node('TBODY', [this.buildTableHeader(), this.buildTableData()]);
+ var table = Builder.node('TABLE', {className: className}, [node]);
+
+ className = this.classNames.joinClassNames('calendar');
+ return Builder.node('DIV', {className: className}, [table]);
+ },
+
+ buildTableHeader: function() {
+ var weekArray = new Array();
+ var className = this.classNames.joinClassNames('tableTh');
+ for (var i = 0; i < DateUtil.dayOfWeek.length; i++) {
+ weekArray.push(
+ Builder.node('TH', {className: className}, [this.options.dayOfWeek[i]]));
+ }
+
+ return Builder.node('TR', weekArray);
+ },
+
+ buildTableData: function() {
+ var length = DateUtil.dayOfWeek.length * 6;
+ var year = this.date.getFullYear();
+ var month = this.date.getMonth();
+ var firstDay = DateUtil.getFirstDate(year, month).getDay();
+ var lastDate = DateUtil.getLastDate(year, month).getDate();
+ var trs = new Array();
+ var tds = new Array();
+
+ for (var i = 0, day = 1; i <= length; i++) {
+ if ((i < firstDay) || day > lastDate) {
+ tds.push(Builder.node('TD'));
+
+ } else {
+ var className;
+ if ((i % 7 == 0) || ((i+1) % 7 == 0))
+ className = 'holiday';
+ else
+ className = 'date';
+
+ var defaultClass = this.classNames.joinClassNames(className);
+ node = Builder.node('TD', {className: defaultClass}, [day]);
+ new Hover(node);
+ Event.observe(node, "click", this.selectDate.bindAsEventListener(this));
+ tds.push(node);
+ day++;
+ }
+
+ if ((i + 1) % 7 == 0) {
+ trs.push(Builder.node('TR', tds));
+ tds = new Array();
+ }
+ }
+
+ return trs;
+ },
+
+ refresh: function() {
+ this.element.innerHTML = '';
+ this.calendar = this.build();
+ this.element.appendChild(this.calendar);
+ new IECover(this.element);
+ },
+
+ getMonth: function() {
+ return DateUtil.months[this.date.getMonth()];
+ },
+
+ changeCalendar: function(event) {
+ var element = Event.element(event);
+ if (Element.hasClassName(element, DatePicker.className.preYearMark)) {
+ this.date.setFullYear(this.date.getFullYear() - 1);
+ } else if (Element.hasClassName(element, DatePicker.className.nextYearMark)) {
+ this.date.setFullYear(this.date.getFullYear() + 1);
+ } else if (Element.hasClassName(element, DatePicker.className.preMonthMark)) {
+ var pre = this.date.getMonth() - 1;
+ if (pre < 0) {
+ pre = 11;
+ this.date.setFullYear(this.date.getFullYear() - 1);
+ }
+ this.date.setMonth(pre);
+ } else if (Element.hasClassName(element, DatePicker.className.nextMonthMark)) {
+ var next = this.date.getMonth() + 1;
+ if (next > 11) {
+ next = 0;
+ this.date.setFullYear(this.date.getFullYear() + 1);
+ }
+ this.date.setMonth(next);
+ }
+
+ this.refresh();
+ if (event) Event.stop(event);
+ },
+
+ selectDate: function(event) {
+ var src = Event.element(event);
+ var text = Element.getTextNodes(src)[0];
+
+ this.date.setDate(text.nodeValue);
+ var value = this.formatDateString();
+
+ if (this.target.value || this.target.value == '') {
+ this.target.value = value;
+ } else {
+ this.target.innerHTML = value;
+ }
+
+ this.hide();
+ this.classNames.refreshClassNames(src, 'date');
+
+ this.callBack(this);
+ },
+
+ show: function(event) {
+ var styles = $H({zIndex: ZindexManager.getIndex(this.options.zIndex)});
+ if (this.options.standTo) {
+ this.defaultParent = this.element.parentNode;
+ document.body.appendChild(this.element);
+ styles = styles.merge({
+ position: 'absolute',
+ left: Event.pointerX(event) + 'px',
+ top: Event.pointerY(event) + 'px'
+ });
+ }
+
+ Element.setStyle(this.element, styles);
+ Element.show(this.element);
+ this.cover.resetSize();
+ Event.observe(document, "click", this.doclistener);
+ if (event) {
+ Event.stop(event);
+ }
+ },
+
+ hide: function() {
+ Event.stopObserving(document, "click", this.doclistener);
+ Element.hide(this.element);
+ if (this.defaultParent) {
+ this.defaultParent.appendChild(this.element);
+ }
+ },
+
+ addTrigger: function(trigger) {
+ Event.observe($(trigger), 'click', this.show.bindAsEventListener(this));
+ },
+
+ changeTarget: function(target) {
+ this.target = $(target);
+ },
+
+ formatDateString: function() {
+ var string = '';
+ if (this.format.constructor == Function) {
+ string = this.format(this.date);
+ } else if (this.format.constructor == String) {
+ string = this.date.strftime(this.format);
+ }
+ return string;
+ }
+}
--- /dev/null
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Grid = Class.create();
+Grid.className = {
+ container: 'grid_container',
+
+ baseTable: 'grid_baseTable',
+ baseRow: 'grid_baseRow',
+ baseCell: 'grid_baseCell',
+
+ headerTable: 'grid_headerTable',
+ headerRow: 'grid_headerRow',
+ headerCell: 'grid_headerCell',
+ headerCellDrag: 'grid_headerCellDrag',
+ headerCellSort: 'grid_headerCellVal',
+
+ idTable: 'grid_idTable',
+ idRow: 'grid_idRow',
+ idCell: 'grid_idCell',
+ idCellVal: 'grid_idCellVal',
+
+ cellTable: 'grid_cellTable',
+ cellTbody: 'grid_cellTbody',
+ cellRow: 'grid_cellRow',
+ cell: 'grid_cell',
+ cellVal: 'grid_cellVal',
+ cellSelected: 'grid_cellSelected',
+ state: 'grid_state',
+ stateEmpty: 'grid_stateEmpty',
+ stateOpen: 'grid_stateOpen',
+ stateClose: 'grid_stateClose',
+
+ inplaceEditor: 'grid_inplaceEditor'
+}
+Grid.scrollTop = 0;
+Grid.scrollLeft = 0;
+Grid.options = {}
+Grid.options.baseTable = {
+ border:1,
+ frame : 'border',
+ cellSpacing:0,
+ cellPadding:0
+}
+Grid.options.headerTable = {
+ border:1,
+ frame : 'border',
+ cellSpacing:0,
+ cellPadding:0
+}
+Grid.options.idTable = {
+ border:1,
+ frame : 'border',
+ cellSpacing:0,
+ cellPadding:0
+}
+Grid.options.cellTable = {
+ border:1,
+ frame : 'border',
+ cellSpacing:0,
+ cellPadding:0
+}
+Grid.prototype = {
+
+ initialize : function(element) {
+
+ this.element = $(element);
+ Element.setStyle(this.element, {visibility: 'hidden'});
+ Element.hide(this.element);
+
+ var options = Object.extend({
+ cssPrefix: 'custum_',
+ cellMinWidth: 10,
+ cellMinHeight: 10,
+ cellDefaultWidth: 72,
+ cellDefaultHeight: 25,
+ defaultRowLength: 10,
+ baseWidth: 40,
+ baseHeight: 25,
+ baseTop: 0,
+ baseLeft: 0,
+ cellEditUrl: '',
+ updateGridUrl: '',
+ updateGridReceiver: '',
+ hierarchy: false,
+ hierarchyCol: false,
+ hierarchyIndent: 20,
+ sortOptions: {}
+ }, arguments[1] || {});
+
+ this.options = options;
+ this.custumCss = CssUtil.appendPrefix(options.cssPrefix, Grid.className);
+ this.cssUtil = new CssUtil([Grid.className, this.custumCss]);
+ this.cssUtil.addClassNames(this.element, 'container');
+ this.hierarchyCol = this.options.hierarchyCol ? $(this.options.hierarchyCol) : false;
+ this.hierarchyColIndex = this.hierarchyCol ? this.hierarchyCol.cellIndex : 0;
+ Element.makePositioned(this.element);
+ Position.includeScrollOffsets = true;
+ this.stateDivWidth = parseInt(CssUtil.getCssRuleBySelectorText('.' + Grid.className.state).style.width, 10);
+
+ this.marginSize = this.options.marginSize ? this.options.marginSize : 4;
+ this.stateIndent = 15;
+
+ this.rowIdBase = this.element.id + '_row_';
+ this.topLevelList = new Array();
+ this.removeList = new Array();
+ this.build();
+ this.removeList.each(function(r) {
+ r.parentNode.removeChild(r);
+ });
+ var sortOptions = {
+ relate : this.idTable,
+ handle:this.headerTable,
+ callBack:this.finishSort.bind(this)
+ };
+ sortOptions = $H(sortOptions).merge(this.options.sortOptions);
+ this.sortTable = new SortableTableGridEx(this.cellTable, sortOptions);
+ Element.setStyle(this.element, {visibility: 'visible'});
+ Element.show(this.element);
+ },
+
+ build: function() {
+ Element.cleanWhitespace(this.element);
+ this.cellTable = this.element.childNodes[0];
+ Element.cleanWhitespace(this.cellTable);
+
+ this.colLength = this.cellTable.tHead.rows[0].cells.length;
+ this.rowLength = this.cellTable.tBodies[0].rows.length;
+ if (this.rowLength == 0)this.rowLength = this.options.defaultRowLength;
+ this.buildBaseTable();
+ this.buildHeaderTable();
+ this.buildIdTable();
+ this.buildCellTable();
+
+ Event.observe(this.element, 'scroll', this.fixTablePosition.bindAsEventListener(this));
+ },
+
+ buildBaseTable: function() {
+
+ this.baseTable = Builder.node('table', Grid.options.baseTable);
+ this.cssUtil.addClassNames(this.baseTable, 'baseTable');
+ with (this.baseTable.style) {
+ width = this.options.baseWidth + 'px';
+ height = this.options.baseHeight + 'px';
+ position = 'absolute';
+ top = this.options.baseTop + 'px';
+ left = this.options.baseLeft + 'px';
+ }
+
+ var row = this.baseTable.insertRow(0);
+ var cell = row.insertCell(0);
+
+ this.cssUtil.addClassNames(row, 'baseRow');
+ this.cssUtil.addClassNames(cell, 'baseCell');
+
+ this.element.appendChild(this.baseTable);
+ },
+
+ buildHeaderTable: function() {
+ this.headerTable = Builder.node('table', Grid.options.headerTable);
+ this.cssUtil.addClassNames(this.headerTable, 'headerTable');
+
+ var thead = this.cellTable.tHead;
+ var row = thead.rows[0];
+ row.id = this.element.id + '_headerTable_row';
+ var cells = row.cells;
+ Element.cleanWhitespace(thead);
+ Element.cleanWhitespace(row);
+
+ this.cssUtil.addClassNames(row, 'headerRow');
+ for (var i = 0; i < cells.length; i++) {
+ var cell = cells[i];
+ var value = cell.firstChild;
+ var title = cell.innerHTML;
+ this.buildHeaderCell(cell, title, i);
+ this.removeList.push(value);
+ }
+ this.headerTable.appendChild(thead);
+ with (this.headerTable.style) {
+ width = this.options.cellDefaultWidth * this.colLength + 'px';
+ height = this.baseTable.style.height;
+ position= 'absolute';
+ top = Element.getStyle(this.baseTable, 'top');
+ left = parseInt(Element.getStyle(this.baseTable, 'left')) + parseInt(Element.getStyle(this.baseTable, 'width')) + 'px';
+ }
+ this.element.appendChild(this.headerTable);
+ Sortable.create(
+ row,
+ {
+ tag:'td',
+ handle:Grid.className.headerCellDrag,
+ constraint:true,
+ overlap:'horizontal',
+ scroll:this.element,
+ onUpdate:this.updateCellLine.bind(this)
+ });
+ },
+
+ buildHeaderCell : function(cell, title, index) {
+
+ cell.id = this.element.id + '_header_col_' + index;
+
+ var drag = Builder.node('div');
+ var sort = Builder.node('div');
+
+ this.cssUtil.addClassNames(cell, 'headerCell');
+ this.cssUtil.addClassNames(drag, 'headerCellDrag');
+ this.cssUtil.addClassNames(sort, 'headerCellSort');
+
+ cell.style.width = this.options.cellDefaultWidth + 'px';
+ var dragWidth = parseInt(Element.getStyle(cell, 'width')) - (this.marginSize * 2);
+ var sortWidth = dragWidth - (this.marginSize * 2);
+ var cellHeight = this.options.baseHeight - (Grid.options.headerTable.border * 4);
+ with (drag.style) {
+ width = dragWidth + 'px';
+ height = cellHeight + 'px';
+ marginLeft = this.marginSize + 'px';
+ marginRight = this.marginSize + 'px';
+ }
+ with (sort.style) {
+ width = sortWidth + 'px';
+ height = cellHeight + 'px';
+ marginLeft = this.marginSize + 'px';
+ marginRight = this.marginSize + 'px';
+ }
+
+ sort.innerHTML = title;
+ drag.appendChild(sort);
+ cell.appendChild(drag);
+
+ new ResizeableGridEx(cell, {minWidth: this.options.cellMinWidth, top:0,right:2, bottom:0, left:0 ,draw:this.updateCellWidth.bind(this)});
+ Event.observe(cell, 'mousedown', this.setSelectedColumn.bindAsEventListener(this));
+ Event.observe(drag, 'mousedown', this.setSelectedColumn.bindAsEventListener(this));
+ Event.observe(sort, 'mousedown', this.setSelectedColumn.bindAsEventListener(this));
+ },
+
+ buildIdTable: function() {
+
+ this.idTable = Builder.node('table', Grid.options.idTable);
+ this.cssUtil.addClassNames(this.idTable, 'idTable');
+ for (var i = 0; i < this.rowLength; i++) {
+
+ var row = this.idTable.insertRow(i);
+ this.buildIdRow(row, i);
+ }
+
+ with(this.idTable.style) {
+ width = this.options.baseWidth + 'px';
+ position = 'absolute';
+ top = parseInt(Element.getStyle(this.baseTable, 'top')) + parseInt(Element.getStyle(this.baseTable, 'height')) + 'px';
+ left = Element.getStyle(this.baseTable, 'left');
+ }
+
+ this.element.appendChild(this.idTable);
+ var tbody = this.idTable.tBodies[0];
+ tbody.id = this.element.id + '_idTable_tbody';
+ Sortable.create(
+ tbody,
+ {
+ tag:'tr',
+ handle:Grid.className.idCellVal,
+ scroll:this.element,
+ constraint:true,
+ overlap:'vertical',
+ onUpdate:this.updateRowLine.bind(this)
+ });
+ },
+
+ buildIdRow : function(row, index) {
+ row.id = this.rowIdBase + '_id_' + index;
+
+ var cell = row.insertCell(0);
+ var valueDiv = Builder.node('div');
+
+ this.cssUtil.addClassNames(row, 'idRow');
+ this.cssUtil.addClassNames(cell, 'idCell');
+ this.cssUtil.addClassNames(valueDiv, 'idCellVal');
+
+ with (cell.style) {
+ width = this.options.baseWidth + 'px';
+ height = this.options.cellDefaultHeight + 'px';
+ }
+ with (valueDiv.style) {
+ marginTop = this.marginSize + 'px';
+ marginBottom = this.marginSize + 'px';
+ width = this.options.baseWidth - (Grid.options.idTable.border * 4) + 'px';
+ height = this.options.cellDefaultHeight - (this.marginSize * 2) + 'px';
+ }
+
+ valueDiv.innerHTML = index + 1;
+ cell.appendChild(valueDiv);
+
+ new ResizeableGridEx(cell, {minHeight: this.options.cellMinHeight, top:0, right: 0, bottom: 2, left: 0, draw:this.updateCellHeight.bind(this)});
+
+ Event.observe(row, 'mousedown', this.setSelectedRow.bindAsEventListener(this));
+ Event.observe(cell, 'mousedown', this.setSelectedRow.bindAsEventListener(this));
+ Event.observe(valueDiv, 'mousedown', this.setSelectedRow.bindAsEventListener(this));
+ },
+
+ buildCellTable: function() {
+ var tbody = this.cellTable.tBodies[0];
+ Element.cleanWhitespace(tbody);
+ with(this.cellTable){
+ border = Grid.options.cellTable.border;
+ cellSpacing = Grid.options.cellTable.cellSpacing;
+ cellPadding = Grid.options.cellTable.cellPadding;
+ }
+ this.cssUtil.addClassNames(this.cellTable, 'cellTable');
+ this.cssUtil.addClassNames(tbody, 'cellTbody');
+ this.element.appendChild(this.cellTable);
+ var rows = this.cellTable.rows;
+
+ if (!rows || rows.length == 0) {
+ for(var i = 0; i < this.rowLength; i++) {
+
+ var newRow = this.cellTable.insertRow(i);
+ newRow.id = this.rowIdBase + i;
+ this.cssUtil.addClassNames(newRow, 'cellRow');
+
+ for (var j = 0; j < this.colLength; j++) {
+ var newCell = newRow.insertCell(j);
+ this.buildCell(newCell, j, "");
+ }
+ if (this.options.hierarchy) {
+ this.setHierarchyRow(newRow);
+ }
+ }
+
+ } else {
+ for (var i = 0; i < this.rowLength; i++) {
+ var row = rows[i];
+ Element.cleanWhitespace(row);
+ this.cssUtil.addClassNames(row, 'cellRow');
+ row.id = this.rowIdBase + i;
+ var cells = row.cells;
+
+ for (var j = 0; j < cells.length; j++) {
+ var cell = cells[j];
+ Element.cleanWhitespace(cell);
+ this.buildCell(cell, j, Element.collectTextNodes(cell));
+ this.removeList.push(cell.firstChild);
+ }
+ if (this.options.hierarchy) {
+ this.setHierarchyRow(row);
+ }
+ }
+ }
+
+ with (this.cellTable.style) {
+ width = this.options.cellDefaultWidth * this.colLength + 'px';
+ position = 'absolute';
+ top = parseInt(Element.getStyle(this.baseTable, 'top')) + parseInt(Element.getStyle(this.baseTable, 'height')) + 'px';
+ left = parseInt(Element.getStyle(this.baseTable, 'left')) + parseInt(Element.getStyle(this.baseTable, 'width')) + 'px';
+ }
+
+ this.cellTable.getIdRow = this.getIdRow.bind(this);
+ },
+
+ buildCell : function(cell, cellIdIndex, value) {
+
+ var cellValueDiv = Builder.node('div');
+ cellValueDiv.innerHTML = value;
+
+ cell.appendChild(cellValueDiv);
+ cell.id = cell.parentNode.id + '_col_' + cellIdIndex;
+
+ this.cssUtil.addClassNames(cell, 'cell');
+ this.cssUtil.addClassNames(cellValueDiv, 'cellVal');
+
+ with (cell.style) {
+ width = Element.getStyle(this.getHeaderCell(cell), 'width');
+ height = Element.getStyle(this.getIdRow(cell.parentNode).cells[0], 'height');
+ }
+ with (cellValueDiv.style) {
+ width = cell.style.width;
+ height = cell.style.height;
+ marginTop = '0px';
+ marginBottom = '0px';
+ }
+
+ Event.observe(cell, 'click', this.setSelectedCell.bindAsEventListener(this));
+
+ var ajax = new Ajax.InPlaceEditor(cellValueDiv, this.options.cellEditUrl,
+ {
+ formClassName: this.cssUtil.joinClassNames('inplaceEditor'),
+ rows: 2,
+ cols:12,
+ okButton: false,
+ cancelLink:false,
+ submitOnBlur:true,
+ hoverClassName: "cellHover",
+ highlightcolor: "#becfeb",
+ highlightendcolor: "#becfeb",
+ onComplete: this.showStateDiv.bind(this),
+ callback : this.createInplaceEditorParams.bind(this),
+ formId : cell.id + '_form'
+ }
+ );
+ cellValueDiv.ajax = ajax;
+ Event.stopObserving(cellValueDiv, 'click', ajax.onclickListener);
+ Event.stopObserving(cellValueDiv, 'mouseover', ajax.mouseoverListener);
+ Event.stopObserving(cellValueDiv, 'mouseout', ajax.mouseoutListener);
+
+
+ Event.observe(cellValueDiv, 'dblclick', this.setTextAreaSize.bindAsEventListener(this));
+ if (this.options.hierarchy && cell.cellIndex == this.hierarchyColIndex) {
+ Event.observe(cellValueDiv, 'dblclick', this.hideStateDiv.bindAsEventListener(this));
+ }
+ Event.observe(cellValueDiv, 'dblclick', ajax.onclickListener);
+
+ },
+
+ addColumn: function(index, colTitle, values) {
+ var headerRow = this.headerTable.rows[0];
+ var insertIndex = (!isNaN(index)) ? index : this.colLength;
+ var colIdIndex = this.colLength;
+ var headerCell = headerRow.insertCell(insertIndex);
+ this.buildHeaderCell(headerCell, colTitle, insertIndex);
+
+ var rows = this.cellTable.rows;
+ var idRows = this.idTable.rows;
+ for (var i = 0; i < rows.length; i++) {
+
+ var cell = rows[i].insertCell(insertIndex);
+ var cellValue = "";
+ if (values && values[i]) {
+ cellValue = values[i];
+ }
+ this.buildCell(cell, colIdIndex, cellValue);
+ }
+
+ this.headerTable.style.width = parseInt(Element.getStyle(this.headerTable, 'width')) + this.options.cellDefaultWidth + 'px';
+ this.cellTable.style.width = this.headerTable.style.width;
+
+ var sortableOptions = Sortable.options(headerRow);
+
+ sortableOptions.draggables.push(
+ new Draggable(
+ headerCell,
+ {
+ revert: true,
+ constraint: true,
+ scroll: this.element,
+ handle: Element.getElementsByClassName(headerCell, Grid.className.headerCellDrag)[0]
+ }
+ )
+ );
+ Droppables.add(headerCell, {overlap:'horizontal', containment:headerRow, onHover:Sortable.onHover, greedy:true});
+ sortableOptions.droppables.push(headerCell);
+ this.sortTable.addEvent(Element.getElementsByClassName(headerCell, Grid.className.headerCellSort)[0]);
+ this.colLength += 1;
+ },
+
+ deleteColumn : function(index) {
+ if((isNaN(index)) || index >= this.colLength) {
+ return;
+ }
+ var headerRow = this.headerTable.rows[0];
+ if (!headerRow) return;
+ var headerCell = headerRow.cells[index];
+ if (!headerCell) return;
+
+ var width = headerCell.offsetWidth;
+ var rows = this.cellTable.rows;
+ headerRow.deleteCell(index);
+
+ for (var i = 0; i < rows.length; i++) {
+ rows[i].deleteCell(index);
+ }
+
+ var headerTableWidth = parseInt(Element.getStyle(this.headerTable, 'width')) - width;
+
+ this.headerTable.style.width = headerTableWidth >= 0 ? headerTableWidth + 'px' : '0px';
+ this.cellTable.style.width = this.headerTable.style.width;
+ this.colLength -= 1;
+ this.fixTablePosition();
+ },
+
+ addRow : function(index, values) {
+ var insertIndex = (!isNaN(index)) ? index : this.idTable.rows.length;
+ var rowIdIndex = this.idTable.rows.length;
+ var idRow = this.idTable.insertRow(index);
+ idRow.id = this.rowIdBase + '_id_' + rowIdIndex;
+ this.buildIdRow(idRow, rowIdIndex);
+ this.updateId();
+
+ var cellRow = this.cellTable.insertRow(insertIndex);
+ cellRow.id = this.rowIdBase + rowIdIndex;
+ this.cssUtil.addClassNames(cellRow, 'cellRow');
+ var headerCells = this.headerTable.rows[0].cells;
+
+ for (var i = 0; i < headerCells.length; i++) {
+ var headerCell = headerCells[i];
+ var colIdIndex = headerCell.id.substring(headerCell.id.indexOf('_col_',0) + '_col_'.length);
+ var cell = cellRow.insertCell(i);
+ var cellValue = (values && values[i]) ? values[i] : "";
+ this.buildCell(cell, colIdIndex, cellValue);
+ }
+
+ this.sortTable.defaultOrder.insert(index, cellRow);
+
+ var idTbody = this.idTable.tBodies[0];
+ var sortableOptions = Sortable.options(idTbody);
+
+ sortableOptions.draggables.push(
+ new Draggable(
+ idRow,
+ {
+ revert: true,
+ constraint: true,
+ scroll: this.element,
+ handle: Element.getElementsByClassName(idRow, Grid.className.idCellVal)[0]
+ }
+ )
+ );
+ Droppables.add(idRow, {overlap:'vertical', containment:idTbody, onHover:Sortable.onHover, greedy:true});
+ sortableOptions.droppables.push(idRow);
+ this.rowLength += 1;
+ return cellRow;
+ },
+
+ deleteRow : function(index) {
+ if(isNaN(index) || index >= this.rowLength) {
+ return;
+ }
+
+ var targetId = null;
+ if (this.cellTable.rows[index])
+ targetId = this.cellTable.rows[index].id;
+ else
+ return;
+
+ this.sortTable.defaultOrder.reverse();
+ var newOrder = new Array();
+
+ for (var i = 0; this.sortTable.defaultOrder.length > 0; i++) {
+ var row = this.sortTable.defaultOrder.pop();
+ if (row.id == targetId) {
+ continue;
+ }
+ newOrder.push(row);
+ }
+
+ this.sortTable.defaultOrder = newOrder;
+ this.idTable.deleteRow(index);
+ this.cellTable.deleteRow(index);
+
+ this.fixTablePosition();
+ this.rowLength -= 1;
+ this.updateId();
+ },
+
+ getHeaderCell : function(cell) {
+ return this.headerTable.rows[0].cells[cell.cellIndex];
+ },
+
+ getCells : function(index) {
+ var rows = this.cellTable.rows;
+ var columns = new Array();
+ for (var i = 0; i < rows.length; i++){
+ columns.push(rows[i].cells[index]);
+ }
+ return columns;
+ },
+
+ getRow : function(index) {
+ return this.cellTable.rows[index];
+ },
+
+ getIdRow : function(cellRow) {
+ var id = cellRow.id;
+ var index = id.substring(this.rowIdBase.length);
+ var targetRow = $(this.rowIdBase + '_id_' + index);
+ return targetRow;
+ },
+
+ getColTitle : function(index) {
+ var headerCell = this.headerTable.rows[0].cells[index];
+ var title = Element.collectTextNodes(headerCell);
+ return title;
+ },
+
+ finishSort : function() {
+ for (var i = 0; i < this.cellTable.rows.length; i++) {
+ this.idTable.tBodies[0].appendChild(this.getIdRow(this.cellTable.rows[i]));
+ }
+ this.updateId();
+ },
+
+ setSelectedCell : function(event) {
+ this.removeSelectedClasses();
+ var src = Event.element(event);
+
+ if (src.tagName.toUpperCase() != 'TH' && src.tagName.toUpperCase() != 'TD') {
+ src = Element.getParentByTagName(['TH,TD'], src);
+ }
+
+ this.targetCell = src;
+
+ if (this.targetCell) {
+ this.targetColIndex = this.targetCell.cellIndex;
+ this.targetRowIndex = this.targetCell.parentNode.rowIndex;
+ this.targetColumn = this.getCells(this.targetColIndex);
+ this.targetRow = this.getRow(this.targetRowIndex);
+ }
+
+ this.cssUtil.addClassNames(this.targetCell, 'cellSelected');
+ var childNodes = Element.getTagNodes(this.targetCell, true);
+ for (var i = 0; i < childNodes.length; i++) {
+ this.cssUtil.addClassNames(childNodes[i], 'cellSelected');
+ }
+ },
+
+ setSelectedColumn : function(event) {
+ this.removeSelectedClasses();
+
+ this.targetCell = null;
+ this.targetRowIndex = null;
+ this.targetRow = null;
+ this.targetIdRow = null;
+ var src = Event.element(event);
+ if (src && (src.tagName.toUpperCase() == 'TH' || src.tagName.toUpperCase() == 'TD')) {
+ this.targetHeaderCell = src;
+ } else {
+ this.targetHeaderCell = Element.getParentByTagName(['TH,TD'], src);
+ }
+ if (this.targetHeaderCell) {
+ this.targetColIndex = this.targetHeaderCell.cellIndex;
+ this.targetColumn = this.getCells(this.targetColIndex);
+ this.cssUtil.addClassNames(this.targetHeaderCell, 'cellSelected');
+ var childNodes = Element.getTagNodes(this.targetHeaderCell, true);
+ for (var i = 0; i < childNodes.length; i++) {
+ this.cssUtil.addClassNames(childNodes[i], 'cellSelected');
+ }
+ for(var i = 0; i < this.targetColumn.length; i++) {
+ this.cssUtil.addClassNames(this.targetColumn[i], 'cellSelected');
+ var cellChildNodes = Element.getTagNodes(this.targetColumn[i], true);
+ for (var j = 0; j < cellChildNodes.length; j++) {
+ this.cssUtil.addClassNames(cellChildNodes.length[j], 'cellSelected');
+ }
+ }
+ }
+ },
+
+ setSelectedRow : function(event) {
+ this.removeSelectedClasses();
+ var src = Event.element(event);
+ if (src && src.tagName.toUpperCase() == 'TR') {
+ this.targetIdRow = src;
+ } else {
+ this.targetIdRow = Element.getParentByTagName(['TR'], src);
+ }
+ if (this.targetIdRow) {
+ this.targetRowIndex = this.targetIdRow.rowIndex;
+ this.targetRow = this.getRow(this.targetRowIndex);
+
+ this.cssUtil.addClassNames(this.targetRow, 'cellSelected');
+ var childNodes = Element.getTagNodes(this.targetRow, true);
+ for (var i = 0; i < childNodes.length; i++) {
+ this.cssUtil.addClassNames(childNodes[i], 'cellSelected');
+ }
+ this.cssUtil.addClassNames(this.targetIdRow, 'cellSelected');
+ childNodes = Element.getTagNodes(this.targetIdRow, true);
+ for (var i = 0; i < childNodes.length; i++) {
+ this.cssUtil.addClassNames(childNodes[i], 'cellSelected');
+ }
+ }
+
+ },
+
+ removeSelectedClasses : function() {
+ if (this.targetHeaderCell) {
+ this.cssUtil.removeClassNames(this.targetHeaderCell, 'cellSelected');
+ var childNodes = Element.getTagNodes(this.targetHeaderCell, true);
+ for (var i = 0; i < childNodes.length; i++) {
+ this.cssUtil.removeClassNames(childNodes[i], 'cellSelected');
+ }
+ for(var i = 0; i < this.targetColumn.length; i++) {
+ this.cssUtil.removeClassNames(this.targetColumn[i], 'cellSelected');
+ var cellChildNodes = Element.getTagNodes(this.targetColumn[i], true);
+ for (var j = 0; j < cellChildNodes.length; j++) {
+ this.cssUtil.removeClassNames(cellChildNodes.length[j], 'cellSelected');
+ }
+ }
+
+ }
+ if (this.targetCell) {
+ this.cssUtil.removeClassNames(this.targetCell, 'cellSelected');
+ var childNodes = Element.getTagNodes(this.targetCell, true);
+ for (var i = 0; i < childNodes.length; i++) {
+ this.cssUtil.removeClassNames(childNodes[i], 'cellSelected');
+ }
+
+ }
+
+ if (this.targetRow) {
+ this.cssUtil.removeClassNames(this.targetRow, 'cellSelected');
+ var childNodes = Element.getTagNodes(this.targetRow, true);
+ for (var i = 0; i < childNodes.length; i++) {
+ this.cssUtil.removeClassNames(childNodes[i], 'cellSelected');
+ }
+ this.cssUtil.removeClassNames(this.targetIdRow, 'cellSelected');
+ childNodes = Element.getTagNodes(this.targetIdRow, true);
+ for (var i = 0; i < childNodes.length; i++) {
+ this.cssUtil.removeClassNames(childNodes[i], 'cellSelected');
+ }
+ }
+
+ this.targetHeaderCell = null;
+ this.targetColumn = null;
+ this.targetColIndex = null;
+ this.targetCell = null;
+ this.targetRowIndex = null;
+ this.targetRow = null;
+ this.targetIdRow = null;
+ },
+
+ updateId : function() {
+ var rows = this.idTable.rows;
+ for (var i = 0; i < rows.length; i++) {
+ var idValue = document.getElementsByClassName(this.custumCss.idCellVal, rows[i])[0];
+
+ idValue.innerHTML = i + 1;
+ }
+ },
+
+ updateRowLine : function(target) {
+ var targetCellRow = this.cellTable.rows[this.targetRowIndex];
+ var updateRowIndex = this.targetIdRow.rowIndex;
+ var cellTableBody = targetCellRow.parentNode;
+ var cellTableRows = cellTableBody.rows;
+
+ if (this.options.hierarchy) {
+ var checkRow = cellTableBody.rows[this.targetIdRow.rowIndex];
+ if (this.isParentRow(checkRow, targetCellRow)) {
+ var idBody = this.idTable.tBodies[0];
+ idBody.insertBefore(this.targetIdRow, idBody.rows[this.targetRowIndex]);
+ return;
+ }
+ }
+ if (updateRowIndex == cellTableRows.length - 1) {
+ cellTableBody.appendChild(targetCellRow);
+ } else if (this.targetRowIndex < updateRowIndex) {
+ cellTableBody.insertBefore(targetCellRow, cellTableRows[updateRowIndex + 1]);
+ } else {
+ cellTableBody.insertBefore(targetCellRow, cellTableRows[updateRowIndex]);
+ }
+ if (this.options.hierarchy) {
+ this.updateOutline(targetCellRow);
+ }
+ this.targetRowIndex = updateRowIndex;
+ this.updateId();
+ },
+ updateCellLine : function(target){
+ var targetCells = this.getCells(this.targetColIndex);
+ var updateColIndex = this.targetHeaderCell.cellIndex;
+
+ var rows = this.cellTable.rows;
+
+ for (var i = 0; i < rows.length; i++) {
+ var cells = rows[i].cells;
+ var targetCell = targetCells[i];
+
+ if (updateColIndex == cells.length -1) {
+ rows[i].appendChild(targetCell);
+ } else if (this.targetColIndex < updateColIndex) {
+ rows[i].insertBefore(targetCell, cells[updateColIndex + 1]);
+ } else {
+ rows[i].insertBefore(targetCell, cells[updateColIndex]);
+ }
+ }
+ this.targetColIndex = updateColIndex;
+ },
+
+ updateCellWidth : function(newStyle, headColumn) {
+
+ if(newStyle.width > this.options.cellMinWidth) {
+ var dragDiv = Element.getElementsByClassName(headColumn, Grid.className.headerCellDrag)[0];
+ var sortDiv = Element.getElementsByClassName(headColumn, Grid.className.headerCellSort)[0];
+ var val = newStyle.width - (parseInt(Element.getStyle(headColumn, 'width')));
+
+ val = parseInt(val);
+
+ this.headerTable.style.width = (parseInt(Element.getStyle(this.headerTable, 'width')) + val) + 'px';
+
+ dragDiv.style.width = newStyle.width - (this.marginSize * 2) + 'px';
+ sortDiv.style.width = parseInt(Element.getStyle(dragDiv, 'width')) - (this.marginSize * 2) + 'px';
+
+ var index = headColumn.cellIndex ;
+ var rows = this.cellTable.rows;
+
+ this.cellTable.style.width = this.headerTable.style.width
+
+ for(var i = 0; i < rows.length; i++){
+ var cell = rows[i].cells[index];
+ var cellValueDiv = Element.getElementsByClassName(cell, Grid.className.cellVal)[0];
+ cellValueDiv.style.width = newStyle.width + 'px';
+ cell.style.width = newStyle.width + 'px';
+ }
+
+ }
+ },
+
+ updateCellHeight : function(newStyle, idCell) {
+ if(newStyle.height > this.options.cellMinHeight) {
+ var row = idCell.parentNode;
+ var index = row.rowIndex;
+ var idValueDiv = Element.getElementsByClassName(idCell, Grid.className.idCellVal)[0];
+ idValueDiv.style.height = newStyle.height - (this.marginSize * 2) + 'px';
+ var padding = parseInt(idValueDiv.style.paddingTop);
+ var cellRow = this.cellTable.rows[index];
+ var cells = cellRow.cells;
+ for (var i = 0; i < cells.length; i++) {
+ cells[i].style.height = newStyle.height + 'px';
+ var cellValueDiv = Element.getElementsByClassName(cells[i], Grid.className.cellVal)[0];
+ cellValueDiv.style.height = newStyle.height + 'px';
+ }
+ }
+ },
+
+ setTextAreaSize : function(event) {
+ var target = Event.element(event);
+ var rows = parseInt(Element.getStyle(target, 'height'));
+ var cols = parseInt(Element.getStyle(target, 'width'));
+ target.ajax.options.rows = Math.round(rows/20);
+ target.ajax.options.cols = Math.round(cols/20);
+ },
+
+ fixTablePosition : function(event) {
+ Grid.scrollTop = this.element.scrollTop;
+ Grid.scrollLeft = this.element.scrollLeft;
+ this.baseTable.style.top = Grid.scrollTop + 'px';
+ this.baseTable.style.left = Grid.scrollLeft + 'px';
+ this.headerTable.style.top = Grid.scrollTop + 'px';
+ this.idTable.style.left = Grid.scrollLeft + 'px';
+ },
+
+//----------ajax request param method---------------------------------------------------------------------------
+ createInplaceEditorParams : function(form, value) {
+ var rowIndexEnd = form.id.indexOf('_col_', 0);
+ var rowIndex = form.id.substring(this.rowIdBase.length, rowIndexEnd);
+
+ var colIndexStart = rowIndexEnd + '_col_'.length;
+ var colIndexEnd = form.id.indexOf('_form', 0);
+ var colIndex = form.id.substring(colIndexStart, colIndexEnd);
+ var jsonRowObj = this.rowDataToJsonObj(rowIndex);
+
+ var targetColTitle = this.getColTitle(colIndex);
+ jsonRowObj.each(function(j) {
+ if (j.column == targetColTitle) {
+ j.value = value;
+ throw $break;
+ }
+ });
+ var jsonRowText = JSON.stringify(jsonRowObj);
+ var params = {
+ rowData: jsonRowText,
+ column: targetColTitle,
+ value: value
+ };
+ return $H(params).toQueryString();
+ },
+
+ gridDataToJsonObj : function() {
+ var rows = this.cellTable.rows;
+ var jsonDataList = [];
+ for (var i = 0; i < this.rowLength; i++) {
+ var rowData = this.rowDataToJsonObj(i);
+ jsonDataList.push(rowData);
+ }
+ return jsonDataList;
+ },
+
+ rowDataToJsonObj : function(index) {
+ var jsonRowObj = [];
+ var row = $A(this.cellTable.rows).detect(function(r) {return r.id.getSuffix() == index});
+ for (var i = 0; i < this.colLength; i++) {
+ var jsonCellObj = {};
+ jsonCellObj['column'] = this.getColTitle(i);
+ jsonCellObj['value'] = Element.collectTextNodes(row.cells[i]);
+ jsonRowObj.push(jsonCellObj);
+ }
+ return jsonRowObj;
+ },
+
+ updateGridData : function() {
+
+ var jsonDataText = JSON.stringify(this.gridDataToJsonObj());
+ var params = 'id=' + encodeURIComponent(this.element.id) + '&data=' + encodeURIComponent(jsonDataText);
+
+ new Ajax.Updater(
+ this.options.updateGridReceiver,
+ this.options.updateGridUrl,
+ {
+ parameters: params,
+ evalScripts: true, asynchronous:true
+
+ }
+ );
+ },
+
+//----------hierarchy grid method---------------------------------------------------------------------------
+ setHierarchyRow : function(row, outlineLevel, outlineNum){
+ row.outlineLevel = outlineLevel || 1;
+ row.list = row.list || new Array();
+ if (row.outlineLevel == 1) {
+ this.topLevelList.push(row);
+ row.outlineNum = outlineNum || this.topLevelList.length;
+ } else {
+ var parentRow = this.getParentRow(row);
+ parentRow.list.push(row);
+ var num = parentRow.length;
+ row.outlineNum = outlineNum || parentRow.outlineNum + '.' + parentRow.list.length;
+
+ }
+
+ this.buildStateDiv(row.cells[this.hierarchyColIndex]);
+ this.setOutlineIndent(row);
+ this.setFontWeight(row);
+ },
+
+ buildStateDiv : function (cell) {
+ var stateDiv = Builder.node('div');
+ var valueDiv = Element.getElementsByClassName(cell, Grid.className.cellVal)[0];
+ this.cssUtil.addClassNames(stateDiv, 'state');
+ cell.insertBefore(stateDiv, valueDiv);
+
+ if (document.all) {
+ stateDiv.style.position = "absolute";
+ } else {
+ stateDiv.style.position = "relative";
+ stateDiv.style.cssFloat = "left";
+ }
+ this.addStateClass(cell, stateDiv);
+ Event.observe(stateDiv, 'click', this.toggleState.bindAsEventListener(this));
+ },
+
+ addStateClass : function (cell, stateDiv) {
+ var row = cell.parentNode;
+ if (row.list.length == 0) {
+ this.cssUtil.addClassNames(stateDiv, 'stateEmpty');
+ } else if (this.options.open){
+ this.cssUtil.addClassNames(stateDiv, 'stateOpen');
+ } else {
+ this.cssUtil.addClassNames(stateDiv, 'stateClose');
+ this.closeRow(row);
+ }
+ },
+
+ toggleState : function(event) {
+ var src = Event.element(event);
+ var row = src.parentNode.parentNode;
+
+ if (!Element.hasClassName(src, Grid.className.stateEmpty)) {
+ if (Element.hasClassName(src, Grid.className.stateOpen)) {
+ this.closeRow(row.list);
+ this.cssUtil.removeClassNames(src, 'stateOpen');
+ this.cssUtil.addClassNames(src, 'stateClose');
+ } else {
+ this.openRow(row.list);
+ this.cssUtil.removeClassNames(src, 'stateClose');
+ this.cssUtil.addClassNames(src, 'stateOpen');
+ }
+ }
+ },
+
+ openRow : function(list) {
+ for (var i = 0; i < list.length; i++) {
+ var row = list[i];
+ Element.show(row);
+ Element.show(this.getIdRow(row));
+ var stateDiv = Element.getElementsByClassName(row.cells[this.hierarchyColIndex], Grid.className.state)[0];
+ if (Element.hasClassName(stateDiv, Grid.className.stateOpen)) {
+ this.openRow(row.list)
+ }
+ }
+ },
+
+ closeRow : function(list) {
+ for (var i = 0; i < list.length; i++) {
+ Element.hide(list[i]);
+ Element.hide(this.getIdRow(list[i]));
+ this.closeRow(list[i].list)
+ }
+ },
+
+
+ showStateDiv : function(transport, element) {
+ var row = Element.getParentByTagName(['TR'], element);
+ var state = Element.getElementsByClassName(row, Grid.className.state)[0];
+ Element.show(state);
+ },
+
+ hideStateDiv : function(event) {
+ var src = Event.element(event);
+ var row = Element.getParentByTagName(['TR'], src);
+ var state = Element.getElementsByClassName(row, Grid.className.state)[0];
+
+ Element.hide(state);
+ },
+
+ addHierarchyRow : function(index, values) {
+ if (this.colLength == 0) {
+ return;
+ }
+ var newRow = this.addRow(index, values);
+
+ newRow.list = new Array();
+ var previousRow = newRow.previousSibling;
+ var parentRow = null;
+ var parentList = null;
+ var insertIndex = 0;
+ if (!previousRow) {
+ newRow.outlineLevel = 1;
+ parentList = this.topLevelList;
+ } else if (previousRow.list.length > 0) {
+ newRow.outlineLevel = previousRow.outlineLevel + 1;
+ parentRow = previousRow;
+ parentList = parentRow.list;
+ } else {
+ newRow.outlineLevel = previousRow.outlineLevel;
+ parentRow = this.getParentRow(previousRow);
+ parentList = parentRow ? parentRow.list : this.topLevelList;
+ insertIndex = parentList.indexOf(previousRow) + 1;
+ }
+ parentList.insert(insertIndex, newRow);
+ this.buildStateDiv(newRow.cells[this.hierarchyColIndex]);
+ for (var i = insertIndex; i < parentList.length; i++) {
+ if (parentList[i].outlineLevel != 1) {
+ parentList[i].outlineNum = parentRow.outlineNum + '.' + (i + 1);
+ } else {
+ parentList[i].outlineNum = i + 1;
+ }
+ this.setOutline(parentList[i]);
+ }
+
+ },
+
+ deleteHierarchyRow : function(index) {
+ if(isNaN(index) || index >= this.rowLength) {
+ return;
+ }
+ var row = this.getRow(index);
+ if (!row) {
+ return;
+ }
+ var parentRow = this.getParentRow(row);
+ var parentList = parentRow ? parentRow.list : this.topLevelList;
+ var removeIndex = parentList.indexOf(row);
+ var childList = row.list;
+
+ for (var i = 0; i < childList.length; i++) {
+ this.deleteChildRow(childList[i]);
+ }
+ parentList.remove(removeIndex);
+ this.deleteRow(index);
+
+ for (var i = removeIndex; i < parentList.length; i++) {
+ var updateRow = parentList[i];
+ if (updateRow.outlineLevel == 1) {
+ updateRow.outlineNum = i + 1;
+ } else {
+ updateRow.outlineNum = this.getParentRow(updateRow).outlineNum + '.' + (i + 1);
+ }
+ this.setOutline(parentList[i]);
+ }
+ this.setFontWeight(parentRow);
+ },
+
+ deleteChildRow : function(childRow) {
+ var list = childRow.list;
+
+ for (var i = 0; i < list.length; i++) {
+ this.deleteChildRow(list[i]);
+ }
+ this.deleteRow(childRow.rowIndex);
+ },
+
+ levelUp : function(row) {
+ if (!row) {
+ return;
+ }
+ var previousRow = row.previousSibling;
+ if (row.outlineLevel == 1 || !previousRow) {
+ return;
+ }
+
+ var parentRow = this.getParentRow(row);
+ var currentList = parentRow.list;
+
+ var newParentRow = this.getParentRow(parentRow);
+ var targetList = newParentRow ? newParentRow.list : this.topLevelList;
+
+ var currentIndex = currentList.indexOf(row);
+ var targetIndex = targetList.indexOf(parentRow) + 1;
+
+ row.outlineLevel -= 1;
+ targetList.insert(targetIndex, row);
+ currentList.remove(currentIndex);
+
+ while (currentList[currentIndex]) {
+ var moveRow = currentList[currentIndex];
+ row.list.push(moveRow);
+ currentList.remove(currentIndex);
+ }
+
+ if (row.outlineLevel != 1) {
+ row.outlineNum = newParentRow.outlineNum + '.' + (targetIndex + 1);
+ } else {
+ row.outlineNum = targetIndex + 1;
+ }
+
+ this.setOutline(row);
+
+ for (var i = targetIndex + 1; i < targetList.length; i++) {
+ if (targetList[i].outlineLevel != 1) {
+ targetList[i].outlineNum = newParentRow.outlineNum + '.' + (i + 1);
+ } else {
+ targetList[i].outlineNum = i + 1;
+ }
+ this.setOutline(targetList[i]);
+ }
+
+ this.setFontWeight(row);
+ this.setFontWeight(parentRow);
+ this.setFontWeight(newParentRow);
+ this.setStateClass(row);
+ this.setStateClass(previousRow);
+ },
+
+ levelDown : function(row) {
+ if (!row) {
+ return;
+ }
+ var previousRow = row.previousSibling;
+ var parentRow = this.getParentRow(row);
+ if (!previousRow || parentRow == previousRow) {
+ return;
+ }
+ var currentList = (row.outlineLevel == 1) ? this.topLevelList : parentRow.list;
+ var currentIndex = currentList.indexOf(row);
+
+ row.outlineLevel += 1;
+
+ var newParentRow = this.getParentRow(row);
+ var targetList = newParentRow.list;
+ var targetIndex = targetList.length;
+
+ currentList.remove(currentIndex);
+ targetList.push(row);
+
+ row.outlineNum = newParentRow.outlineNum + '.' + (targetIndex + 1);
+ this.setOutline(row);
+ for (var i = currentIndex; i < currentList.length; i++) {
+ if (currentList[i].outlineLevel != 1) {
+ currentList[i].outlineNum = parentRow.outlineNum + '.' + (i + 1);
+ } else {
+ currentList[i].outlineNum = i + 1;
+ }
+ this.setOutline(currentList[i]);
+ }
+
+ for (var i = targetIndex + 1; i < targetList.length; i++) {
+ targetList[i].outlineNum = newParentRow.outlineNum + '.' + (i + 1);
+ this.setOutline(targetList[i]);
+ }
+
+ this.setFontWeight(row);
+ this.setFontWeight(parentRow);
+ this.setFontWeight(newParentRow);
+ this.setStateClass(row);
+ this.setStateClass(previousRow);
+
+ },
+
+ setStateClass : function(row) {
+ if (!row.list) return;
+ var stateDiv = Element.getElementsByClassName(row.cells[this.hierarchyColIndex], Grid.className.state)[0];
+
+ if (Element.hasClassName(stateDiv, Grid.className.stateEmpty) && row.list.length > 0) {
+ this.cssUtil.removeClassNames(stateDiv, 'stateEmpty');
+ this.cssUtil.addClassNames(stateDiv, 'stateOpen');
+ } else if (!Element.hasClassName(stateDiv, Grid.className.stateEmpty) && row.list.length == 0) {
+ this.cssUtil.removeClassNames(stateDiv, 'stateOpen');
+ this.cssUtil.addClassNames(stateDiv, 'stateEmpty');
+ }
+ },
+
+ setOutline : function(row) {
+ var childList = row.list;
+ if (!childList) return;
+ for(var i = 0; i < childList.length; i++) {
+ var childRow = childList[i];
+ childRow.outlineLevel = row.outlineLevel + 1;
+ childRow.outlineNum = row.outlineNum + '.' + (i + 1);
+ this.setOutline(childRow);
+ }
+ this.setOutlineIndent(row);
+ },
+
+ setOutlineIndent : function(row) {
+ var cell = row.cells[this.hierarchyColIndex];
+ if (!cell) {
+ return;
+ }
+ var cellValueDiv = Element.getElementsByClassName(cell, Grid.className.cellVal)[0];
+ var stateDiv = Element.getElementsByClassName(cell, Grid.className.state)[0];
+ if (!stateDiv) return;
+ var stateDivWidth = stateDiv.offsetWidth || this.stateDivWidth;
+ var left = this.options.hierarchyIndent * (row.outlineLevel - 1);
+ var valueLeft = document.all ? left + stateDivWidth : left;
+ cellValueDiv.style.left = valueLeft + 'px';
+ stateDiv.style.left = left + 'px';
+ },
+
+ setFontWeight : function(row) {
+ if (row) {
+ if (!row.list) return;
+ if (row.list.length > 0){
+ row.style.fontWeight = 'bold';
+ } else {
+ row.style.fontWeight = 'normal';
+ }
+ }
+ },
+
+ updateOutline : function(row) {
+ var previousRow = row.previousSibling;
+ var newParentRow = null;
+ var insertIndex = 0;
+ var newParentList = null;
+
+ if (!previousRow.list) return;
+ if (!previousRow) {
+ newParentList = this.topLevelList;
+ }else if(previousRow.list.length > 0) {
+ newParentRow = previousRow;
+ newParentList = newParentRow.list;
+ } else {
+ newParentRow = this.getParentRow(previousRow);
+ newParentList = newParentRow ? newParentRow.list : this.topLevelList;
+ insertIndex = newParentList.indexOf(previousRow) + 1;
+ }
+ var parentRow = this.getParentRowByIndex(row, this.targetRowIndex);
+ var parentList = null;
+
+ var outlineNumBase = '';
+ if (parentRow) {
+ parentList = parentRow.list;
+ outlineNumBase = parentRow.outlineNum + '.';
+ } else {
+ parentList = this.topLevelList;
+ if (!parentList) return;
+ }
+ var removeIndex = parentList.indexOf(row);
+
+ if (parentList == newParentList && removeIndex < insertIndex) {
+ insertIndex -= 1;
+ parentList.remove(removeIndex);
+ parentList.insert(insertIndex, row);
+ for (var i = removeIndex; i < parentList.length; i++) {
+ try {
+ parentList[i].outlineNum = outlineNumBase + (i + 1);
+ this.setOutline(parentList[i]);
+ } catch (e) {}
+ }
+
+ } else {
+ parentList.remove(removeIndex);
+ newParentList.insert(insertIndex, row);
+ for (var i = removeIndex; i < parentList.length; i++) {
+ parentList[i].outlineNum = outlineNumBase + (i + 1);
+ this.setOutline(parentList[i]);
+ }
+ var newOutlineNumBase = newParentRow ? newParentRow.outlineNum + '.' : '';
+ var newOutlineLevelBase = newParentRow ? newParentRow.outlineLevel : 0;
+ row.outlineNum = newOutlineNumBase + (insertIndex + 1);
+ row.outlineLevel = newOutlineLevelBase + 1;
+ for (var i = insertIndex; i < newParentList.length; i++) {
+ newParentList[i].outlineNum = newOutlineNumBase + (i + 1);
+ this.setOutline(newParentList[i]);
+ }
+ this.setOutline(row);
+ }
+ this.setFontWeight(row);
+ this.setStateClass(row);
+ if (parentRow) {
+ this.setFontWeight(parentRow);
+ this.setStateClass(parentRow);
+ }
+ if (newParentRow) {
+ this.setFontWeight(newParentRow);
+ this.setStateClass(newParentRow);
+ }
+ this.updateHierarchyRowLine(row);
+ },
+
+ updateHierarchyRowLine : function(row, existingRow) {
+ if (!row.list) return;
+ var rowIndex = row.rowIndex;
+ var cellBody = this.cellTable.tBodies[0];
+ var idBody = this.idTable.tBodies[0];
+ if (!existingRow) {
+ existingRow = cellBody.rows[rowIndex + 1]
+ }
+
+ for (var i = 0; i < row.list.length; i++) {
+ if (!existingRow) {
+ cellBody.appendChild(row.list[i]);
+ idBody.appendChild(this.getIdRow(row.list[i]));
+ } else {
+ cellBody.insertBefore(row.list[i], existingRow);
+ idBody.insertBefore(this.getIdRow(row.list[i]), this.getIdRow(existingRow));
+ }
+ this.updateHierarchyRowLine(row.list[i], existingRow);
+ }
+ },
+
+ getParentRow : function(row) {
+ if (row.outlineLevel == 1) {
+ return null;
+ }
+
+ var previousRow = row.previousSibling;
+ if (!previousRow) {
+ return null;
+ }
+ try {
+ while (previousRow.outlineLevel != (row.outlineLevel - 1)) {
+ previousRow = previousRow.previousSibling;
+ }
+ return previousRow;
+ } catch (e) {}
+ },
+
+ getParentRowByIndex : function(row, index) {
+ if (row.outlineLevel == 1) {
+ return null;
+ }
+ if (this.targetRowIndex) {
+ for(var i = 0; i < this.targetRowIndex + 1; i++) {
+ if (!this.cellTable.rows[i].list) return;
+ if (this.cellTable.rows[i].list.indexOf(row) != -1) {
+ return this.cellTable.rows[i];
+ }
+ }
+ }
+ return null;
+ },
+
+ getPreviousRootRow : function(row) {
+ var previousRow = row.previousSibling;
+ if (!previousRow) {
+ return;
+ }
+ while (previousRow.outlineLevel != 1) {
+ previousRow = previousRow.previousSibling;
+ }
+
+ return previousRow;
+ },
+
+ isParentRow : function(row, parentRow) {
+ var temp = this.getParentRow(row);
+ if (!temp) {
+ return false;
+ } else if (temp == parentRow) {
+ return true;
+ } else {
+ return this.isParentRow(temp, parentRow);
+ }
+ }
+}
--- /dev/null
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
+//
+// This code is substantially based on code from Thomas Fakes(http://craz8.com)
+// which has the following copyright and permission notice
+//
+// Copyright (c) 2005 Thomas Fakes (http://craz8.com)
+//
+// This code is substantially based on code from script.aculo.us which has the
+// following copyright and permission notice
+//
+// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ResizeableGridEx = Class.create();
+Object.extend(Object.extend(ResizeableGridEx.prototype, Resizeable.prototype), {
+
+ draw: function(event) {
+
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var style = this.element.style;
+ var newHeight = 0;
+ var newWidth = 0;
+ var newTop = 0;
+ var newLeft = 0;
+ if (this.currentDirection.indexOf('n') != -1) {
+ var pointerMoved = this.startY - pointer[1];
+ var margin = Element.getStyle(this.element, 'margin-top') || "0";
+ newHeight = this.startHeight + pointerMoved;
+ newTop = (this.startTop - pointerMoved - parseInt(margin)) + "px";
+ }
+ if (this.currentDirection.indexOf('w') != -1) {
+ var pointerMoved = this.startX - pointer[0];
+ var margin = Element.getStyle(this.element, 'margin-left') || "0";
+ newWidth = this.startWidth + pointerMoved;
+ newLeft = (this.startLeft - pointerMoved - parseInt(margin)) + "px";
+ }
+ if (this.currentDirection.indexOf('s') != -1) {
+ newHeight = this.startHeight + pointer[1] - this.startY;
+ }
+ if (this.currentDirection.indexOf('e') != -1) {
+ newWidth = this.startWidth + pointer[0] - this.startX;
+ }
+ var newStyle = {
+ height: newHeight,
+ width: newWidth,
+ top: newTop,
+ left: newLeft
+ }
+ if (this.options.draw) {
+ this.options.draw(newStyle, this.element);
+ }
+
+ if (newHeight && newHeight > this.options.minHeight) {
+
+ style.top = newStyle.top;
+
+ style.height = newStyle.height + "px";
+
+ }
+ if (newWidth && newWidth > this.options.minWidth) {
+
+ style.left = newStyle.left;
+ style.width = newStyle.width + "px";
+
+
+ }
+ if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
+ },
+
+ directions: function(event) {
+ var pointer = [Event.pointerX(event) + Grid.scrollLeft, Event.pointerY(event) + Grid.scrollTop];
+ //var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var offsets = Position.cumulativeOffset(this.element);
+ var cursor = '';
+ if (this.between(pointer[1] - offsets[1], 0, this.options.top)) cursor += 'n';
+ if (this.between((offsets[1] + this.element.offsetHeight) - pointer[1], 0, this.options.bottom)) cursor += 's';
+ if (this.between(pointer[0] - offsets[0], 0, this.options.left)) cursor += 'w';
+ if (this.between((offsets[0] + this.element.offsetWidth) - pointer[0], 0, this.options.right)) cursor += 'e';
+
+ return cursor;
+ }
+});
--- /dev/null
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+SortableTableGridEx = Class.create();
+Object.extend(Object.extend(SortableTableGridEx.prototype, SortableTable.prototype), {
+
+ initialize: function(element) {
+ this.element = $(element);
+ Element.setStyle(this.element, {visibility: 'hidden'});
+
+ var options = Object.extend({
+ ascImg: false,
+ descImg: false,
+ handle: false,
+ callBack: false
+ }, arguments[1] || {});
+ this.options = options;
+
+ this.handle = options.handle ? $(options.handle) : this.element.rows[0];
+ this.ascImg = options.ascImg ? options.ascImg : 'images/spinelz/sortableTable_down.gif';
+ this.descImg = options.descImg ? options.descImg : 'images/spinelz/sortableTable_up.gif';
+ this.sortType = options.sortType;
+
+ this.currentOrder = 'default';
+ this.defaultOrder = new Array();
+ for (var i = 0; i < this.element.rows.length; i++) {
+ this.defaultOrder[i] = this.element.rows[i];
+ }
+ this.addEvents();
+ Element.setStyle(this.element, {visibility: 'visible'});
+ },
+
+ addEvents: function() {
+ var rows = this.handle.rows[0];
+ if (!rows) return;
+
+ for (var i = 0; i < rows.cells.length; i++) {
+ Element.cleanWhitespace(rows.cells[i]);
+ Element.cleanWhitespace(rows.cells[i].firstChild);
+ this.addEvent(rows.cells[i].firstChild.firstChild);
+ }
+ },
+
+ addEvent: function(handle) {
+ if (handle) {
+ handle.style.cursor = 'pointer';
+ Event.observe(handle, 'click', this.sortTable.bindAsEventListener(this));
+ }
+ },
+
+ sortTable: function(event) {
+ var target = Event.element(event);
+ if (target.tagName.toUpperCase() == 'IMG') {
+ target = target.parentNode;
+ }
+ var cell = target;
+ if (cell.tagName.toUpperCase() != 'TD' && cell.tagName.toUpperCase() != 'TH') {
+ cell = Element.getParentByTagName(['TD','TH'], cell);
+ }
+ var tmpColumn = cell.cellIndex;
+ if (this.targetColumn != tmpColumn) {
+ this.currentOrder = 'default';
+ }
+ this.targetColumn = tmpColumn;
+
+ var newRows = new Array();
+ for (var i = 0; i < this.element.rows.length; i++) {
+ newRows[i] = this.element.rows[i];
+ }
+ if (newRows.length < 1) return;
+
+ if (this.currentOrder == 'default') {
+ newRows.sort(this.getSortFunc());
+ this.currentOrder = 'asc';
+
+ } else if (this.currentOrder == 'asc') {
+ newRows = newRows.reverse();
+ this.currentOrder = 'desc';
+ } else if (this.currentOrder == 'desc') {
+ newRows = this.defaultOrder;
+ this.currentOrder = 'default';
+ }
+
+ for (var i = 0; i < newRows.length; i++) {
+ this.element.tBodies[0].appendChild(newRows[i]);
+ }
+
+ this.mark(target);
+ if (this.options.callBack) this.options.callBack(this.element);
+ },
+
+ mark: function(cell) {
+ var row = this.options.handle ? this.options.handle.rows[0] : this.element.rows[0];
+
+ var imgs = row.getElementsByTagName('IMG');
+
+ for (var i = 0; i < imgs.length; i++){
+ var parent = imgs[i].parentNode;
+ parent.removeChild(imgs[i]);
+ }
+ var imgFile;
+ if (this.currentOrder == 'asc') imgFile = this.ascImg;
+ else if (this.currentOrder == 'desc') imgFile = this.descImg;
+
+ if (imgFile)
+ cell.appendChild(Builder.node('IMG', {src: imgFile, alt: 'sortImg'}));
+ }
+
+});
+
--- /dev/null
+// Copyright (c) 2006 spinelz.org (http://script.spinelz.org/)
+//
+// This code is substantially based on code from script.aculo.us which has the
+// following copyright and permission notice
+//
+// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+InPlaceEditorEx = Class.create();
+Object.extend(Object.extend(InPlaceEditorEx.prototype, Ajax.InPlaceEditor.prototype), {
+ /*********************************************
+ * Edit
+ * The URL option is unnecessary because
+ * of updating without Ajax.
+ *********************************************
+ initialize: function(element, url, options) {
+ this.url = url;
+ *********************************************/
+ initialize: function(element, options) {
+ /*********************************************/
+ this.element = $(element);
+
+ this.options = Object.extend({
+ okButton: true,
+ okText: "ok",
+ cancelLink: true,
+ cancelText: "cancel",
+ savingText: "Saving...",
+ clickToEditText: "Click to edit",
+ okText: "ok",
+ rows: 1,
+ onComplete: function(transport, element) {
+ new Effect.Highlight(element, {startcolor: this.options.highlightcolor});
+ },
+ onFailure: function(transport) {
+ alert("Error communicating with the server: " + transport.responseText.stripTags());
+ },
+ callback: function(form) {
+ return Form.serialize(form);
+ },
+ handleLineBreaks: true,
+ loadingText: 'Loading...',
+ savingClassName: 'inplaceeditor-saving',
+ loadingClassName: 'inplaceeditor-loading',
+ formClassName: 'inplaceeditor-form',
+ highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor,
+ highlightendcolor: "#FFFFFF",
+ externalControl: null,
+ submitOnBlur: false,
+ ajaxOptions: {},
+ evalScripts: false
+ }, options || {});
+
+ if(!this.options.formId && this.element.id) {
+ this.options.formId = this.element.id + "-inplaceeditor";
+ if ($(this.options.formId)) {
+ // there's already a form with that name, don't specify an id
+ this.options.formId = null;
+ }
+ }
+
+ if (this.options.externalControl) {
+ this.options.externalControl = $(this.options.externalControl);
+ }
+
+ this.originalBackground = Element.getStyle(this.element, 'background-color');
+ if (!this.originalBackground) {
+ this.originalBackground = "transparent";
+ }
+
+ this.element.title = this.options.clickToEditText;
+
+ /*********************************************
+ * Edit
+ * The event to enter edit mode is changed
+ * from single-click to double-click.
+ *********************************************
+ this.onclickListener = this.enterEditMode.bindAsEventListener(this);
+ this.mouseoverListener = this.enterHover.bindAsEventListener(this);
+ this.mouseoutListener = this.leaveHover.bindAsEventListener(this);
+ Event.observe(this.element, 'click', this.onclickListener);
+ Event.observe(this.element, 'mouseover', this.mouseoverListener);
+ Event.observe(this.element, 'mouseout', this.mouseoutListener);
+ if (this.options.externalControl) {
+ Event.observe(this.options.externalControl, 'click', this.onclickListener);
+ Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener);
+ Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener);
+ }
+ *********************************************/
+ this.ondblclickListener = this.enterEditMode.bindAsEventListener(this);
+ this.mouseoverListener = this.enterHover.bindAsEventListener(this);
+ this.mouseoutListener = this.leaveHover.bindAsEventListener(this);
+ Event.observe(this.element, 'dblclick', this.ondblclickListener);
+ Event.observe(this.element, 'mouseover', this.mouseoverListener);
+ Event.observe(this.element, 'mouseout', this.mouseoutListener);
+ if (this.options.externalControl) {
+ Event.observe(this.options.externalControl, 'dblclick', this.ondblclickListener);
+ Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener);
+ Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener);
+ }
+ /*********************************************/
+ },
+ getText: function() {
+ return this.element.innerHTML.unescapeHTML();
+ },
+ onSubmit: function() {
+ var value = this.editField.value.escapeHTML();
+ if(value == '') {
+ this.onclickCancel();
+ return false;
+ } else {
+ this.onLoading();
+ this.element.innerHTML = value;
+ new InPlaceEditorEx(this.element.id, this.options);
+ return true;
+ }
+ },
+ removeForm: function() {
+ if(this.form) {
+ if(this.form.parentNode) {
+ var childNodes = this.form.parentNode.childNodes;
+ for(var i = 0; i < childNodes.length; i++) {
+ childNodes[i].data = '';
+ }
+ Element.remove(this.form);
+ }
+ this.form = null;
+ }
+ }
+});
--- /dev/null
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var MenuBar = Class.create();
+MenuBar.cssNames = {
+ container: 'menubar',
+ menu: 'menubar_menu',
+ menuBody: 'menubar_menuBody',
+ menuBodyHover: 'menubar_menuBodyHover',
+ subMenu: 'menubar_subMenu',
+ subMenuBody: 'menubar_subMenuBody',
+ subMenuBodyHover: 'menubar_subMenuBodyHover',
+ subMenuContainer: 'menubar_menuContainer',
+ dirMark: 'menubar_dirMark'
+}
+
+MenuBar.mark = {
+ dir: '>>'
+}
+
+MenuBar.prototype = {
+
+ initialize: function(element) {
+ this.options = Object.extend({
+ hideOnClickSubmenu: true
+ }, arguments[1]);
+
+ this.element = $(element);
+ Element.setStyle(this.element, {visibility: 'hidden'});
+ Element.hide(this.element);
+
+ var options = Object.extend({
+ cssPrefix: 'custom_'
+ }, arguments[1] || {});
+
+ var customCss = CssUtil.appendPrefix(options.cssPrefix, MenuBar.cssNames);
+ this.classNames = new CssUtil([MenuBar.cssNames, customCss]);
+
+ this.clicked = [];
+ var topMenus = [];
+ var nodes = this.element.childNodes;
+
+ for (var i = 0; i < nodes.length; i++) {
+ if (nodes[i].nodeType == 1) {
+ this.build(nodes[i], 'menu');
+ topMenus.push(nodes[i]);
+ }
+ }
+
+ this.menubar = Builder.node('DIV', topMenus)
+ this.classNames.addClassNames(this.menubar, 'container');
+ this.element.appendChild(this.menubar);
+
+ Event.observe(document, "click", this.hideAllTrigger(this.menubar).bindAsEventListener(this));
+ Element.setStyle(this.element, {visibility: 'visible'});
+ Element.show(this.element);
+ },
+
+ build: function(element, className) {
+ this.classNames.addClassNames(element, className);
+
+ var bodyContents = new Array();
+ var subMenus = new Array();
+ var nodes = element.childNodes;
+
+ for (var i = 0; i < nodes.length; i++) {
+ if (nodes[i].nodeType == 1 && nodes[i].tagName == 'DIV') {
+ this.build(nodes[i], 'subMenu');
+ subMenus.push(nodes[i]);
+ } else {
+ bodyContents.push(nodes[i]);
+ }
+ }
+
+ var bodyClass= className + 'Body';
+ var body = Builder.node('DIV', bodyContents);
+ this.classNames.addClassNames(body, bodyClass);
+ new Hover(body);
+ element.appendChild(body);
+
+ if (subMenus.length > 0) {
+ if (className == 'subMenu') {
+ var subMenu = Builder.node('DIV', [MenuBar.mark.dir]);
+ this.classNames.addClassNames(subMenu, 'dirMark');
+ body.appendChild(subMenu);
+ }
+
+ var container = Builder.node('DIV', subMenus);
+ this.classNames.addClassNames(container, 'subMenuContainer');
+ element.appendChild(container);
+
+ this.hide(container);
+ }
+ Event.observe(element, "click", this.onClick.bindAsEventListener(this, body));
+ },
+
+ onClick: function(event, menuBody) {
+ var menu = menuBody.parentNode;
+ var parentContainer = this.getParentContainer(menu);
+
+ var container = this.getContainer(menu);
+ var className = MenuBar.cssNames.menu;
+ if (Element.hasClassName(menu, className)) {
+ if (this.clicked.length > 0) {
+ this.hideAll(this.menubar);
+ this.clicked = [];
+ }
+ if (container) this.showAtBottom(container, menuBody);
+
+ } else {
+ if (container) {
+ var lastMenuBody = this.clicked.pop();
+ var lastMenu = lastMenuBody.parentNode;
+ var lastContainer = this.getContainer(lastMenu);
+ var lastParentContainer = this.getParentContainer(lastMenu);
+
+ if (lastMenu == menu) {
+ this.hide(container);
+
+ } else if (Element.hasClassName(lastContainer, MenuBar.cssNames.container)) {
+ this.clicked.push(last);
+
+ } else if (lastParentContainer == parentContainer) {
+ this.hide(lastContainer);
+
+ } else {
+ this.clicked.push(lastMenuBody);
+ }
+ this.showAtLeft(container, menu);
+ } else if (this.options.hideOnClickSubmenu) {
+ this.hideAll(this.menubar);
+ }
+ }
+
+ if (container) this.clicked.push(menuBody);
+ Event.stop(event);
+ },
+
+ showAtBottom: function(contents, menuBody) {
+ var offset = Position.positionedOffset(menuBody);
+ var height = 0;
+
+ if (menuBody.style.height) height = Element.getHeight(menuBody);
+ else height = menuBody.clientHeight;
+ height += offset[1];
+ height += (document.all) ? 4 : 3;
+
+ contents.style.top = height + 'px';
+ contents.style.left = offset[0] + 'px';
+
+ this.show(contents);
+ },
+
+ showAtLeft: function(contents, menuBody) {
+ var offset = Position.positionedOffset(menuBody);
+
+ contents.style.top = (offset[1] - 1) + 'px';
+ contents.style.left = (offset[0] + menuBody.offsetWidth + 2) + 'px';
+
+ this.show(contents);
+ },
+
+ hideAllTrigger: function(element) {
+ return function(event) {
+ if (!this.isMenuElement(Event.element(event))) this.hideAll(element);
+ }
+ },
+
+ hideAll: function(element) {
+ var nodes = element.childNodes;
+ for (var i = 0; i < nodes.length; i++) {
+ if (nodes[i].nodeType == 1) {
+ if (Element.hasClassName(nodes[i], MenuBar.cssNames.subMenuContainer)) {
+ this.hide(nodes[i]);
+ }
+
+ this.hideAll(nodes[i]);
+ }
+ }
+ },
+
+ show: function(element) {
+ element.style.visibility = 'visible';
+ },
+
+ hide: function(element) {
+ element.style.visibility = 'hidden';
+ },
+
+ getContainer: function(element) {
+
+ if (!element) return;
+ return document.getElementsByClassName(MenuBar.cssNames.subMenuContainer, element)[0];
+ },
+
+ getParentContainer: function(element) {
+ var container = Element.getParentByClassName(MenuBar.cssNames.subMenuContainer, element);
+ if (!container) {
+ container = Element.getParentByClassName(MenuBar.cssNames.container, element);
+ }
+
+ return container;
+ },
+
+ isMenuElement: function(element) {
+ return Element.hasClassName(element, MenuBar.cssNames.menuBodyHover)
+ || Element.hasClassName(element, MenuBar.cssNames.subMenuBodyHover)
+ || Element.hasClassName(element, MenuBar.cssNames.dirMark);
+ }
+}
--- /dev/null
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+NavPanel = Class.create();
+NavPanel.className = {
+ navPanel : 'navPanel',
+ panel: 'navPanel_panel',
+ tab : 'navPanel_tab',
+ tabLeftInactive : 'navPanel_tabLeftInactive',
+ tabLeftActive: 'navPanel_tabLeftActive',
+ tabMiddleInactive : 'navPanel_tabMiddleInactive',
+ tabMiddleActive : 'navPanel_tabMiddleActive',
+ tabRightInactive : 'navPanel_tabRightInactive',
+ tabRightActive : 'navPanel_tabRightActive'
+}
+NavPanel.prototype = {
+
+ initialize: function(element) {
+ var options = Object.extend({
+ selected: 1,
+ cssPrefix: 'custom_'
+ }, arguments[1] || {});
+
+ this.options = options;
+ this.element = $(element);
+ Element.setStyle(this.element, {visibility: 'hidden'});
+ Element.hide(this.element);
+
+ var customCss = CssUtil.appendPrefix(this.options.cssPrefix, NavPanel.className);
+ this.classNames = new CssUtil([NavPanel.className, customCss]);
+
+ this.classNames.addClassNames(this.element, 'navPanel');
+
+ this.selected = (this.options.selected > 0) ? this.options.selected - 1 : 0 ;
+ this.start();
+
+ Element.setStyle(this.element, {visibility: 'visible'});
+ Element.show(this.element);
+ },
+
+ start: function() {
+ this.tabs = [];
+ this.panels = [];
+ this.panelList = [];
+
+ this.tabId = this.element.id + '_tab';
+ this.tabLeftId = this.tabId + '_left';
+ this.tabMiddleId = this.tabId + '_middle';
+ this.tabRightId = this.tabId + '_right';
+ this.panelId = this.element.id + '_panel';
+
+ this.build();
+ },
+
+ build: function() {
+ Element.cleanWhitespace(this.element);
+ this.panelList = this.element.childNodes;
+
+ for (var i = 0; i < this.panelList.length; i++) {
+ if (this.panelList[i].nodeType != 1) {
+ Element.remove(this.panelList[i]);
+ i--;
+ continue;
+ }
+ Element.cleanWhitespace(this.panelList[i]);
+ var navSet = this.panelList[i].childNodes;
+ this.buildTab(navSet[0], i);
+ this.buildPanel(navSet[0], i);
+ }
+ this.selectTab();
+ },
+
+
+ buildTab: function(tabTitle, i) {
+ var tab = Builder.node('div', {id:this.tabId + i});
+ this.classNames.addClassNames(tab, 'tab');
+ var tabLeft = Builder.node('div', {id:this.tabLeftId + i});
+ var tabMiddle = Builder.node('div', {id:this.tabMiddleId + i});
+ tabMiddle.appendChild(tabTitle);
+ var tabRight = Builder.node('div',{id:this.tabRightId + i});
+
+ tab.appendChild(tabLeft);
+ tab.appendChild(tabMiddle);
+ tab.appendChild(tabRight);
+ Event.observe(tab, 'click', this.selectTab.bindAsEventListener(this));
+
+ this.tabs[i] = tab;
+ this.setTabInactive(tab);
+ this.panelList[i].appendChild(tab);
+ },
+
+ buildPanel: function(panelContent, i) {
+ var panel = Builder.node('div', {id:this.panelId + i});
+ this.classNames.addClassNames(panel, 'panel');
+ panel.appendChild(panelContent);
+ Element.hide(panel);
+ this.panels[i] = panel;
+ this.panelList[i].appendChild(panel);
+ },
+
+ selectTab: function(e) {
+ if (!e) {
+ if (!this.panels[this.selected]) this.selected = 0;
+ Element.show(this.panels[this.selected]);
+ this.setTabActive(this.tabs[this.selected]);
+ return;
+ }
+
+ var targetElement = Event.element(e);
+ var targetIndex = this.getTargetIndex(targetElement);
+ if (targetIndex == this.selected) {
+ return;
+ }
+
+ var currentPanel = this.panels[this.selected];
+ var targetPanel = this.panels[targetIndex];
+ this.setTabInactive(this.tabs[this.selected]);
+ this.setTabActive(this.tabs[targetIndex]);
+ Element.show(targetPanel);
+ Element.hide(currentPanel);
+ this.selected = targetIndex;
+ },
+
+ setTabActive: function(tab) {
+ var tabChildren = tab.childNodes;
+
+ this.classNames.refreshClassNames(tabChildren[0], 'tabLeftActive');
+ this.classNames.refreshClassNames(tabChildren[1], 'tabMiddleActive');
+ this.classNames.refreshClassNames(tabChildren[2], 'tabRightActive');
+ },
+
+ setTabInactive: function(tab) {
+ var tabChildren = tab.childNodes;
+
+ this.classNames.refreshClassNames(tabChildren[0], 'tabLeftInactive');
+ this.classNames.refreshClassNames(tabChildren[1], 'tabMiddleInactive');
+ this.classNames.refreshClassNames(tabChildren[2], 'tabRightInactive');
+ },
+
+ getTargetIndex: function(element) {
+
+ while(element) {
+ if (element.id && element.id.indexOf(this.tabId, 0) >= 0) {
+ var index = element.id.substring(this.tabId.length);
+ if (!isNaN(index)) {
+ return index;
+ }
+ }
+ element = element.parentNode;
+ }
+ }
+}
--- /dev/null
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var SelectableTable = Class.create();
+
+SelectableTable.classNames = {
+ table: 'selectableTable_table',
+ tr: 'selectableTable_tr',
+ trHover: 'selectableTable_trHover',
+ trSelected: 'selectableTable_trSelected'
+}
+
+SelectableTable.prototype = {
+ initialize: function(element) {
+ this.element = $(element);
+ Element.setStyle(this.element, {visibility: 'hidden'});
+ var defaultOptions = {
+ arrayDefaultData: [],
+ flagAllowUnselect: true,
+ flagInitialAllowMultiple: false,
+ flagKeypressAvailable: false,
+ flagKeypressDeleteAvailable: false,
+ flagKeypressInsertAvailable: false,
+ functionPostAdd: Prototype.emptyFunction,
+ functionPostDelete: Prototype.emptyFunction,
+ functionPostPressLeft: Prototype.emptyFunction,
+ functionPostPressRight: Prototype.emptyFunction,
+ functionPostSelect: Prototype.emptyFunction,
+ functionPostUnselect: Prototype.emptyFunction,
+ functionPreAdd: function() {return true;},
+ functionPreDelete: function() {return true;},
+ functionSubmit: Prototype.emptyFunction,
+ initialSelected: null,
+ prefixTrId: 'selectable_table_',
+ prefixCSS: 'custom_'
+ }
+ this.options = Object.extend(defaultOptions, arguments[1] || {});
+ this.classNames = new CssUtil([SelectableTable.classNames, CssUtil.appendPrefix(this.options.prefixCSS, SelectableTable.classNames)]);
+ this.documentListener = this.eventKeypress.bindAsEventListener(this);
+ this.flagAllowMultiple = this.options.flagInitialAllowMultiple;
+ this.flagAvailable = true;
+ this.focused = null;
+ this.lastSelected = null;
+ this.newNumber = 1;
+ this.selected = new Object();
+ this.build();
+ if(arguments[2]) {
+ this.selectEffect(this.buildTrId(arguments[2]));
+ }
+ Element.setStyle(this.element, {visibility: 'visible'});
+ },
+
+ add: function() {
+ if(!this.flagAvailable) {return;}
+ if(!this.options.functionPreAdd(this)) {return;}
+ if(arguments[0] == null) {arguments[0] = this.options.arrayDefaultData;}
+ if(typeof(arguments[0]) != 'string') {
+ arguments = arguments[0];
+ }
+ if(arguments[0] == null) {return;}
+ var objTr, objTd;
+ objTr = document.createElement('tr');
+ objTr.id = 'new_' + this.newNumber;
+ this.buildTr(objTr);
+ for(var i = 0; i < arguments.length; i++) {
+ objTd = document.createElement('td');
+ objTd.innerHTML = arguments[i];
+ objTr.appendChild(objTd);
+ }
+ this.element.tBodies[0].appendChild(objTr);
+ this.newNumber++;
+ this.options.functionPostAdd(this);
+ },
+
+ build: function() {
+ var lines = this.element.tBodies[0].rows;
+ this.classNames.addClassNames(this.element, 'table');
+ Event.observe(document, 'keypress', this.documentListener);
+ for(var i = 0; i < lines.length; i++) {
+ this.buildTr(lines[i]);
+ }
+ var selected = this.options.initialSelected
+ if(selected) {
+ this.selectEffect(this.buildTrId(selected));
+ }
+ },
+
+ buildTr: function(objTr) {
+ objTr.id = this.buildTrId(objTr.id);
+ this.classNames.addClassNames(objTr, 'tr');
+ Event.observe(objTr, 'click', this.eventClick.bindAsEventListener(this));
+ Event.observe(objTr, 'dblclick', this.eventDoubleClick.bindAsEventListener(this));
+ Event.observe(objTr, 'mouseout', this.eventFocusOut.bindAsEventListener(this));
+ Event.observe(objTr, 'mouseover', this.eventFocusOver.bindAsEventListener(this));
+ },
+
+ buildTrId: function(strId) {
+ return this.options.prefixTrId + strId
+ },
+
+ deleteAll: function() {
+ if(!this.flagAvailable) {return;}
+ if(!this.options.functionPreDelete(this)) {return;}
+ for(var trId in this.selected) {
+ this.element.tBodies[0].removeChild($(trId));
+ delete this.selected[trId];
+ }
+ this.focused = null;
+ this.options.functionPostDelete(this);
+ },
+
+ eventClick: function(event) {
+ if(!this.flagAvailable) {return;}
+ if(event.shiftKey) {
+ this.selectOrUnselectRange(Event.findElement(event, 'tr').id);
+ } else {
+ this.selectOrUnselect(Event.findElement(event, 'tr').id, event.ctrlKey);
+ }
+ },
+
+ eventDoubleClick: function(event) {
+ if(!this.flagAvailable) {return;}
+ if(this.flagAllowMultiple) {
+ this.select(Event.findElement(event, 'tr').id, false);
+ this.submit();
+ }
+ },
+
+ eventFocusOut: function(event) {
+ if(!this.flagAvailable) {return;}
+ this.focusOff();
+ },
+
+ eventFocusOver: function(event) {
+ if(!this.flagAvailable) {return;}
+ this.focusOn(Event.findElement(event, 'tr').id);
+ Event.findElement(event, 'tr').focus();
+ },
+
+ eventKeypress: function(event) {
+ if(!this.flagAvailable) {return;}
+ if(!this.options.flagKeypressAvailable) {return;}
+ switch(event.keyCode) {
+ case 13: //Enter
+ if(event.shiftKey) {
+ this.selectOrUnselectRange(this.focused);
+ } else {
+ this.selectOrUnselect(this.focused, event.ctrlKey);
+ }
+ break;
+ case 37: //Left
+ this.options.functionPostPressLeft(this);
+ break;
+ case 38: //Up
+ this.focusMove('up');
+ break;
+ case 39: //Right
+ this.options.functionPostPressRight(this);
+ break;
+ case 40: //Down
+ this.focusMove('down');
+ break;
+ case 45: //Insert
+ if(this.options.flagKeypressInsertAvailable) {this.add();}
+ break;
+ case 46: //Delete
+ if(this.options.flagKeypressDeleteAvailable) {this.deleteAll();}
+ break;
+ }
+ },
+
+ focusMove: function(direction) {
+ if(!this.flagAvailable) {return;}
+ if(this.focused == null) {
+ this.focusOn(this.element.tBodies[0].rows[0].id);
+ } else {
+ var rowIndex = $(this.focused).rowIndex;
+ var correctionValue, flagEdge;
+ switch(direction) {
+ case 'down':
+ correctionValue = 1;
+ flagEdge = this.isBottom(rowIndex);
+ break;
+ case 'up':
+ correctionValue = -1;
+ flagEdge = this.isTop(rowIndex);
+ break;
+ }
+ if(!flagEdge) {
+ this.focusOn(this.element.rows[rowIndex + correctionValue].id);
+ }
+ }
+ },
+
+ focusOff: function() {
+ if(!this.flagAvailable) {return;}
+ if(this.focused != null) {
+ var objTr = $(this.focused);
+ this.classNames.removeClassNames(objTr, 'trHover');
+ this.focused = null;
+ }
+ },
+
+ focusOn: function(trId) {
+ if(!this.flagAvailable) {return;}
+ if($(trId) != null) {
+ this.focusOff();
+ this.classNames.addClassNames($(trId), 'trHover');
+ this.focused = trId;
+ }
+ },
+
+ getSelected: function() {
+ var selectedIdList = new Array();
+ for(var trId in this.selected) {
+ selectedIdList.push(trId.replace(this.options.prefixTrId, ''));
+ }
+ return selectedIdList;
+ },
+
+ getSelectedElement: function(id) {
+ var trId = this.options.prefixTrId + id;
+ return $(trId)
+ },
+
+ isBottom: function(rowIndex) {
+ return (rowIndex == this.element.rows.length - 1) ? true : false;
+ },
+
+ isTop: function(rowIndex) {
+ return (rowIndex == this.element.tBodies[0].rows[0].rowIndex) ? true : false;
+ },
+
+ makeAvailable: function() {
+ this.flagAvailable = true;
+ },
+
+ makeMultiple: function() {
+ this.flagAllowMultiple = true;
+ },
+
+ makeSingular: function() {
+ this.flagAllowMultiple = false;
+ this.unselectAll();
+ },
+
+ makeUnavailable: function() {
+ this.flagAvailable = false;
+ },
+
+ removeEventFromDocument: function() {
+ Event.stopObserving(document, 'keypress', this.documentListener);
+ },
+
+ select: function(trId, ctrl) {
+ if(!this.flagAvailable) {return;}
+ this.selectEffect(trId, ctrl);
+ this.lastSelected = trId;
+ this.options.functionPostSelect(this);
+ if(!this.flagAllowMultiple) {
+ this.submit();
+ }
+ },
+
+ selectAll: function() {
+ if(!this.flagAvailable) {return;}
+ if(!this.flagAllowMultiple) {return;}
+ this.selected = new Object();
+ var lines = this.element.tBodies[0].rows;
+ for(var i = 0; i < lines.length; i++) {
+ this.select(lines[i].id, true);
+ }
+ },
+
+ selectEffect: function(trId, ctrl) {
+ if($(trId)) {
+ if(!this.flagAllowMultiple || !ctrl) {
+ this.unselectAll();
+ }
+ this.classNames.addClassNames($(trId), 'trSelected');
+ this.selected[trId] = true;
+ }
+ },
+
+ selectOrUnselect: function(trId, ctrl) {
+ if(!this.flagAvailable) {return;}
+ if(trId == null) {return;}
+ if(ctrl && this.selected[trId]) {
+ if(!this.flagAllowMultiple && !this.options.flagAllowUnselect) {return;}
+ this.unselect(trId);
+ } else {
+ this.select(trId, ctrl);
+ }
+ },
+
+ selectOrUnselectRange: function(trId) {
+ if(!this.flagAvailable) {return;}
+ if(trId == null) {return;}
+ if(this.lastSelected == null || this.lastSelected == trId) {
+ this.selectOrUnselect(trId);
+ return;
+ }
+ var flagSelect = false;
+ var lines = this.element.tBodies[0].rows;
+ var lastSelected = this.lastSelected
+ for(var i = 0; i < lines.length; i++) {
+ if(lines[i].id == trId || lines[i].id == lastSelected) {
+ flagSelect = (flagSelect) ? false : true;
+ } else if(!flagSelect) {
+ continue;
+ }
+ if(this.selected[lastSelected]) {
+ this.select(lines[i].id, true);
+ } else {
+ this.unselect(lines[i].id);
+ }
+ }
+ },
+
+ submit: function(trId) {
+ if(!this.flagAvailable) {return;}
+ var selected = this.getSelected();
+ this.options.functionSubmit(selected[0]);
+ },
+
+ unselect: function(trId) {
+ if(!this.flagAvailable) {return;}
+ this.classNames.removeClassNames($(trId), 'trSelected');
+ delete this.selected[trId];
+ this.lastSelected = trId;
+ this.options.functionPostUnselect(this);
+ },
+
+ unselectAll: function() {
+ if(!this.flagAvailable) {return;}
+ var lines = this.element.tBodies[0].rows;
+ for(var i = 0; i < lines.length; i++) {
+ this.unselect(lines[i].id);
+ }
+ }
+}
+
+var SelectableTableManager = Class.create();
+SelectableTableManager.prototype = {
+ initialize: function() {
+ this.active = null,
+ this.list = {}
+ },
+ activate: function(key) {
+ this.stop();
+ if(this.list[key]) {
+ this.list[key].makeAvailable();
+ this.active = this.list[key];
+ } else {
+ this.active = null;
+ }
+ },
+ push: function(key, element) {
+ this.list[key] = element;
+ },
+ start: function() {
+ if(this.active) {
+ this.active.makeAvailable();
+ }
+ },
+ stop: function() {
+ $H(this.list).each(
+ function(el) {
+ if(el[1]) {
+ el[1].makeUnavailable();
+ }
+ }
+ );
+ }
+}
--- /dev/null
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+SideBarBox = Class.create();
+
+SideBarBox.className = {
+ panelContainer : 'sideBarBox_panelContainer',
+ tabContainer : 'sideBarBox_tabContainer',
+ title : 'sideBarBox_tabTitle',
+ tab : 'sideBarBox_tab',
+ tabTopInactive : 'sideBarBox_tabTopInactive',
+ tabTopActive : 'sideBarBox_tabTopActive',
+ tabMiddleInactive : 'sideBarBox_tabMiddleInactive',
+ tabMiddleActive : 'sideBarBox_tabMiddleActive',
+ tabBottomInactive : 'sideBarBox_tabBottomInactive',
+ tabBottomActive : 'sideBarBox_tabBottomActive'
+}
+
+SideBarBox.prototype = {
+
+ initialize: function(element) {
+ var options = Object.extend({
+ selected: 1,
+ beforeSelect: function() {return true},
+ afterSelect: Prototype.emptyFunction,
+ visible: false,
+ close: true,
+ cssPrefix: 'custom_'
+ }, arguments[1] || {});
+
+ this.options = options;
+ this.element = $(element);
+ Element.setStyle(this.element, {visibility: 'hidden'});
+
+ var customCss = CssUtil.appendPrefix(this.options.cssPrefix, SideBarBox.className);
+ this.classNames = new CssUtil([SideBarBox.className, customCss]);
+
+ this.start();
+ Element.setStyle(this.element, {visibility: 'visible'});
+ },
+
+ start: function() {
+ this.tabs = [];
+ this.panelContents = [];
+ this.tabSets = [];
+
+ this.visible = this.options.visible;
+ this.selected = (this.options.selected > 0) ? this.options.selected - 1 : 0 ;
+ this.selected = (this.visible) ? this.selected : -1;
+
+ this.tabId = this.element.id + '_tab';
+ this.tabTopId = this.tabId + '_top';
+ this.tabMiddleId = this.tabId + '_middle';
+ this.tabBottomId = this.tabId + '_bottom';
+ this.tabContainerId = this.element.id + '_tabContainer';
+ this.panelId = this.element.id + '_panel';
+ this.panelContainerId = this.element.id + '_panelContainer';
+
+ this.tabContainer = null;
+ this.panelContainer = null;
+
+ this.buildTabBox();
+ },
+
+ buildTabBox: function() {
+ this.buildContainers();
+
+ Element.cleanWhitespace(this.element);
+ this.tabSets = this.element.childNodes;
+ if (this.visible && this.selected >= this.tabSets.length) {
+ this.selected = 0;
+ }
+ var i = 0;
+ while(this.tabSets.length > 0){
+ var tabSet = this.tabSets[0];
+ var tabPanel = $A(tabSet.childNodes).detect(function(c) {
+ return (c.nodeType == 1) && (c.tagName.toLowerCase() == 'div');
+ });
+ this.buildPanel(tabPanel, i);
+ this.buildTab(tabSet, i);
+ i++;
+ }
+ this.addContainers();
+ },
+
+ buildContainers : function() {
+ this.tabContainer = Builder.node('div',{id:this.tabContainerId});
+ this.classNames.addClassNames(this.tabContainer, 'tabContainer');
+ this.panelContainer = Builder.node('div',
+ {
+ id:this.panelContainerId
+ }
+ );
+ this.classNames.addClassNames(this.panelContainer, 'panelContainer');
+
+ if (!this.visible) {
+ Element.hide(this.panelContainer);
+ }
+ },
+
+ addContainers : function() {
+ this.element.appendChild(this.panelContainer);
+ this.element.appendChild(this.tabContainer);
+ this.element.appendChild(Builder.node('div', {style:'clear: left'}));
+ },
+
+ buildTab: function(tab, i) {
+ var tabTitle = tab.childNodes;
+ tab.id = this.tabId + i;
+ this.classNames.addClassNames(tab, 'tab');
+ var top = Builder.node('div',{id: this.tabTopId + i});
+ var middle = Builder.node('div', {id: this.tabMiddleId + i}, $A(tabTitle));
+ var bottom = Builder.node('div', {id: this.tabBottomId + i});
+
+ tab.appendChild(top);
+ tab.appendChild(middle);
+ tab.appendChild(bottom);
+ Event.observe(tab, 'click', this.selectTab.bindAsEventListener(this));
+
+ this.tabs[i] = tab;
+ this.tabContainer.appendChild(tab);
+ if ( i != this.selected) {
+ this.setTabInactive(tab);
+ } else {
+ this.setTabActive(tab);
+ }
+ },
+
+ buildPanel: function(panelContent, i) {
+ var panel = Builder.node('div', {id: this.panelId + i});
+ panel.appendChild(panelContent);
+ this.panelContents[i] = panel;
+ if(i != this.selected) {
+ Element.hide(panel);
+ }
+ this.panelContainer.appendChild(panel);
+ },
+
+ selectTab: function(e) {
+ if (!this.options.beforeSelect()) return;
+ if (!e) {
+ this.setTabActive(this.tabs[this.selected]);
+ Element.show(this.panelList[this.selected]);
+ return;
+ }
+
+ var currentPanel = this.panelContents[this.selected];
+ var currentTab = this.tabs[this.selected];
+
+ var targetElement = null;
+ if (e.nodeType) {
+ targetElement = e;
+ } else {
+ targetElement = Event.element(e);
+ }
+ var targetIndex = this.getTargetIndex(targetElement);
+ var targetPanel = this.panelContents[targetIndex];
+ var targetTab = this.tabs[targetIndex];
+ if (this.visible) {
+ if (targetTab.id == currentTab.id) {
+ if (this.options.close) {
+ Effect.SlideRightOutOfView(this.panelContainer);
+ this.visible = false;
+ this.selected = -1;
+ this.setTabInactive(currentTab);
+ Element.toggle(targetPanel);
+ }
+ } else {
+ this.setTabActive(targetTab);
+ this.setTabInactive(currentTab);
+ Element.toggle(currentPanel);
+ Element.toggle(targetPanel);
+ this.selected = targetIndex;
+ }
+ } else {
+ this.setTabActive(targetTab);
+ Element.toggle(targetPanel);
+ Effect.SlideRightIntoView(this.panelContainer);
+ this.visible = true;
+ this.selected = targetIndex;
+ }
+ this.options.afterSelect(targetPanel, currentPanel);
+ },
+
+ setTabActive: function(tab) {
+ var tabChildren = tab.childNodes;
+
+ this.classNames.refreshClassNames(tabChildren[0], 'tabTopActive');
+ this.classNames.refreshClassNames(tabChildren[1], 'tabMiddleActive');
+ this.classNames.refreshClassNames(tabChildren[2], 'tabBottomActive');
+ },
+
+ setTabInactive: function(tab) {
+ var tabChildren = tab.childNodes;
+
+ this.classNames.refreshClassNames(tabChildren[0], 'tabTopInactive');
+ this.classNames.refreshClassNames(tabChildren[1], 'tabMiddleInactive');
+ this.classNames.refreshClassNames(tabChildren[2], 'tabBottomInactive');
+ },
+
+ getTargetIndex: function(element) {
+ while(element) {
+ if (element.id && element.id.indexOf(this.tabId, 0) >= 0) {
+ var index = element.id.substring(this.tabId.length);
+ if (!isNaN(index)) {
+ return index;
+ }
+ }
+ element = element.parentNode;
+ }
+ },
+
+ hasNextTab: function() {
+ return this.getNextTab() ? true : false;
+ },
+
+ hasPreviousTab: function() {
+ return this.getPreviousTab() ? true : false;
+ },
+
+ getNextTab: function() {
+ return Element.next(this.getCurrentTab());
+ },
+
+ getPreviousTab: function() {
+ return Element.previous(this.getCurrentTab());
+ },
+
+ selectNextTab: function() {
+ this.selectTab(this.getNextTab());
+ },
+
+ selectPreviousTab: function() {
+ this.selectTab(this.getPreviousTab());
+ },
+
+ tabCount: function() {
+ return this.tabs.inject(0, function(i, t) {
+ return t ? ++i : i;
+ })
+ },
+
+ getCurrentPanel: function() {
+ return this.panelContents[this.selected];
+ },
+
+ getCurrentTab: function() {
+ return this.tabs[this.selected];
+ }
+}
--- /dev/null
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
+//
+// This code is substantially based on code from script.aculo.us which has the
+// following copyright and permission notice
+//
+// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Effect.SlideRightIntoView = function(element) {
+ element = $(element);
+ Element.cleanWhitespace(element);
+
+ var oldInnerRight = element.firstChild.style.right;
+ var elementDimensions = Element.getDimensions(element);
+ return new Effect.Scale(element, 100,
+ Object.extend({ scaleContent: false,
+ scaleY: false,
+ scaleFrom: 0,
+ scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
+ restoreAfterFinish: true,
+ afterSetup: function(effect) {
+ Element.makePositioned(effect.element.firstChild);
+ if (window.opera) effect.element.firstChild.style.left = "";
+ Element.makeClipping(effect.element);
+ element.style.width = '0';
+ Element.show(element);
+ },
+ afterUpdateInternal: function(effect) {
+ effect.element.firstChild.style.right =
+ (effect.dims[1] - effect.element.clientWidth) + 'px'; },
+ afterFinishInternal: function(effect) {
+ Element.undoClipping(effect.element);
+ Element.undoPositioned(effect.element.firstChild);
+ effect.element.firstChild.style.right = oldInnerRight; }
+ }, arguments[1] || {})
+ );
+}
+
+Effect.SlideRightOutOfView = function(element) {
+ element = $(element);
+ Element.cleanWhitespace(element);
+ var oldInnerRight = element.firstChild.style.right;
+ return new Effect.Scale(element, 0,
+ Object.extend({ scaleContent: false,
+ scaleY: false,
+ scaleMode: 'box',
+ scaleFrom: 100,
+ restoreAfterFinish: true,
+ beforeStartInternal: function(effect) {
+ Element.makePositioned(effect.element.firstChild);
+ if (window.opera) effect.element.firstChild.style.left = "";
+ Element.makeClipping(effect.element);
+ Element.show(element);
+ },
+ afterUpdateInternal: function(effect) {
+ effect.element.firstChild.style.right =
+ (effect.dims[1] - effect.element.clientWidth) + 'px'; },
+ afterFinishInternal: function(effect) {
+ Element.hide(effect.element);
+ Element.undoClipping(effect.element);
+ Element.undoPositioned(effect.element.firstChild);
+ effect.element.firstChild.style.right = oldInnerRight; }
+ }, arguments[1] || {})
+ );
+}
--- /dev/null
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var SortableTable = Class.create();
+
+SortableTable.classNames = {
+ header: 'sortableTable_header',
+ title: 'sortableTable_title',
+ empty: 'sortableTable_empty',
+ down: 'sortableTable_down',
+ up: 'sortableTable_up',
+ mark: 'sortableTable_mark',
+ thead: 'sortableTable_thead',
+ tbody: 'sortableTable_tbody'
+}
+
+SortableTable.prototype = {
+
+ initialize: function(element) {
+ this.element = $(element);
+ Element.setStyle(this.element, {visibility: 'hidden'});
+
+ var options = Object.extend({
+ sortType: false,
+ cssPrefix: 'custom_'
+ }, arguments[1] || {});
+
+ var customCss = CssUtil.appendPrefix(options.cssPrefix, SortableTable.classNames);
+ this.classNames = new CssUtil([SortableTable.classNames, customCss]);
+
+ this.sortType = options.sortType;
+
+ this.currentOrder = 'default';
+ this.defaultOrder = new Array();
+ for (var i = 1; i < this.element.rows.length; i++) {
+ this.defaultOrder[i - 1] = this.element.rows[i];
+ }
+
+ this.build();
+ Element.setStyle(this.element, {visibility: 'visible'});
+ },
+
+ build: function() {
+ thead = this.element.tHead;
+ this.classNames.addClassNames(thead, 'thead');
+ tbody = thead.nextSibling;
+ while ((tbody.nodeType != 1) || (tbody.tagName.toLowerCase() != 'tbody')) {
+ tbody = tbody.nextSibling;
+ }
+ this.classNames.addClassNames(tbody, 'tbody');
+ var rows = this.element.rows[0];
+ if (!rows) return;
+
+ for (var i = 0; i < rows.cells.length; i++) {
+
+ var cell = rows.cells[i];
+ cell.style.cursor = 'pointer';
+
+ Element.cleanWhitespace(cell);
+ var title = Builder.node('DIV', $A(cell.childNodes));
+ this.classNames.addClassNames(title, 'title');
+
+ var img = Builder.node('DIV');
+ this.classNames.addClassNames(img, 'mark');
+ this.classNames.addClassNames(img, 'empty');
+
+ var header = Builder.node('DIV', [title, img]);
+ this.classNames.addClassNames(header, 'header');
+ cell.appendChild(header);
+
+ var titleWidth = title.offsetWidth;
+ var imgWidth = img.offsetWidth;
+
+ title.style.width = (titleWidth + imgWidth) + 'px';
+ Event.observe(rows.cells[i], 'click', this.sortTable.bindAsEventListener(this));
+ }
+ },
+
+ sortTable: function(event) {
+ var cell = Event.element(event);
+
+ if (cell.tagName.toUpperCase() != 'TD' && cell.tagName.toUpperCase() != 'TH') {
+ cell = Element.getParentByTagName(['TD','TH'], cell);
+ }
+
+ var tmpColumn = cell.cellIndex;
+ if (this.targetColumn != tmpColumn) {
+ this.currentOrder = 'default';
+ }
+ this.targetColumn = tmpColumn;
+
+ var newRows = new Array();
+ for (var i = 1; i < this.element.rows.length; i++) {
+ newRows[i - 1] = this.element.rows[i];
+ }
+ if (newRows.length < 1) return;
+
+ if (this.currentOrder == 'default') {
+ newRows.sort(this.getSortFunc());
+ this.currentOrder = 'asc';
+ } else if (this.currentOrder == 'asc') {
+ newRows = newRows.reverse();
+ this.currentOrder = 'desc';
+ } else if (this.currentOrder == 'desc') {
+ newRows = this.defaultOrder;
+ this.currentOrder = 'default';
+ }
+
+ for (var i = 0; i < newRows.length; i++) {
+ this.element.tBodies[0].appendChild(newRows[i]);
+ }
+
+ this.mark(cell);
+ },
+
+ mark: function(cell) {
+ var images = document.getElementsByClassName(SortableTable.classNames.mark, this.element);
+ var targetImg = document.getElementsByClassName(SortableTable.classNames.mark, cell)[0];
+
+ for (var i = 0; i < images.length; i++) {
+ var parent = images[i].parentNode;
+ var title = document.getElementsByClassName(SortableTable.classNames.title, parent)[0];
+ var titleWidth = title.offsetWidth;
+
+ if (targetImg == images[i]) {
+
+ var imgWidth = targetImg.offsetWidth;
+
+ if (this.currentOrder == 'asc') {
+ this.classNames.addClassNames(targetImg, 'down');
+ this.classNames.removeClassNames(targetImg, 'empty');
+ if (!document.all) title.style.width = (titleWidth - imgWidth) + 'px';
+
+ } else if (this.currentOrder == 'desc') {
+ this.classNames.addClassNames(targetImg, 'up');
+ this.classNames.removeClassNames(targetImg, 'down');
+
+ } else if (this.currentOrder == 'default') {
+ this.classNames.addClassNames(targetImg, 'empty');
+ this.classNames.removeClassNames(targetImg, 'up');
+ if (!document.all) title.style.width = (titleWidth + imgWidth) + 'px';
+ }
+
+ } else {
+
+ if (Element.hasClassName(images[i], SortableTable.classNames.empty))
+ continue;
+
+ else if (Element.hasClassName(images[i], SortableTable.classNames.down))
+ this.classNames.removeClassNames(images[i], 'down');
+
+ else if (Element.hasClassName(images[i], SortableTable.classNames.up))
+ this.classNames.removeClassNames(images[i], 'up');
+
+ var imgWidth = targetImg.offsetWidth;
+ this.classNames.addClassNames(images[i], 'empty');
+ if (!document.all) title.style.width = (titleWidth + imgWidth) + 'px';
+ }
+ }
+ },
+
+ getSortFunc: function() {
+ if (!this.sortType || !this.sortType[this.targetColumn])
+ return SortFunction.string(this);
+
+ var type = this.getSortType();
+
+ if (!this.sortType || !type) {
+ return SortFunction.string(this);
+ } else if (type == SortFunction.numeric) {
+ return SortFunction.number(this);
+ }
+
+ return SortFunction.date(this);
+ },
+
+ getSortType: function() {
+ return this.sortType[this.targetColumn];
+ }
+}
+
+var SortFunction = Class.create();
+SortFunction = {
+ string: 'string',
+ numeric: 'numeric',
+ mmddyyyy: 'mmddyyyy',
+ mmddyy: 'mmddyy',
+ yyyymmdd: 'yyyymmdd',
+ yymmdd: 'yymmdd',
+ ddmmyyyy: 'ddmmyyyy',
+ ddmmyy: 'ddmmyy',
+
+ date: function(grid) {
+ return function(fst, snd) {
+ var aValue = Element.collectTextNodes(fst.cells[grid.targetColumn]);
+ var bValue = Element.collectTextNodes(snd.cells[grid.targetColumn]);
+ var date1, date2;
+
+ var date1 = SortFunction.getDateString(aValue, grid.getSortType());
+ var date2 = SortFunction.getDateString(bValue, grid.getSortType());
+
+ if (date1 == date2) return 0;
+ if (date1 < date2) return -1;
+
+ return 1;
+ }
+ },
+
+ number: function(grid) {
+ return function(fst, snd) {
+ var aValue = parseFloat(Element.collectTextNodes(fst.cells[grid.targetColumn]));
+ if (isNaN(aValue)) aValue = 0;
+ var bValue = parseFloat(Element.collectTextNodes(snd.cells[grid.targetColumn]));
+ if (isNaN(bValue)) bValue = 0;
+
+ return aValue - bValue;
+ }
+ },
+
+ string: function(grid) {
+ return function(fst, snd) {
+ var aValue = Element.collectTextNodes(fst.cells[grid.targetColumn]);
+ var bValue = Element.collectTextNodes(snd.cells[grid.targetColumn]);
+ if (aValue == bValue) return 0;
+ if (aValue < bValue) return -1;
+ return 1;
+ }
+ },
+
+ getDateString: function(date, type) {
+ var array = date.split('/');
+
+ if ((type == SortFunction.mmddyyyy) ||
+ (type == SortFunction.mmddyy)) {
+ var newArray = new Array();
+ newArray.push(array[2]);
+ newArray.push(array[0]);
+ newArray.push(array[1]);
+ } else if ((type == SortFunction.ddmmyyyy) ||
+ (type == SortFunction.ddmmyy)) {
+ var newArray = new Array();
+ newArray.push(array[2]);
+ newArray.push(array[1]);
+ newArray.push(array[0]);
+ } else {
+ newArray = array;
+ }
+
+ return newArray.join();
+ }
+}
+
--- /dev/null
+var Switcher = Class.create();
+Switcher.classNames = {
+ open: 'switcher_state_open',
+ close: 'switcher_state_close'
+}
+Switcher.prototype = {
+ initialize: function(sw, content) {
+ this.options = Object.extend({
+ open: false,
+ duration: 0.4,
+ beforeOpen: Prototype.emptyFunction,
+ afterOpen: Prototype.emptyFunction,
+ beforeClose: Prototype.emptyFunction,
+ afterClose: Prototype.emptyFunction,
+ effect: false,
+ cssPrefix: 'custom_'
+ }, arguments[2] || {});
+
+ this.sw = $(sw);
+ this.content = $(content);
+
+ var customCss = CssUtil.appendPrefix(this.options.cssPrefix, Switcher.classNames);
+ this.classNames = new CssUtil([Switcher.classNames, customCss]);
+
+ if (this.options.open) {
+ Element.show(this.content);
+ this.classNames.addClassNames(this.sw, 'open');
+ } else {
+ Element.hide(this.content);
+ this.classNames.addClassNames(this.sw, 'close');
+ }
+
+ Event.observe(this.sw, 'click', this.toggle.bind(this));
+ },
+
+ toggle: function() {
+ if (Element.hasClassName(this.sw, Switcher.classNames.close)) {
+ this.open();
+ }else {
+ this.close();
+ }
+ },
+
+ open: function() {
+ this.options.beforeOpen(this.content);
+ this.classNames.refreshClassNames(this.sw, 'open');
+ if (this.options.effect) {
+ new Effect.BlindDown(this.content, {duration: this.options.duration});
+ } else {
+ Element.show(this.content);
+ }
+ this.options.afterOpen(this.content);
+ },
+
+ close: function() {
+ this.options.beforeClose(this.content);
+ this.classNames.refreshClassNames(this.sw, 'close');
+ if (this.options.effect) {
+ new Effect.BlindUp(this.content, {duration: this.options.duration});
+ } else {
+ Element.hide(this.content);
+ }
+ this.options.afterClose(this.content);
+ }
+}
--- /dev/null
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+TabBox = Class.create();
+TabBox.className = {
+ tabBox: 'tabBox_tabBox',
+ panelContainer: 'tabBox_panelContainer',
+ tabContainer: 'tabBox_tabContainer',
+ tab: 'tabBox_tab',
+ tabLeftInactive: 'tabBox_tabLeftInactive',
+ tabLeftActive: 'tabBox_tabLeftActive',
+ tabMiddleInactive: 'tabBox_tabMiddleInactive',
+ tabMiddleActive: 'tabBox_tabMiddleActive',
+ tabRightInactive: 'tabBox_tabRightInactive',
+ tabRightActive: 'tabBox_tabRightActive',
+ tabTitle: 'tabBox_tabTitle',
+ closeButton: 'tabBox_closeButton'
+}
+TabBox.prototype = {
+
+ initialize: function(element) {
+ var options = Object.extend({
+ selected: 1,
+ cssPrefix: 'custom_',
+ beforeSelect: function() {return true},
+ afterSelect: Prototype.emptyFunction,
+ onRemove: function() {return true},
+ sortable: false,
+ closeButton: false,
+ afterSort: Prototype.emptyFunction,
+ onSort: Prototype.emptyFunction,
+ lazyLoadUrl: [],
+ onLazyLoad: Prototype.emptyFunction,
+ afterLazyLoad: Prototype.emptyFunction,
+ lazyLoadFailure: Prototype.emptyFunction,
+ failureLimitOver: Prototype.emptyFunction,
+ failureLimit: 5,
+ tabRow: null,
+ titleLength: null
+ }, arguments[1] || {});
+
+ this.options = options;
+ this.element = $(element);
+ Element.setStyle(this.element, {visibility: 'hidden'});
+ Element.hide(this.element);
+ this.selected = (this.options.selected > 0) ? this.options.selected - 1 : 0 ;
+
+ var customCss = CssUtil.appendPrefix(this.options.cssPrefix, TabBox.className);
+ this.classNames = new CssUtil([TabBox.className, customCss]);
+ this.classNames.addClassNames(this.element, 'tabBox');
+
+ this.start();
+ Element.setStyle(this.element, {visibility: 'visible'});
+ Element.show(this.element);
+
+ if (this.options.lazyLoadUrl.length > 0) this.lazyLoad(0);
+ },
+
+ start: function() {
+ this.tabs = [];
+ this.panelList = [];
+
+ this.tabId = this.element.id + '_tab';
+ this.tabLeftId = this.tabId + '_left';
+ this.tabMiddleId = this.tabId + '_middle';
+ this.tabRightId = this.tabId + '_right';
+ this.tabContainerId = this.element.id + '_tabContainer';
+ this.panelId = this.element.id + '_panel';
+ this.panelContainerId = this.element.id + '_panelContainer';
+
+ this.tabContainer = null;
+ this.panelContainer = null;
+ this.build();
+ if (this.options.sortable) this.setDrag();
+ },
+
+ setDrag: function() {
+ Sortable.create(this.tabContainerId, {
+ tag: 'div',
+ overlap: 'horizontal',
+ constraint: 'horizontal',
+ onChange: this.options.onSort,
+ onUpdate: this.options.afterSort,
+ starteffect: Prototype.emptyFunction,
+ endeffect: Prototype.emptyFunction
+ });
+ },
+
+ build: function() {
+ this.buildContainers();
+
+ Element.cleanWhitespace(this.element);
+ var tabSets = this.element.childNodes;
+
+ if (tabSets.length <= this.selected) {
+ this.selected = 0;
+ }
+ var i = 0;
+ while(tabSets.length > 0) {
+ this.buildTabSet(tabSets[0], i);
+ i++;
+ }
+ this.addContainers();
+ this.selectTab();
+ },
+
+ buildTabSet: function(element, i) {
+ if (element.nodeType != 1) {
+ Element.remove(element);
+ return;
+ }
+ Element.cleanWhitespace(element);
+ var panelContents = element.childNodes[1];
+ this.buildPanel(panelContents, i);
+ this.buildTab(element, i);
+ },
+
+ buildContainers : function() {
+ this.tabContainer = Builder.node('div',{id:this.tabContainerId});
+ this.classNames.addClassNames(this.tabContainer, 'tabContainer');
+
+ this.panelContainer = Builder.node('div', {id:this.panelContainerId});
+ this.classNames.addClassNames(this.panelContainer, 'panelContainer');
+ },
+
+ addContainers : function() {
+ this.element.appendChild(this.tabContainer);
+ this.element.appendChild(this.panelContainer);
+ },
+
+ buildTab: function(tab, i) {
+ tab.id = this.tabId + i
+ this.classNames.addClassNames(tab, 'tab');
+ var tabTitle = Builder.node('div', [$A(tab.childNodes)]);
+ this.classNames.addClassNames(tabTitle, 'tabTitle');
+ var tabLeft = Builder.node('div', {id:this.tabLeftId + i});
+ var tabMiddle = Builder.node('div', {id:this.tabMiddleId + i}, [tabTitle]);
+ var tabRight = Builder.node('div',{id:this.tabRightId + i});
+
+ tab.appendChild(tabLeft);
+ tab.appendChild(tabMiddle);
+ tab.appendChild(tabRight);
+ Event.observe(tab, 'click', this.selectTab.bindAsEventListener(this));
+ Event.observe(tab, 'mouseover', this.onMouseOver.bindAsEventListener(this));
+ Event.observe(tab, 'mouseout', this.onMouseOut.bindAsEventListener(this));
+
+ if (this.options.closeButton) {
+ var button = Builder.node('div', {
+ id: this.element.id.appendSuffix('closeButton_' + i)
+ });
+ this.classNames.addClassNames(button, 'closeButton');
+ tabMiddle.appendChild(button);
+ Event.observe(button, 'click', this.onRemove.bindAsEventListener(this));
+ }
+
+ if (this.options.tabRow && !isNaN(this.options.tabRow) && (i % this.options.tabRow == 0)) {
+ Element.setStyle(tab, {clear: 'left', styleFloat: 'none'});
+ }
+
+ this.setTitle(tabMiddle);
+ this.tabs[i] = tab;
+ this.setTabInactive(tab);
+ this.tabContainer.appendChild(tab);
+ },
+
+ setTitle: function(container) {
+ var node = Element.getTextNodes(container, true)[0];
+ title = node.nodeValue.replace(/^(\s)*/, '');
+ title = title.replace(/(\s)*$/, '');
+ var sortTitle = title;
+ if (this.options.titleLength && !isNaN(this.options.titleLength)) {
+ sortTitle = title.substring(0, this.options.titleLength);
+ }
+ node.nodeValue = sortTitle;
+ container.parentNode.title = title;
+ },
+
+ buildPanel: function(panelContent, i) {
+ var panel = Builder.node('div', {id: this.panelId + i});
+ panel.appendChild(panelContent);
+ Element.hide(panel);
+ this.panelList[i] = panel;
+ this.panelContainer.appendChild(panel);
+ },
+
+ selectTab: function(e){
+ if (!this.options.beforeSelect()) return;
+ if (!e) {
+ this.setTabActive(this.tabs[this.selected]);
+ Element.show(this.panelList[this.selected]);
+ return;
+ }
+ var currentPanel = this.getCurrentPanel();
+ var currentTab = this.getCurrentTab();
+
+ var targetElement = null;
+ if (e.nodeType) {
+ targetElement = e;
+ } else {
+ targetElement = Event.element(e);
+ }
+ var targetIndex = this.getTargetIndex(targetElement);
+ if (targetIndex == this.selected) {
+ return;
+ }
+ var targetPanel = this.panelList[targetIndex];
+ var targetTab = this.tabs[targetIndex];
+
+ if (currentTab) this.setTabInactive(currentTab);
+ this.setTabActive(targetTab);
+
+ if (currentPanel) Element.toggle(currentPanel);
+ Element.toggle(targetPanel);
+
+ this.selected = targetIndex;
+ this.options.afterSelect(targetPanel, currentPanel);
+ },
+
+ setTabActive: function(tab) {
+ var tabChildren = tab.childNodes;
+ this.classNames.refreshClassNames(tabChildren[0], 'tabLeftActive');
+ this.classNames.refreshClassNames(tabChildren[1], 'tabMiddleActive');
+ this.classNames.refreshClassNames(tabChildren[2], 'tabRightActive');
+ },
+
+ setTabInactive: function(tab) {
+ var tabChildren = tab.childNodes;
+ this.classNames.refreshClassNames(tabChildren[0], 'tabLeftInactive');
+ this.classNames.refreshClassNames(tabChildren[1], 'tabMiddleInactive');
+ this.classNames.refreshClassNames(tabChildren[2], 'tabRightInactive');
+ },
+
+ getTargetIndex: function(element) {
+ while(element) {
+ if (element.id && element.id.indexOf(this.tabId, 0) >= 0) {
+ var index = element.id.substring(this.tabId.length);
+ if (!isNaN(index)) {
+ return index;
+ }
+ }
+ element = element.parentNode;
+ }
+ },
+
+ onRemove: function(event) {
+ Event.stop(event);
+ var element = Event.element(event);
+ var index = this.getTargetIndex(element);
+ var tab = this.tabs[index];
+ if (this.options.onRemove(tab)) {
+ this.remove(tab);
+ }
+ },
+
+ remove: function(tab) {
+ if (tab) {
+ var index = this.getTargetIndex(tab);
+ var nextActiveTab = this.getNextTab();
+ if (!nextActiveTab) nextActiveTab = this.getPreviousTab();
+ Element.remove(tab);
+ Element.remove(this.panelList[index]);
+ this.tabs[index] = null;
+ this.panelList[index] = null;
+
+ if (index == this.selected) {
+ if (nextActiveTab) {
+ this.selectTab(nextActiveTab);
+ }
+ }
+ }
+ },
+
+ addByElement: function(element) {
+ this.buildTabSet($(element), this.tabs.length);
+ if (this.options.sortable) this.setDrag();
+ },
+
+ add: function(title, content) {
+ var contents = [];
+ var node = Builder.node('div');
+ node.innerHTML = title;
+ contents.push(node);
+ node = Builder.node('div');
+ node.innerHTML = content;
+ contents.push(node);
+ this.addByElement(Builder.node('div', contents));
+ },
+
+ lazyLoad: function(index) {
+ this.errorCount = 0;
+ this.loadedList = [];
+ this.load(index);
+ },
+
+ load: function(index) {
+ var container = this.panelList[index];
+ var url = this.options.lazyLoadUrl[index];
+ var self = this;
+ if (container && url) {
+ new Ajax.Updater(
+ {success: container},
+ url,
+ {
+ onSuccess: function() {
+ self.setLoaded(index);
+ self.options.onLazyLoad(container, self);
+ self.load(++index);
+ if (self.isFinishLazyLoad()) self.options.afterLazyLoad(self);
+ },
+ onFailure: function() {
+ self.errorCount++;
+ self.options.lazyLoadFailure(container, self);
+ if (self.errorCount <= self.options.failureLimit) {
+ self.load(index);
+ } else {
+ self.options.failureLimitOver(self);
+ }
+ },
+ asynchronous: true,
+ evalScripts: true
+ }
+ );
+ }
+ },
+
+ isFinishLazyLoad: function() {
+ return this.loadedList.length == this.panelList.length;
+ },
+
+ setLoaded: function(i) {
+ this.loadedList.push(i);
+ },
+
+ onMouseOver: function(event) {
+ var targetElement = Event.element(event);
+ var targetIndex = this.getTargetIndex(targetElement);
+ if (targetIndex != this.selected) {
+ var targetTab = this.tabs[targetIndex];
+ this.setTabActive(targetTab);
+ }
+ },
+
+ onMouseOut: function(event) {
+ var targetElement = Event.element(event);
+ var targetIndex = this.getTargetIndex(targetElement);
+ if (targetIndex != this.selected) {
+ var targetTab = this.tabs[targetIndex];
+ this.setTabInactive(targetTab);
+ }
+ },
+
+ hasNextTab: function() {
+ return this.getNextTab() ? true : false;
+ },
+
+ hasPreviousTab: function() {
+ return this.getPreviousTab() ? true : false;
+ },
+
+ getNextTab: function() {
+ return Element.next(this.getCurrentTab());
+ },
+
+ getPreviousTab: function() {
+ return Element.previous(this.getCurrentTab());
+ },
+
+ selectNextTab: function() {
+ this.selectTab(this.getNextTab());
+ },
+
+ selectPreviousTab: function() {
+ this.selectTab(this.getPreviousTab());
+ },
+
+ tabCount: function() {
+ return this.tabs.inject(0, function(i, t) {
+ return t ? ++i : i;
+ })
+ },
+
+ getCurrentPanel: function() {
+ return this.panelList[this.selected];
+ },
+
+ getCurrentTab: function() {
+ return this.tabs[this.selected];
+ }
+}
--- /dev/null
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+/**
+ * TimePicker
+ */
+var TimePicker = Class.create();
+TimePicker.className = {
+ container: 'timepicker_container',
+// container: 'timepicker',
+ header: 'timepicker_header',
+ preYears: 'timepicker_preYears',
+ nextYears: 'timepicker_nextYears',
+ years: 'timepicker_years',
+ mark: 'timepicker_mark',
+ ym: 'timepicker_ym',
+ table: 'timepicker_table',
+ thRight: 'right',
+ tdRight: 'right',
+ tdBottom: 'bottom',
+ date: 'timepicker_date',
+ holiday: 'timepicker_holiday',
+ regularHoliday: 'timepicker_regularHoliday',
+ schedule: 'timepicker_schedule',
+ highlightDay: 'timepicker_highlightDay',
+ scheduleListContainer: 'timepicker_scheduleListContainer',
+ scheduleItem: 'timepicker_scheduleItem',
+ scheduleTimeArea: 'timepicker_scheduleItemTimeArea',
+ scheduleHandler: 'timepicker_scheduleHandler',
+ holidayName: 'timepicker_holidayName',
+ dateContainer: 'timepicker_dateContainer',
+ tableHeader: 'timepicker_tableHeader',
+ rowContent: 'timepicker_rowContent',
+ selected: 'timepicker_selected',
+ displayToggle: 'timepicker_displayToggle',
+
+ nextYearMark: 'timepicker_nextYearMark',
+ nextMonthMark: 'timepicker_nextMonthMark',
+ nextWeekMark: 'timepicker_nextWeekMark',
+ preYearMark: 'timepicker_preYearMark',
+ preMonthMark: 'timepicker_preMonthMark',
+ preWeekMark: 'timepicker_preWeekMark',
+
+ weekTable: 'timepicker_weekContainerTable',
+ weekMainTable: 'timepicker_weekMainTable',
+ timeLine: 'timepicker_timeline',
+ timeLineTimeTop: 'timepicker_timelineTimeTop',
+ timeLineTime: 'timepicker_timelineTime',
+ timeLineTimeIe: 'timepicker_timelineTime_ie',
+ timeLineTimeIeTop: 'timepicker_timelineTime_ieTop',
+ headerColumn: 'timepicker_headerColumn',
+ columnTopDate: 'timepicker_columnTopDate',
+ columnDate: 'timepicker_columnDate',
+ columnDateOdd: 'timepicker_columnOddDate',
+ scheduleItemSamll: 'timepicker_scheduleItemSmall',
+ scheduleItemLarge: 'timepicker_scheduleItemLarge',
+ scheduleItemSelect: 'timepicker_scheduleItemSelect',
+ deleteImg: 'timepicker_deleteImage',
+ privateImg: 'timepicker_privateImage',
+ scheduleContainer: 'timepicker_weekScheduleContainer',
+ selector: 'timepicker_selector',
+ cover: 'timepicker_cover'
+}
+Object.extend(TimePicker.prototype, Calendar.prototype);
+Object.extend(TimePicker.prototype, {
+ initialize: function(element) {
+ this.options = Object.extend({
+ initDate: new Date(),
+ cssPrefix: 'custom_',
+ holidays: [],
+ schedules: [],
+ size: Calendar.size.large,
+ regularHoliday: [0, 6],
+ displayIndexes: [0, 1, 2, 3, 4, 5, 6],
+ displayTime: [{hour: 0, min: 0}, {hour: 24, min: 0}],
+ weekIndex: 0,
+ dblclickListener: null,
+ afterSelect: Prototype.emptyFunction,
+ beforeRefresh: Prototype.emptyFunction,
+ changeSchedule: Prototype.emptyFunction,
+ changeCalendar: Prototype.emptyFunction,
+ displayType: 'month',
+ highlightDay: true,
+ beforeRemoveSchedule: function() {return true;},
+ dblclickSchedule: null,
+ updateTirm: Prototype.emptyFunction,
+ displayTimeLine: true,
+ clickDateText: null,
+ getMonthHeaderText: Prototype.emptyFunction,
+ getMonthSubHeaderText: Prototype.emptyFunction,
+ getWeekHeaderText: Prototype.emptyFunction,
+ getWeekSubHeaderText: Prototype.emptyFunction,
+ getDayHeaderText: Prototype.emptyFunction,
+
+ setPosition: true,
+ headerTitle: '',
+ standardTime: false,
+ oneDayLabel: '24H',
+ standardTimeLabel: 'standard'
+ }, arguments[1] || {});
+
+ if (this.options.standardTime) {
+ this.options.displayTime = this.options.standardTime;
+ this.options.oneDay = [{hour: 0, min: 0}, {hour: 24, min: 0}];
+ }
+
+ this.element = $(element);
+ this.date = new Date();
+ var customCss = CssUtil.appendPrefix(this.options.cssPrefix, TimePicker.className);
+ this.classNames = new CssUtil([TimePicker.className, customCss]);
+
+ this.builder = new TimePickerBuilder(this);
+ this.builder.beforeBuild();
+ this.calendar = this.builder.build();
+ this.builder.afterBuild();
+ this.element.appendChild(this.calendar);
+ Element.hide(element);
+ Element.setStyle(this.element, {position: 'absolute'});
+
+// Event.observe(document, 'click', this.hide.bind(this));
+ Event.observe(document, "mouseup", this.onMouseUp.bindAsEventListener(this));
+ },
+
+ refresh: function() {
+ this.options.beforeRefresh(this);
+ this.destroy();
+ this.selectedBase = null;
+ Element.remove(this.calendar);
+ this.builder = new TimePickerBuilder(this);
+ this.builder.beforeBuild();
+ this.calendar = this.builder.build();
+ this.element.appendChild(this.calendar);
+ this.builder.afterBuild();
+// Event.observe(window, 'resize', this.windowResize);
+ },
+
+ show: function(event, triggerId) {
+ Event.stop(event);
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ if (this.options.setPosition.constructor == Function) {
+ this.options.setPosition(this.element, pointer);
+ } else if (this.options.setPosition) {
+ var parentOffset = Position.cumulativeOffset(this.element.parentNode);
+ Element.setStyle(this.element, {
+ left: pointer[0] - parentOffset[0] + 'px',
+ top: pointer[1] - parentOffset[1] + 'px'
+ });
+ }
+ Element.setStyle(this.element, {zIndex: ZindexManager.getIndex()});
+ Element.show(this.element);
+ this.builder.setColumnWidth();
+ this.builder.setCover();
+ },
+
+ hide: function() {
+ Element.hide(this.element);
+ this.clearSelected();
+ },
+
+ setTrigger: function(trigger, targets) {
+ trigger = $(trigger);
+ Event.observe(trigger, 'click', this.show.bindAsEventListener(this));
+ },
+
+ setTargets: function(targets) {
+ this.targets = targets;
+ },
+
+ onMouseUp: function(event) {
+ var calendar = this;
+ var dimention = Element.getDimensions(this.element);
+ var position = Position.cumulativeOffset(this.element);
+ var x = Event.pointerX(event);
+ var y = Event.pointerY(event);
+
+ if ((x < position[0]) || ((position[0] + dimention.width) < x) ||
+ (y < position[1]) || ((position[1] + dimention.height) < y)) {
+ this.hide();
+ }
+
+ if (calendar.mouseDown) {
+ setTimeout(function() {
+ if (calendar.mouseDown) {
+ calendar.mouseDown = false;
+ calendar.hide();
+ }
+ }, 10);
+ }
+
+ var term = this.builder.getSelectedTerm();
+ if (term) {
+ var start = term.first();
+ var finish = term.last();
+ this.setTime(this.targets.start.hour, start.getHours());
+ this.setTime(this.targets.start.min, start.getMinutes());
+ this.setTime(this.targets.finish.hour, finish.getHours());
+ this.setTime(this.targets.finish.min, finish.getMinutes());
+ this.hide();
+ }
+ },
+
+ setTime: function(target, value) {
+ $A($(target).options).each(function(option) {
+ if (option.value == value) {
+ option.selected = true;
+ } else {
+ option.selected = false;
+ }
+ });
+ }
+});
+
+
+/**
+ * TimePickerBuilder
+ */
+var TimePickerBuilder = Class.create();
+Object.extend(TimePickerBuilder.prototype, CalendarDay.prototype);
+Object.extend(TimePickerBuilder.prototype, {
+ initialize: function(calendar) {
+ var day = calendar.date.getDay();
+ this.calendar = calendar;
+ this.setDisplayTime();
+ this.calendar.options.displayIndexesOld = this.calendar.options.displayIndexes;
+ this.calendar.options.displayIndexes = [day];
+ this.calendar.options.weekIndexOld = this.calendar.options.weekIndex;
+ this.calendar.options.weekIndex = day;
+ this.week = this.getWeek();
+ },
+
+ buildHeader: function() {
+ var headerNodes = Builder.node('TR');
+ headerNodes.appendChild(this.buildHeaderCenter());
+
+ className = this.calendar.classNames.joinClassNames('header');
+ var tbody = Builder.node('TBODY', [headerNodes]);
+ return Builder.node('TABLE', {className: className}, [tbody]);
+ },
+
+ buildHeaderCenter: function() {
+ var contents = [];
+ var node = Builder.node('SPAN', [this.calendar.options.headerTitle]);
+ contents.push(node);
+ var container = Builder.node('TD', contents);
+ return container;
+ },
+
+ buildTimeLine: function() {
+ var time = new Date();
+ var hour = 0, hoursOfDay = 24;
+ time.setHours(hour);
+ time.setMinutes(0);
+ var nodes = [];
+ var timelineClass = 'timeLineTime';
+ var timelineTopClass = 'timeLineTime'
+ if (UserAgent.isIE()) {
+ timelineClass = 'timeLineTimeIe';
+ timelineTopClass = 'timeLineTimeIeTop';
+ }
+
+ var node = Builder.node('DIV');
+ this.calendar.classNames.addClassNames(node, 'timeLineTimeTop');
+ nodes.push(node);
+ while (hour < hoursOfDay) {
+ if (this.includeDisplayTime(hour)) {
+ node = Builder.node('DIV', [this.formatTime(time)]);
+ if (nodes.length == 0) {
+ this.calendar.classNames.addClassNames(node, timelineTopClass);
+ } else {
+ this.calendar.classNames.addClassNames(node, timelineClass);
+ }
+ nodes.push(node);
+ }
+ hour++;
+ time.setHours(hour);
+ }
+
+ var td = Builder.node('TD', nodes);
+ this.calendar.classNames.addClassNames(td, 'timeLine');
+ return td;
+ },
+
+ buildCalendarHeader: function() {
+ var node = null;
+ if (this.calendar.options.displayTime == this.calendar.options.standardTime) {
+ node = Builder.node('DIV', [this.calendar.options.oneDayLabel]);
+ } else {
+ node = Builder.node('DIV', [this.calendar.options.standardTimeLabel]);
+ }
+ Event.observe(node, 'click', this.toggleDisplayTime.bindAsEventListener(this, node));
+ this.calendar.classNames.addClassNames(node, 'headerColumn');
+ return Builder.node('TR', [Builder.node('TD', {align: 'center'}, [node])]);
+ },
+
+ abstractSelect: function(event, method) {
+ var element = this.findClickedElement(event);
+ if (element) {
+ if (Element.hasClassName(element, TimePicker.className.columnDate) ||
+ Element.hasClassName(element, TimePicker.className.columnDateOdd) ||
+ Element.hasClassName(element, TimePicker.className.columnTopDate)) {
+
+ var date = this.getDate(element);
+ method(date, element);
+ }
+ }
+ },
+
+ toggleDisplayTime: function(event, element) {
+ Event.stop(event);
+// var text = Element.getTextNodes(element).first().nodeValue;
+ if (this.calendar.options.displayTime == this.calendar.options.oneDay) {
+ this.calendar.options.displayTime = this.calendar.options.standardTime;
+ } else {
+ this.calendar.options.displayTime = this.calendar.options.oneDay;
+ }
+ this.calendar.refresh();
+ },
+
+ findClickedElement: function(event) {
+ var container = $(this.getScheduleContainerId());
+ var position = Position.cumulativeOffset(container);
+ var x = Event.pointerX(event) - position[0];
+ var y = Event.pointerY(event) - position[1];
+ var descendans = this.calendarTable.rows[0].cells[0].getElementsByTagName('div');
+ var height = parseInt(Element.getHeight(container), 10) / descendans.length;
+ var cellIndex = Math.floor(y / height);
+ return descendans[cellIndex];
+ },
+
+ beforeBuild: function() {
+ this.column = {};
+ var rule = CssUtil.getCssRuleBySelectorText('.' + TimePicker.className.columnDate);
+ this.column.height = parseInt(rule.style['height'], 10) + 1;
+ },
+
+ afterBuild: function() {
+ this.setColumnWidth();
+ this.setCover();
+ }
+});
--- /dev/null
+// Copyright (c) 2006 spinelz.org (http://script.spinelz.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var ToolBar = Class.create();
+ToolBar.className = {
+ container : 'toolbar_container',
+ containerLeft : 'toolbar_containerLeft',
+ containerMiddle : 'toolbar_containerMiddle',
+ containerRight : 'toolbar_containerRight',
+ toolbarItem : 'toolbar_item',
+ toolbarItemHover : 'toolbar_itemHov',
+ toolbarItemPres : 'toolbar_itemPres',
+ toolbarContent : 'toolbar_content',
+ toolbarContentPres: 'toolbar_contentPres'
+}
+
+ToolBar.prototype = {
+
+ initialize: function(element) {
+ var options = Object.extend({
+ cssPrefix : 'custom_'
+ }, arguments[1] || {});
+
+ this.element = $(element);
+ Element.setStyle(this.element, {visibility: 'hidden'});
+ Element.hide(this.element);
+ this.options = options;
+
+ var customCss = CssUtil.appendPrefix(this.options.cssPrefix, ToolBar.className);
+ this.classNames = new CssUtil([ToolBar.className, customCss]);
+
+ this.build();
+ Element.setStyle(this.element, {visibility: 'visible'});
+ Element.show(this.element);
+ },
+
+ build: function() {
+// Element.cleanWhitespace(this.element);
+ this.classNames.addClassNames(this.element, 'container');
+ var iconList = this.element.childNodes;
+
+ var containerLeft = Builder.node('div');
+ this.classNames.addClassNames(containerLeft, 'containerLeft');
+
+ this.containerMiddle = Builder.node('div');
+ this.classNames.addClassNames(this.containerMiddle, 'containerMiddle');
+
+ var containerRight = Builder.node('div');
+ this.classNames.addClassNames(containerRight, 'containerRight');
+
+ var removeList = [];
+ var toolbar = this;
+ $A(iconList).each(function(i) {
+ if (i.nodeType != 1) {
+ throw $continue;
+ }
+ toolbar.buildIcon(i);
+ });
+
+ this.element.appendChild(containerLeft);
+ this.element.appendChild(this.containerMiddle);
+ this.element.appendChild(containerRight);
+ },
+
+ buildIcon: function(icon) {
+ var toolbarItem = Builder.node('div');
+ this.classNames.addClassNames(toolbarItem, 'toolbarItem');
+
+ var toolbarContent = Builder.node('div');
+ this.classNames.addClassNames(toolbarContent, 'toolbarContent');
+
+ toolbarContent.appendChild(icon);
+ toolbarItem.appendChild(toolbarContent);
+ this.containerMiddle.appendChild(toolbarItem);
+ this.setHovEvent(toolbarItem);
+ this.setPresEvent(toolbarItem);
+ },
+
+ addIcon: function(options) {
+ var iconOptions = Object.extend({
+ id : 'newIcon',
+ src : 'url',
+ alt : 'icon',
+ width: 15,
+ height: 15
+ }, arguments[0] || {});
+ if (!$(iconOptions.id)) {
+ var icon = Builder.node('img', {id: iconOptions.id, src: iconOptions.src, alt: iconOptions.alt, style: 'width: ' + iconOptions.width + 'px; height: ' + iconOptions.height + 'px;'});
+ this.buildIcon(icon);
+ }
+ },
+
+ removeIcon: function(icon) {
+ var target = $(icon);
+ if (target) {
+ var itemNode = target.parentNode.parentNode;
+ Element.remove(itemNode);
+ }
+ },
+
+ addEvent: function(icon, eventName, func) {
+ var target = $(icon);
+ if (target) {
+ var itemNode = target.parentNode.parentNode;
+ Event.observe(itemNode, eventName, func);
+ }
+ },
+
+ removeEvent: function(icon, eventName, func) {
+ var target = $(icon);
+ if (target) {
+ var itemNode = target.parentNode.parentNode;
+ Event.stopObserving(itemNode, eventName, func);
+ }
+ },
+ setHovEvent: function(element) {
+ Event.observe(element, "mouseout", this.toggleItemClass(element, 'toolbarItem').bindAsEventListener(this));
+ Event.observe(element, "mouseover", this.toggleItemClass(element, 'toolbarItemHover').bindAsEventListener(this));
+ Event.observe(element, "mouseout", this.toggleItemClass(element.childNodes[0], 'toolbarContent').bindAsEventListener(this));
+ },
+
+ setPresEvent: function(element) {
+ Event.observe(element, "mousedown", this.toggleItemClass(element, 'toolbarItemPres').bindAsEventListener(this));
+ Event.observe(element, "mouseup", this.toggleItemClass(element, 'toolbarItem').bindAsEventListener(this));
+ Event.observe(element, "mousedown", this.toggleItemClass(element.childNodes[0], 'toolbarContentPres').bindAsEventListener(this));
+ Event.observe(element, "mouseup", this.toggleItemClass(element.childNodes[0], 'toolbarContent').bindAsEventListener(this));
+ },
+
+ toggleItemClass: function(target, className) {
+ return function() {
+ this.classNames.refreshClassNames(target, className);
+ }
+ }
+}
--- /dev/null
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var TreeView = Class.create();
+TreeView.className = {
+ top: 'treeview',
+ dir: 'treeview_dir',
+ dirBody: 'treeview_dirBody',
+ dirBodyText: 'treeview_dirBodyText',
+ dirBodyTextActive: 'treeview_dirBodyTextActive',
+ dirContainer: 'treeview_dirContainer',
+ dirContainerHover: 'treeview_dirContainerHover',
+ file: 'treeview_file',
+ fileBody: 'treeview_fileBody',
+ fileBodyText: 'treeview_fileBodyText',
+ fileBodyTextActive: 'treeview_fileBodyTextActive',
+ state_open: 'treeview_stateOpen',
+ state_close: 'treeview_stateClose',
+ state_empty: 'treeview_stateEmpty',
+ dirIcon: 'treeview_dirIcon',
+ fileIcon: 'treeview_fileIcon',
+ handle: 'treeview_handle'
+}
+
+TreeView.iconId = 'treeview_icon';
+
+TreeView.prototype = {
+ initialize: function(element) {
+ this.element = $(element);
+ Element.setStyle(this.element, {visibility: 'hidden'});
+ Element.hide(this.element);
+
+ this.options = Object.extend({
+ dirSymbol: 'dir',
+ fileSymbol: 'file',
+ cssPrefix: 'custom_',
+ open: true,
+ callBackFunctions: false,
+ dirSelect: true,
+ fileSelect: true,
+ noSelectedInsert: true,
+ iconIdPrefix: TreeView.iconId,
+ move: false,
+ unselected: Prototype.emptyFunction,
+ enableUnselected: true,
+ sortOptions: {},
+ openDir: Prototype.emptyFunction,
+ closeDir: Prototype.emptyFunction,
+ emptyImg: false,
+ initialSelected: null
+ }, arguments[1] || {});
+
+ this.customCss = CssUtil.appendPrefix(this.options.cssPrefix, TreeView.className);
+ this.classNames = new CssUtil([TreeView.className, this.customCss]);
+
+ this.changeClassNameDirAndFile(this.element);
+ var nodes = this.element.childNodes;
+ for (var i = 0; i < nodes.length; i++) {
+ this.build(nodes[i]);
+ }
+
+ this.classNames.addClassNames(this.element, 'top');
+ Element.setStyle(this.element, {visibility: 'visible'});
+ Element.show(this.element);
+
+ if (this.options.initialSelected) {
+ this.selectEffect(this.options.initialSelected);
+ }
+
+ if (this.options.move) {
+ this.setSortable();
+ }
+ },
+
+ addChildById: function(element, parent, number) {
+ element = $(element);
+ parent = $(parent);
+
+ var container = null;
+ if (!element || !parent)
+ return;
+ else if (Element.hasClassName(parent, TreeView.className.dir))
+ container = this.getChildDirContainer(parent);
+ else if (Element.hasClassName(parent, TreeView.className.top))
+ container = parent;
+ else
+ return;
+
+ this.build(element);
+
+ if (isNaN(number)) {
+ container.appendChild(element);
+ } else {
+ var children = this.getDirectoryContents(container);
+ if (children[number]) container.insertBefore(element, children[number]);
+ else container.appendChild(element);
+ }
+
+ this.refreshStateImg(parent);
+ if (this.options.dragAdrop) this.setSortable();
+ },
+
+ addChildByPath: function(element, path) {
+ element = $(element);
+ if (element) this.build(element);
+ else return;
+
+ var paths = path.split('/').findAll(function(elm) {
+ return (elm != '');
+ });
+
+ var last = paths.pop();
+ var container = this.search(paths.join('/'));
+
+ var children = this.getDirectoryContents(container);
+
+ if(children[last])
+ container.insertBefore(element, children[last]);
+ else
+ container.appendChild(element);
+
+ this.refreshStateImg(container.parentNode);
+ if (this.options.dragAdrop) this.setSortable();
+ },
+
+ addChildBySelected: function(element, number) {
+ if (!this.selected && !this.options.noSelectedInsert) return;
+
+ if (this.selected)
+ this.addChildById(element, this.selected, number);
+ else
+ this.addChildById(element, this.element, number);
+ },
+
+ addSelectItemCallback: function(functionObj) {
+ if (!this.options.callBackFunctions) {
+ this.options.callBackFunctions = new Array();
+ }
+ this.options.callBackFunctions.push(functionObj);
+ },
+
+ build: function(element) {
+ if (element.nodeType != 1) return;
+
+ Element.cleanWhitespace(element);
+ this.changeClassNameDirAndFile(element);
+
+ if (Element.hasClassName(element, TreeView.className.dir)) {
+ var container = this.createDirectoryContainer(element);
+ var body;
+ if (this.hasContents(container))
+ body = this.createDirectoryBody(element, false);
+ else
+ body = this.createDirectoryBody(element, true);
+
+ element.appendChild(body);
+ element.appendChild(container);
+
+ var nodes = container.childNodes;
+ for (var i = 0; i < nodes.length; i++) {
+ this.build(nodes[i]);
+ }
+ } else if (Element.hasClassName(element, TreeView.className.file)) {
+ var created = this.createFileBody(element);
+ element.appendChild(created);
+ }
+ },
+
+ changeClassName: function(element, to, from) {
+ var nodes = document.getElementsByClassName(from, element);
+
+ var newClassName = this.classNames.joinClassNames(to);
+ nodes.each(function(n) {
+ n.className = n.className.replace(new RegExp(from), newClassName);
+ });
+
+ if (Element.hasClassName(element, from)) {
+ element.className = element.className.replace(new RegExp(from), newClassName);
+ }
+ },
+
+ changeClassNameDirAndFile: function(element) {
+ this.changeClassName(element, 'dir', this.options.dirSymbol);
+ this.changeClassName(element, 'file', this.options.fileSymbol);
+ },
+
+ convertJSON: function() {
+ return JSON.stringify(this.parse());
+ },
+
+ createDirectoryBody: function(element, isEmpty) {
+ var customClass = null;
+ var dirBodyClass = this.classNames.joinClassNames('dir');
+ if (element.className != dirBodyClass) {
+ customClass = element.className.replace(new RegExp(dirBodyClass + ' '), '');
+ element.className = dirBodyClass;
+ }
+
+ var bodyNodes = new Array();
+ var state;
+ if (isEmpty && !this.options.emptyImg)
+ state = 'state_empty';
+ else if (this.options.open)
+ state = 'state_open';
+ else
+ state = 'state_close';
+
+ var id = this.options.iconIdPrefix.appendSuffix(element.id);
+ var stateImg = Builder.node('DIV', {id: id.appendSuffix('stateImg')});
+ this.classNames.addClassNames(stateImg, state);
+ Event.observe(stateImg, "click", this.toggle.bindAsEventListener(this));
+
+ var itemImg = Builder.node('DIV', {id: id});
+ this.classNames.addClassNames(itemImg, 'dirIcon');
+ if (customClass) {
+ Element.addClassName(itemImg, customClass);
+ }
+ this.classNames.addClassNames(itemImg, 'handle');
+
+ var bodyText = Builder.node('SPAN', this.getDirectoryText(element));
+ this.classNames.addClassNames(bodyText, 'dirBodyText');
+
+ bodyNodes.push(stateImg);
+ bodyNodes.push(itemImg);
+ bodyNodes.push(bodyText);
+
+ var body = Builder.node('DIV', bodyNodes);
+ this.classNames.addClassNames(body, 'dirBody');
+ if (this.options.dirSelect) {
+ Event.observe(itemImg, "click", this.selectDirItem.bindAsEventListener(this));
+ Event.observe(bodyText, "click", this.selectDirItem.bindAsEventListener(this));
+ }
+
+ return body;
+ },
+
+ createDirectoryContainer: function(element) {
+ var container = element.getElementsByTagName('ul')[0];
+ if (!container) {
+ container = Builder.node('UL');
+ }
+ this.classNames.addClassNames(container, 'dirContainer');
+ if (!this.options.open) Element.hide(container);
+ return container;
+ },
+
+ createFileBody: function(element) {
+ var customClass = null;
+ var fileBodyClass = this.classNames.joinClassNames('file');
+ if (element.className != fileBodyClass) {
+ customClass = element.className.replace(new RegExp(fileBodyClass + ' '), '');
+ element.className = fileBodyClass;
+ }
+
+ var id = this.options.iconIdPrefix.appendSuffix(element.id);
+ var itemImg = Builder.node('DIV', {id: id});
+ this.classNames.addClassNames(itemImg, 'fileIcon');
+ if (customClass) {
+ Element.addClassName(itemImg, customClass);
+ }
+ this.classNames.addClassNames(itemImg, 'handle');
+
+ var bodyText = Builder.node('SPAN', $A(element.childNodes));
+ this.classNames.addClassNames(bodyText, 'fileBodyText');
+
+ var children = new Array();
+ children.push(itemImg);
+ children.push(bodyText);
+
+ var body = Builder.node('DIV', children);
+ this.classNames.addClassNames(body, 'fileBody');
+ if (this.options.fileSelect) {
+ Event.observe(itemImg, "click", this.selectFileItem.bindAsEventListener(this));
+ Event.observe(bodyText, "click", this.selectFileItem.bindAsEventListener(this));
+ }
+
+ return body;
+ },
+
+ getChildBody: function(element) {
+ var names = [TreeView.className.fileBody, TreeView.className.dirBody];
+ return Element.getFirstElementByClassNames(element, names);
+ },
+
+ getChildBodyText: function(element) {
+ var names = [
+ TreeView.className.fileBodyText,
+ TreeView.className.fileBodyTextActive,
+ TreeView.className.dirBodyText,
+ TreeView.className.dirBodyTextActive
+ ];
+ return Element.getFirstElementByClassNames(element, names);
+ },
+
+ getChildBodyTextNode: function(element) {
+ var body = this.getChildBody(element);
+ var bodyText = this.getChildBodyText(body);
+ return this.searchTextNode(bodyText);
+ },
+
+ getChildDir: function(element) {
+ return document.getElementsByClassName(TreeView.className.dir, element);
+ },
+
+ getChildDirBody: function(element) {
+ return document.getElementsByClassName(TreeView.className.dirBody, element)[0];
+ },
+
+ getChildDirContainer: function(element) {
+ return document.getElementsByClassName(TreeView.className.dirContainer, element)[0];
+ },
+
+ getChildStateImg: function(element) {
+ var body = this.getChildDirBody(element);
+ var names = [
+ TreeView.className.state_close,
+ TreeView.className.state_open,
+ TreeView.className.state_empty
+ ];
+
+ return Element.getFirstElementByClassNames(body, names);
+ },
+
+ getChildren: function(element, ignoreDir, ignoreFile) {
+ var parent;
+ var children = new Array();
+ if(element) {
+ parent = $(element).getElementsByTagName('ul')[0];
+ } else {
+ parent = this.element;
+ }
+ $A(Element.getTagNodes(parent)).each(
+ function(node) {
+ if(!ignoreDir && Element.hasClassName(node, TreeView.className.dir)) {
+ children.push(node);
+ }
+ if(!ignoreFile && Element.hasClassName(node, TreeView.className.file)) {
+ children.push(node);
+ }
+ }
+ );
+ return children;
+ },
+
+ getDirectoryContents: function(element) {
+ return $A(element.childNodes).findAll(function(child) {
+ if ((child.nodeType != 1)) {
+ return false;
+ }
+ if (child.tagName.toLowerCase() == 'li') {
+ return true;
+ }
+ return false;
+ });
+ },
+
+ getDirectoryText: function(element) {
+ return $A(element.childNodes).findAll(function(child) {
+ if ((child.nodeType != 1)) {
+ return true;
+ } else if (child.tagName.toLowerCase() != 'ul') {
+ return true;
+ }
+ return false;
+ });
+ },
+
+ getHierarchyNumber: function() {
+ if (!this.selected) return;
+ var element = this.selected;
+ var i = 0;
+ while (true) {
+ if (this.element == element) {
+ return i;
+ } else {
+ element = this.getParentDir(element, true);
+ if (!element) return;
+ i++;
+ }
+ }
+ },
+
+ getParentDir: function(element, top) {
+ var result = Element.getParentByClassName(TreeView.className.dir, element);
+ if (!result && top)
+ result = Element.getParentByClassName(TreeView.className.top, element);
+ return result;
+ },
+
+ hasContents: function(element) {
+ if (element) {
+ if (!Element.hasClassName(element, TreeView.className.dirContainer) &&
+ !Element.hasClassName(element, TreeView.className.top)) {
+ return false;
+ }
+
+ var nodes = element.childNodes;
+ for (var i = 0; i < nodes.length; i++) {
+ if (nodes[i].nodeType == 1) {
+ if (Element.hasClassName(nodes[i], TreeView.className.dir) ||
+ Element.hasClassName(nodes[i], TreeView.className.file)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ },
+
+ parse: function(container) {
+ if (!container) container = this.element;
+
+ var itemList = [];
+ var contents = this.getDirectoryContents(container);
+
+ for (var i = 0; i < contents.length; i++) {
+ var node = contents[i];
+ var body = this.getChildBody(node);
+ var text = this.getChildBodyText(body);
+
+ var item = {};
+ item.id = node.id;
+
+ item.name = Element.collectTextNodes(text).replace(/\n/, '');
+ if (Element.hasClassName(node, TreeView.className.dir)) {
+ item.type = this.options.dirSymbol;
+ item.contents = this.parse(this.getChildDirContainer(node));
+
+ } else {
+ item.type = this.options.fileSymbol;
+ }
+
+ itemList.push(item);
+ }
+
+ return itemList;
+ },
+
+ refreshStateImg: function(element) {
+ if (!Element.hasClassName(element, TreeView.className.dir)) return;
+
+ var container = this.getChildDirContainer(element);
+ var img = this.getChildStateImg(element);
+
+ if (!this.hasContents(container) && !this.options.emptyImg)
+ this.classNames.refreshClassNames(img, 'state_empty');
+ else if (Element.visible(container))
+ this.classNames.refreshClassNames(img, 'state_open');
+ else
+ this.classNames.refreshClassNames(img, 'state_close');
+ },
+
+ removeById: function(element) {
+ element = $(element);
+ if (element) {
+ var parent = element.parentNode.parentNode;
+ Element.remove(element);
+ this.refreshStateImg(parent);
+ }
+ },
+
+ removeByPath: function(path) {
+ var paths = path.split('/').findAll(function(elm) {
+ return (elm != '');
+ });
+
+ var last = paths.pop();
+ var container = this.search(paths.join('/'));
+
+ var target = this.getDirectoryContents(container)[last];
+ if (target)
+ this.removeById(target);
+ },
+
+ removeBySelected: function() {
+ if (!this.selected) return;
+ this.removeById(this.selected);
+ this.selected = false;
+ },
+
+ renameById: function(name, element) {
+ element = $(element);
+ if (!Element.hasClassName(element, TreeView.className.dir) &&
+ !Element.hasClassName(element, TreeView.className.file)) {
+ return;
+ }
+ var node = this.getChildBodyTextNode(element);
+ node.nodeValue = name;
+ },
+
+ renameByPath: function(name, path) {
+ var paths = path.split('/').findAll(function(elm) {
+ return (elm != '');
+ });
+
+ var last = paths.pop();
+ var container = this.search(paths.join('/'));
+
+ var target = this.getDirectoryContents(container)[last];
+ if (target)
+ this.renameById(name, target);
+ },
+
+ renameBySelected: function(name) {
+ if (!this.selected) return;
+ this.renameById(name, this.selected);
+ },
+
+ search: function(path) {
+ var paths = path.split('/').findAll(function(elm) {
+ return (elm != '');
+ });
+
+ var container = this.element;
+ for (var i = 0; i < paths.length; i++) {
+ var num = paths[i];
+ var contents = this.getDirectoryContents(container);
+ if (contents[num] && Element.hasClassName(contents[num], TreeView.className.dir)) {
+ container = this.getChildDirContainer(contents[num]);
+ } else {
+ return false;
+ }
+ }
+ return container;
+ },
+
+ searchTextNode: function(element) {
+ var text = null;
+ var nodes = element.childNodes;
+
+ for (var i = 0; i < nodes.length; i++) {
+ if (nodes[i].nodeType == 3) {
+ text = nodes[i];
+ break;
+ } else if (nodes[i].nodeType == 1) {
+ var tmp = this.searchTextNode(nodes[i]);
+ if (tmp) {
+ text = tmp;
+ break;
+ }
+ }
+ }
+ return text;
+ },
+
+ selectDirItem: function(event) {
+ var itemBody = Element.getParentByClassName(TreeView.className.dirBody, Event.element(event));
+ this.selectItem(itemBody);
+ },
+
+ selectEffect: function(element) {
+ element = $(element);
+ if(element) {
+ var itemBody = element.firstChild;
+ if (this.selectItemUnselect(itemBody, false)) {
+ return;
+ }
+ this.selectItemSelect(itemBody, false);
+ }
+ },
+
+ selectFileItem: function(event) {
+ var itemBody = Element.getParentByClassName(TreeView.className.fileBody, Event.element(event));
+ this.selectItem(itemBody);
+ },
+
+ selectItem: function(itemBody) {
+ if (this.selectItemUnselect(itemBody, true)) {
+ return;
+ }
+ this.selectItemSelect(itemBody, true);
+ },
+
+ selectItemSelect: function(itemBody, callback) {
+ this.selected = itemBody.parentNode;
+ var text = this.getChildBodyText(itemBody);
+ if (Element.hasClassName(text, TreeView.className.dirBodyText)) {
+ this.classNames.refreshClassNames(text, 'dirBodyTextActive');
+ this.defaultCss = 'dirBodyText';
+ } else if (Element.hasClassName(text, TreeView.className.fileBodyText)) {
+ this.classNames.refreshClassNames(text, 'fileBodyTextActive');
+ this.defaultCss = 'fileBodyText';
+ }
+ if (callback) {
+ if (this.options.callBackFunctions) {
+ for (var i = 0; i < this.options.callBackFunctions.length; i++) {
+ this.options.callBackFunctions[i](itemBody.parentNode);
+ }
+ }
+ }
+ },
+
+ selectItemUnselect: function(itemBody, callback) {
+ if (this.selected) {
+ var selectedBody = this.getChildBody(this.selected);
+ var selectedText = this.getChildBodyText(selectedBody);
+ this.classNames.refreshClassNames(selectedText, this.defaultCss);
+ if (this.selected == itemBody.parentNode && this.options.enableUnselected) {
+ this.selected = false;
+ this.defaultCss = false;
+ if (callback) {
+ this.options.unselected();
+ }
+ return true;
+ }
+ }
+ return false;
+ },
+
+ setSortable: function() {
+ var options = Object.extend({
+ dropOnEmpty: true,
+ tree: true,
+ hoverclass: 'treeview_dirContainerHover',
+ scroll: window,
+ ghosting: true
+ }, this.options.sortOptions);
+ Sortable.create(this.element, options);
+ },
+
+ toggle: function(event) {
+ Event.stop(event);
+ var src = Event.element(event);
+ var parent = this.getParentDir(src);
+ var container = this.getChildDirContainer(parent);
+
+ if (!this.hasContents(container) && !this.options.emptyImg) return;
+
+ Element.toggle(container);
+ this.refreshStateImg(parent);
+
+ if (!this.hasContents(container) && !this.options.emptyImg)
+ this.options.openDir(parent, container);
+ else if (Element.visible(container))
+ this.options.openDir(parent, container);
+ else
+ this.options.closeDir(parent, container);
+ }
+}
--- /dev/null
+// Copyright (c) 2006 spinelz.org (http://script.spinelz.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var Window = Class.create();
+Window.className = {
+ window: 'window',
+ header: 'window_header',
+ headerLeft: 'window_headerLeft',
+ headerMiddle: 'window_headerMiddle',
+ headerRight: 'window_headerRight',
+ buttonHolder: 'window_buttonHolder',
+ closeButton: 'window_closeButton',
+ maxButton: 'window_maxButton',
+ minButton: 'window_minButton',
+ body: 'window_body',
+ bodyLeft: 'window_bodyLeft',
+ bodyMiddle: 'window_bodyMiddle',
+ bodyRight: 'window_bodyRight',
+ bottom: 'window_bottom',
+ bottomLeft: 'window_bottomLeft',
+ bottomMiddle: 'window_bottomMiddle',
+ bottomRight: 'window_bottomRight'
+}
+
+Window.prototype = {
+
+ initialize: function(element) {
+ var options = Object.extend({
+ className: Window.className.window,
+ width: 300,
+ height: 300,
+ minWidth: 200,
+ minHeight: 40,
+ drag: true,
+ resize: true,
+ resizeX: true,
+ resizeY: true,
+ modal: false,
+ closeButton: true,
+ maxButton: true,
+ minButton: true,
+ cssPrefix: 'custom_',
+ restriction: false,
+ endDrag: Prototype.emptyFunction,
+ endResize: Prototype.emptyFunction,
+ addButton: Prototype.emptyFunction,
+ preMaximize: function() {return true},
+ preMinimize: function() {return true},
+ preRevertMaximize: function() {return true},
+ preRevertMinimize: function() {return true},
+ preClose: function() {return true},
+ endMaximize: Prototype.emptyFunction,
+ endMinimize: Prototype.emptyFunction,
+ endRevertMaximize: Prototype.emptyFunction,
+ endRevertMinimize: Prototype.emptyFunction,
+ endClose: Prototype.emptyFunction,
+ dragOptions: {},
+ appendToBody: false
+ }, arguments[1] || {});
+
+ var customCss = CssUtil.appendPrefix(options.cssPrefix, Window.className);
+ this.classNames = new CssUtil([Window.className, customCss]);
+
+ this.element = $(element);
+ Element.setStyle(this.element, {visibility: 'hidden'});
+
+ this.options = options;
+ this.element.className = this.options.className;
+ this.header = null;
+ this.windowBody = null;
+ this.bottom = null;
+
+ this.elementId = this.element.id;
+ this.dragHandleId = this.elementId + '_dragHandle';
+
+ this.maxZindex = -1;
+ this.minFlag = false;
+ this.maxFlag = false;
+ this.currentPos = [0,0];
+ this.currentSize = [0,0];
+
+ this.buildWindow();
+ this.cover = new IECover(this.element, {padding: 10});
+
+ Element.makePositioned(element);
+ Element.hide(this.element);
+ Element.setStyle(this.element, {visibility: 'visible'});
+
+ if (this.options.appendToBody) this.appendToBody.callAfterLoading(this);
+ },
+
+ buildWindow: function() {
+ Element.cleanWhitespace(this.element);
+
+ with(this.element.style) {
+ width = this.options.width + 'px';
+ height= this.options.height + 'px';
+ }
+
+ var title = this.element.childNodes[0];
+ var content = this.element.childNodes[1];
+ this.buildHeader(title);
+ this.buildBody(content);
+ this.buildBottom();
+ var newStyle = {height: this.options.height};
+ this.setBodyHeight(newStyle);
+
+ if (this.options.drag) this.createDraggble();
+
+ if (this.options.resize) {
+ this.enableResizing();
+ }
+ },
+
+ buildHeader: function(title) {
+ var headerLeft = Builder.node('div');
+ this.classNames.addClassNames(headerLeft, 'headerLeft');
+
+ var headerMiddle = Builder.node('div', {id: this.dragHandleId});
+ this.classNames.addClassNames(headerMiddle, 'headerMiddle');
+
+ var headerRight = Builder.node('div');
+ this.classNames.addClassNames(headerRight, 'headerRight');
+
+ var buttonHolder = Builder.node('div');
+ this.classNames.addClassNames(buttonHolder, 'buttonHolder');
+
+ headerMiddle.appendChild(title);
+ var headerList = [headerLeft, headerMiddle, buttonHolder, headerRight];
+ this.header = Builder.node('div', headerList);
+ this.classNames.addClassNames(this.header, 'header');
+ this.element.appendChild(this.header);
+
+
+ if (this.options.closeButton) {
+ var closeButton = Builder.node('div', {id: this.element.id.appendSuffix('closeButton')});
+ this.classNames.addClassNames(closeButton, 'closeButton');
+ buttonHolder.appendChild(closeButton);
+ Event.observe(closeButton, 'click', this.close.bindAsEventListener(this));
+ }
+ if (this.options.maxButton) {
+ var maxButton = Builder.node('div', {id: this.element.id.appendSuffix('maxButton')});
+ this.classNames.addClassNames(maxButton, 'maxButton');
+ buttonHolder.appendChild(maxButton);
+ Event.observe(maxButton, 'click', this.maximize.bindAsEventListener(this));
+ }
+ if (this.options.minButton) {
+ var minButton = Builder.node('div', {id: this.element.id.appendSuffix('minButton')});
+ this.classNames.addClassNames(minButton, 'minButton');
+ buttonHolder.appendChild(minButton);
+ Event.observe(minButton, 'click', this.minimize.bindAsEventListener(this));
+ }
+
+ if (this.options.addButton) {
+ var addButton = this.options.addButton;
+ if (addButton.constructor == Function) {
+ addButton(buttonHolder);
+ } else if (addButton.constructor == Array) {
+ var self = this;
+ var firstChild = buttonHolder.firstChild;
+ addButton.each(function(b) {
+ var button = Builder.node('div', {id: b.id, className: b.className});
+ Event.observe(button, 'click', b.onclick.bindAsEventListener(self));
+ if (b.first && firstChild) {
+ buttonHolder.insertBefore(button, firstChild);
+ } else {
+ buttonHolder.appendChild(button);
+ }
+ });
+ }
+ }
+ },
+
+ buildBody: function(contents) {
+ var bodyLeft = Builder.node('div', {className: Window.className.bodyLeft});
+ this.classNames.addClassNames(bodyLeft, 'bodyLeft');
+
+ var bodyMiddle = Builder.node('div');
+ this.classNames.addClassNames(bodyMiddle, 'bodyMiddle');
+ bodyMiddle.appendChild(contents);
+
+ var bodyRight = Builder.node('div');
+ this.classNames.addClassNames(bodyRight, 'bodyRight');
+
+ var bodyList = [bodyRight,bodyLeft, bodyMiddle];
+ this.windowBody = Builder.node('div', bodyList);
+ this.classNames.addClassNames(this.windowBody, 'body');
+ this.element.appendChild(this.windowBody);
+ },
+
+ buildBottom: function() {
+ var bottomLeft = Builder.node('div');
+ this.classNames.addClassNames(bottomLeft, 'bottomLeft');
+
+ var bottomMiddle = Builder.node('div');
+ this.classNames.addClassNames(bottomMiddle, 'bottomMiddle');
+
+ var bottomRight = Builder.node('div');
+ this.classNames.addClassNames(bottomRight, 'bottomRight');
+
+ var bottomList = [bottomLeft, bottomMiddle, bottomRight];
+ this.bottom = Builder.node('div', bottomList);
+ this.classNames.addClassNames(this.bottom, 'bottom');
+ this.element.appendChild(this.bottom);
+ },
+
+ createDraggble: function() {
+ var self = this;
+ var options = Object.extend({
+ handle: this.dragHandleId,
+ starteffect: Prototype.emptyFunction,
+ endeffect: Prototype.emptyFunction,
+ endDrag: this.options.endDrag,
+ scroll: window
+ }, this.options.dragOptions);
+
+ if (this.options.restriction) {
+ options.snap = function(x, y) {
+ function constrain(n, lower, upper) {
+ if (n > upper) return upper;
+ else if (n < lower) return lower;
+ else return n;
+ }
+
+ var eDimensions = Element.getDimensions(self.element);
+ var pDimensions = Element.getDimensions(self.element.parentNode);
+
+ if (Element.getStyle(self.element.parentNode, 'position') == 'static') {
+ var offset = Position.positionedOffset(self.element.parentNode);
+ var parentLeft = offset[0];
+ var parentTop = offset[1];
+ return[
+ constrain(x, parentLeft, parentLeft + pDimensions.width - eDimensions.width),
+ constrain(y, parentTop, parentTop + pDimensions.height - eDimensions.height)
+ ];
+ } else {
+ return[
+ constrain(x, 0, pDimensions.width - eDimensions.width),
+ constrain(y, 0, pDimensions.height - eDimensions.height)
+ ];
+ }
+ }
+ } else {
+ var p = Position.cumulativeOffset(Position.offsetParent(this.element));
+ options.snap = function(x, y) {
+ return [
+ ((x + p[0]) >= 0) ? x : 0 - p[0],
+ ((y + p[1]) >= 0) ? y : 0 - p[1]
+ ];
+ }
+ }
+ new DraggableWindowEx(this.element, options);
+ },
+
+ setWindowZindex : function(zIndex) {
+ zIndex = this.getZindex(zIndex);
+ this.element.style.zIndex = zIndex;
+ },
+
+ getZindex: function(zIndex) {
+ return ZindexManager.getIndex(zIndex);
+ },
+
+ open: function(zIndex) {
+ this.opening = true;
+ if (this.options.modal) {
+ Modal.mask(this.element, {zIndex: zIndex});
+ } else {
+ this.setWindowZindex(zIndex);
+ }
+ Element.show(this.element);
+ this.cover.resetSize();
+ this.opening = false;
+ if (this.shouldClose) {
+ this.close();
+ this.shouldClose = false;
+ }
+ },
+
+ close: function() {
+ if (this.opening) this.shouldClose = true;
+ if (!this.options.preClose(this)) return;
+ this.element.style.zIndex = -1;
+ this.maxZindex = -1;
+ try {
+ Element.hide(this.element);
+ } catch(e) {}
+ if (this.options.modal) {
+ Modal.unmask();
+ }
+ this.options.endClose(this);
+ if (this.opening) this.shouldClose = true;
+ },
+
+ minimize: function(event) {
+ if (this.minFlag) {
+ if (!this.options.preRevertMinimize(this)) return;
+ Element.toggle(this.windowBody);
+ if (this.maxFlag) {
+ this.minFlag = false;
+ this.setMax();
+ } else {
+ var newStyle = {height:this.currentSize[1]}
+ this.setBodyHeight(newStyle);
+ this.element.style.width = this.currentSize[0];
+ this.element.style.height = this.currentSize[1];
+ this.element.style.left = this.currentPos[0];
+ this.element.style.top = this.currentPos[1];
+ this.maxFlag = false;
+ this.minFlag = false;
+ this.options.endRevertMinimize(this);
+ }
+ } else {
+ if (!this.options.preMinimize(this)) return;
+ Element.toggle(this.windowBody);
+ if (!this.maxFlag) {
+ this.currentPos = [Element.getStyle(this.element, 'left'), Element.getStyle(this.element, 'top')];
+ this.currentSize = [Element.getStyle(this.element, 'width'), Element.getStyle(this.element, 'height')];
+ }
+ this.setMin();
+ this.minFlag = true;
+ this.options.endMinimize(this);
+ }
+ this.cover.resetSize();
+ },
+
+ maximize: function(event) {
+ if (this.maxFlag) {
+ if (this.minFlag) {
+ Element.toggle(this.windowBody);
+ this.minFlag = false;
+ this.setMax();
+ } else {
+ if (!this.options.preRevertMaximize(this)) return;
+ var newStyle = {height:parseInt(this.currentSize[1])}
+ this.setBodyHeight(newStyle);
+ this.element.style.width = this.currentSize[0];
+ this.element.style.height = this.currentSize[1];
+ this.element.style.left = this.currentPos[0];
+ this.element.style.top = this.currentPos[1];
+ this.maxFlag = false;
+ this.minFlag = false;
+ document.body.style.overflow = '';
+ this.element.style.position = this.position;
+ if (this.parent) {
+ if (this.nextElement) {
+ this.parent.insertBefore(this.element, this.nextElement);
+ } else {
+ this.parent.appendChild(this.element);
+ }
+ }
+ this.options.endRevertMaximize(this);
+ }
+
+ } else {
+ if (!this.options.preMaximize(this)) return;
+ if (!this.minFlag) {
+ this.currentPos = [Element.getStyle(this.element, 'left'), Element.getStyle(this.element, 'top')];
+ this.currentSize = [Element.getStyle(this.element, 'width'), Element.getStyle(this.element, 'height')];
+ } else {
+ Element.toggle(this.windowBody);
+ this.minFlag = false;
+ }
+ this.parent = this.element.parentNode;
+ this.nextElement = Element.next(this.element, 0);
+ this.position = Element.getStyle(this.element, 'position');
+ document.body.style.overflow = 'hidden';
+ document.body.appendChild(this.element);
+ this.element.style.position = 'absolute';
+ this.setMax();
+ this.maxFlag = true;
+ this.options.endMaximize(this);
+ }
+ this.cover.resetSize();
+ },
+
+ setMin : function() {
+ var minHeight = this.header.offsetHeight + this.bottom.offsetHeight;
+ var minWidth = this.options.minWidth;
+ this.element.style.height = minHeight + 'px';
+ this.element.style.width = minWidth + 'px';
+ },
+
+ setMax : function(zIndex) {
+ var maxW = Element.getWindowWidth();
+ var maxH = Element.getWindowHeight();
+ var newStatus = {height:maxH}
+ with(this.element.style) {
+ width = maxW + 'px';
+ height = maxH + 'px';
+ left = '0px';
+ top = '0px';
+ }
+ this.setBodyHeight(newStatus);
+ this.setWindowZindex(zIndex);
+ },
+
+ _getParentWidth: function(parent) {
+ if (parent && parent.style) {
+ var width = parent.style.width;
+ var index = 0;
+ if (width) {
+ if ((index = width.indexOf('px', 0)) > 0) {
+ return parseInt(width);
+ } else if ((index = width.indexOf('%', 0)) > 0) {
+ var pw = this._getParentWidth(parent.parentNode);
+
+ var par = parseInt(width);
+ return pw * par / 100;
+ } else if (!width.isNaN) {
+ return parseInt(width);
+ }
+ } else if (parent == document.body){
+ return Element.getWindowWidth();
+ }
+ }
+ },
+
+ setHeight: function(height) {
+ height = {height: height};
+ Element.setStyle(this.element, height);
+ this.setBodyHeight(height);
+ },
+
+ setBodyHeight: function(newStyle) {
+ var height = parseInt(newStyle.height);
+ if (height > this.options.minHeight) {
+ var newHeight = (height - this.header.offsetHeight - this.bottom.offsetHeight) + 'px';
+ this.windowBody.childNodes[0].style.height = newHeight;
+ this.windowBody.childNodes[1].style.height = newHeight;
+ this.windowBody.childNodes[2].style.height = newHeight;
+ this.windowBody.style.height = newHeight;
+ }
+ if (this.cover) this.cover.resetSize();
+ },
+
+ center: function() {
+ var w = parseInt(Element.getStyle(this.element, 'width'));
+ var h = parseInt(Element.getStyle(this.element, 'height'));
+
+ var pOffset = Position.cumulativeOffset(Position.offsetParent(this.element));
+
+ var left = (Element.getWindowWidth() - w) / 2;
+ var top = (Element.getWindowHeight() - h) / 2;
+ var scrollTop = (document.documentElement.scrollTop || document.body.scrollTop);
+ var scrollLeft = (document.documentElement.scrollLeft || document.body.scrollLeft);
+
+ top += scrollTop - pOffset[1];
+ left += scrollLeft - pOffset[0];
+ top = ((top + pOffset[1]) >= 0) ? top : 0 - pOffset[1];
+ left = ((left + pOffset[0]) >= 0) ? left : 0 - pOffset[0];
+ Element.setStyle(this.element, {left: left + 'px', top: top + 'px'});
+ },
+
+ enableResizing: function() {
+ var resTop = this.options.resizeY ? 6 : 0;
+ var resBottom = this.options.resizeY ? 6 : 0;
+ var resLeft = this.options.resizeX ? 6 : 0;
+ var resRight = this.options.resizeX ? 6 : 0;
+ this.resizeable = new ResizeableWindowEx(this.element, {
+ top: resTop,
+ bottom: resBottom,
+ left: resLeft,
+ right: resRight,
+ minWidth: this.options.minWidth,
+ minHeight: this.options.minHeight,
+ draw: this.setBodyHeight.bind(this),
+ resize: this.options.endResize,
+ restriction: this.options.restriction,
+ zindex: 2000
+ });
+ },
+
+ disableResizing: function() {
+ this.resizeable.destroy();
+ },
+
+ appendToBody: function() {
+ this.removeFromBody(this.element.id)
+ document.body.appendChild(this.element);
+ },
+
+ removeFromBody: function(dom_id) {
+ $A(document.body.childNodes).each(function(node){
+ if (node.id == dom_id) node.remove();
+ });
+ }
+}
+
+
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
+//
+// This code is substantially based on code from script.aculo.us which has the
+// following copyright and permission notice
+//
+// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var DraggableWindowEx = Class.create();
+Object.extend(DraggableWindowEx.prototype, Draggable.prototype);
+Object.extend(DraggableWindowEx.prototype, {
+ initDrag: function(event) {
+ if(Event.isLeftClick(event)) {
+ // abort on form elements, fixes a Firefox issue
+ var src = Event.element(event);
+ if(src.tagName && (
+ src.tagName=='INPUT' ||
+ src.tagName=='SELECT' ||
+ src.tagName=='OPTION' ||
+ src.tagName=='BUTTON' ||
+ src.tagName=='TEXTAREA')) return;
+
+ if(this.element._revert) {
+ this.element._revert.cancel();
+ this.element._revert = null;
+ }
+
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var pos = Position.cumulativeOffset(this.element);
+ this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
+
+ var zIndex = ZindexManager.getIndex();
+ this.originalZ = zIndex;
+ this.options.zindex = zIndex;
+ Element.setStyle(this.element, {zIndex: zIndex});
+
+ Draggables.activate(this);
+ Event.stop(event);
+ }
+ },
+
+ endDrag: function(event) {
+ if(!this.dragging) return;
+ this.stopScrolling();
+ this.finishDrag(event, true);
+
+ this.options.endDrag();
+ Event.stop(event);
+ }
+});
+
--- /dev/null
+// Copyright (c) 2005 spinelz.org (http://script.spinelz.org/)
+//
+// This code is substantially based on code from Thomas Fakes(http://craz8.com)
+// which has the following copyright and permission notice
+//
+// Copyright (c) 2005 Thomas Fakes (http://craz8.com)
+//
+// This code is substantially based on code from script.aculo.us which has the
+// following copyright and permission notice
+//
+// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ResizeableWindowEx = Class.create();
+Object.extend(Object.extend(ResizeableWindowEx.prototype, Resizeable.prototype), {
+ startResize: function(event) {
+ if (Event.isLeftClick(event)) {
+
+ // abort on form elements, fixes a Firefox issue
+ var src = Event.element(event);
+ if(src.tagName && (
+ src.tagName=='INPUT' ||
+ src.tagName=='SELECT' ||
+ src.tagName=='BUTTON' ||
+ src.tagName=='TEXTAREA')) return;
+
+ var dir = this.directions(event);
+ if (dir.length > 0) {
+ this.active = true;
+ var offsets = Position.cumulativeOffset(this.element);
+ this.startTop = offsets[1];
+ this.startLeft = offsets[0];
+ this.startWidth = parseInt(Element.getStyle(this.element, 'width'));
+ this.startHeight = parseInt(Element.getStyle(this.element, 'height'));
+ this.startX = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
+ this.startY = event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
+
+ this.currentDirection = dir;
+ Event.stop(event);
+ }
+
+ if (this.options.restriction) {
+ var parent = this.element.parentNode;
+ var dimensions = Element.getDimensions(parent);
+ this.parentOffset = Position.cumulativeOffset(parent);
+ this.parentWidth = this.parentOffset[0] + dimensions.width;
+ this.parentHeight = this.parentOffset[1] + dimensions.height;
+ }
+ }
+ },
+
+ draw: function(event) {
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ if (this.options.restriction &&
+ (
+ (this.parentWidth <= pointer[0])
+ || (this.parentHeight <= pointer[1])
+ || (this.parentOffset[0] >= pointer[0])
+ || (this.parentOffset[1] >= pointer[1])
+ )) return;
+
+ var style = this.element.style;
+ var newHeight = style.height;
+ var newWidth = style.width;
+ var newTop = style.top;
+ var newLeft = style.left;
+
+ if (this.currentDirection.indexOf('n') != -1) {
+ var pointerMoved = this.startY - pointer[1];
+ var margin = Element.getStyle(this.element, 'margin-top') || "0";
+ newHeight = this.startHeight + pointerMoved;
+ newTop = (this.startTop - pointerMoved - parseInt(margin)) + "px";
+ }
+
+ if (this.currentDirection.indexOf('w') != -1) {
+ var pointerMoved = this.startX - pointer[0];
+ var margin = Element.getStyle(this.element, 'margin-left') || "0";
+ newWidth = this.startWidth + pointerMoved;
+ newLeft = this.startLeft - pointerMoved - parseInt(margin);
+ if (this.options.restriction) newLeft -= this.parentOffset[0];
+ newLeft += 'px';
+ }
+
+ if (this.currentDirection.indexOf('s') != -1) {
+ newHeight = this.startHeight + pointer[1] - this.startY;
+ }
+
+ if (this.currentDirection.indexOf('e') != -1) {
+ newWidth = this.startWidth + pointer[0] - this.startX;
+ }
+
+ var newStyle = {
+ height: newHeight,
+ width: newWidth,
+ top: newTop,
+ left: newLeft
+ }
+ if (this.options.draw) {
+ this.options.draw(newStyle, this.element);
+ }
+
+ if (newHeight && newHeight > this.options.minHeight) {
+ style.top = newStyle.top;
+ style.height = newStyle.height + "px";
+ }
+ if (newWidth && newWidth > this.options.minWidth) {
+ style.left = newStyle.left;
+ style.width = newStyle.width + "px";
+ }
+ if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
+ }
+});
--- /dev/null
+// script.aculo.us builder.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006
+
+// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//
+// See scriptaculous.js for full license.
+
+var Builder = {
+ NODEMAP: {
+ AREA: 'map',
+ CAPTION: 'table',
+ COL: 'table',
+ COLGROUP: 'table',
+ LEGEND: 'fieldset',
+ OPTGROUP: 'select',
+ OPTION: 'select',
+ PARAM: 'object',
+ TBODY: 'table',
+ TD: 'table',
+ TFOOT: 'table',
+ TH: 'table',
+ THEAD: 'table',
+ TR: 'table'
+ },
+ // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken,
+ // due to a Firefox bug
+ node: function(elementName) {
+ elementName = elementName.toUpperCase();
+
+ // try innerHTML approach
+ var parentTag = this.NODEMAP[elementName] || 'div';
+ var parentElement = document.createElement(parentTag);
+ try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
+ parentElement.innerHTML = "<" + elementName + "></" + elementName + ">";
+ } catch(e) {}
+ var element = parentElement.firstChild || null;
+
+ // see if browser added wrapping tags
+ if(element && (element.tagName != elementName))
+ element = element.getElementsByTagName(elementName)[0];
+
+ // fallback to createElement approach
+ if(!element) element = document.createElement(elementName);
+
+ // abort if nothing could be created
+ if(!element) return;
+
+ // attributes (or text)
+ if(arguments[1])
+ if(this._isStringOrNumber(arguments[1]) ||
+ (arguments[1] instanceof Array)) {
+ this._children(element, arguments[1]);
+ } else {
+ var attrs = this._attributes(arguments[1]);
+ if(attrs.length) {
+ try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
+ parentElement.innerHTML = "<" +elementName + " " +
+ attrs + "></" + elementName + ">";
+ } catch(e) {}
+ element = parentElement.firstChild || null;
+ // workaround firefox 1.0.X bug
+ if(!element) {
+ element = document.createElement(elementName);
+ for(attr in arguments[1])
+ element[attr == 'class' ? 'className' : attr] = arguments[1][attr];
+ }
+ if(element.tagName != elementName)
+ element = parentElement.getElementsByTagName(elementName)[0];
+ }
+ }
+
+ // text, or array of children
+ if(arguments[2])
+ this._children(element, arguments[2]);
+
+ return element;
+ },
+ _text: function(text) {
+ return document.createTextNode(text);
+ },
+ _attributes: function(attributes) {
+ var attrs = [];
+ for(attribute in attributes)
+ attrs.push((attribute=='className' ? 'class' : attribute) +
+ '="' + attributes[attribute].toString().escapeHTML() + '"');
+ return attrs.join(" ");
+ },
+ _children: function(element, children) {
+ if(typeof children=='object') { // array can hold nodes and text
+ children.flatten().each( function(e) {
+ if(typeof e=='object')
+ element.appendChild(e)
+ else
+ if(Builder._isStringOrNumber(e))
+ element.appendChild(Builder._text(e));
+ });
+ } else
+ if(Builder._isStringOrNumber(children))
+ element.appendChild(Builder._text(children));
+ },
+ _isStringOrNumber: function(param) {
+ return(typeof param=='string' || typeof param=='number');
+ },
+ dump: function(scope) {
+ if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope
+
+ var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " +
+ "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " +
+ "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+
+ "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+
+ "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+
+ "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);
+
+ tags.each( function(tag){
+ scope[tag] = function() {
+ return Builder.node.apply(Builder, [tag].concat($A(arguments)));
+ }
+ });
+ }
+}
\ No newline at end of file
--- /dev/null
+// script.aculo.us controls.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006
+
+// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
+// (c) 2005 Jon Tirsen (http://www.tirsen.com)
+// Contributors:
+// Richard Livsey
+// Rahul Bhargava
+// Rob Wills
+//
+// See scriptaculous.js for full license.
+
+// Autocompleter.Base handles all the autocompletion functionality
+// that's independent of the data source for autocompletion. This
+// includes drawing the autocompletion menu, observing keyboard
+// and mouse events, and similar.
+//
+// Specific autocompleters need to provide, at the very least,
+// a getUpdatedChoices function that will be invoked every time
+// the text inside the monitored textbox changes. This method
+// should get the text for which to provide autocompletion by
+// invoking this.getToken(), NOT by directly accessing
+// this.element.value. This is to allow incremental tokenized
+// autocompletion. Specific auto-completion logic (AJAX, etc)
+// belongs in getUpdatedChoices.
+//
+// Tokenized incremental autocompletion is enabled automatically
+// when an autocompleter is instantiated with the 'tokens' option
+// in the options parameter, e.g.:
+// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' });
+// will incrementally autocomplete with a comma as the token.
+// Additionally, ',' in the above example can be replaced with
+// a token array, e.g. { tokens: [',', '\n'] } which
+// enables autocompletion on multiple tokens. This is most
+// useful when one of the tokens is \n (a newline), as it
+// allows smart autocompletion after linebreaks.
+
+if(typeof Effect == 'undefined')
+ throw("controls.js requires including script.aculo.us' effects.js library");
+
+var Autocompleter = {}
+Autocompleter.Base = function() {};
+Autocompleter.Base.prototype = {
+ baseInitialize: function(element, update, options) {
+ this.element = $(element);
+ this.update = $(update);
+ this.hasFocus = false;
+ this.changed = false;
+ this.active = false;
+ this.index = 0;
+ this.entryCount = 0;
+
+ if(this.setOptions)
+ this.setOptions(options);
+ else
+ this.options = options || {};
+
+ this.options.paramName = this.options.paramName || this.element.name;
+ this.options.tokens = this.options.tokens || [];
+ this.options.frequency = this.options.frequency || 0.4;
+ this.options.minChars = this.options.minChars || 1;
+ this.options.onShow = this.options.onShow ||
+ function(element, update){
+ if(!update.style.position || update.style.position=='absolute') {
+ update.style.position = 'absolute';
+ Position.clone(element, update, {
+ setHeight: false,
+ offsetTop: element.offsetHeight
+ });
+ }
+ Effect.Appear(update,{duration:0.15});
+ };
+ this.options.onHide = this.options.onHide ||
+ function(element, update){ new Effect.Fade(update,{duration:0.15}) };
+
+ if(typeof(this.options.tokens) == 'string')
+ this.options.tokens = new Array(this.options.tokens);
+
+ this.observer = null;
+
+ this.element.setAttribute('autocomplete','off');
+
+ Element.hide(this.update);
+
+ Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this));
+ Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this));
+ },
+
+ show: function() {
+ if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
+ if(!this.iefix &&
+ (navigator.appVersion.indexOf('MSIE')>0) &&
+ (navigator.userAgent.indexOf('Opera')<0) &&
+ (Element.getStyle(this.update, 'position')=='absolute')) {
+ new Insertion.After(this.update,
+ '<iframe id="' + this.update.id + '_iefix" '+
+ 'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +
+ 'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
+ this.iefix = $(this.update.id+'_iefix');
+ }
+ if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
+ },
+
+ fixIEOverlapping: function() {
+ Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
+ this.iefix.style.zIndex = 1;
+ this.update.style.zIndex = 2;
+ Element.show(this.iefix);
+ },
+
+ hide: function() {
+ this.stopIndicator();
+ if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update);
+ if(this.iefix) Element.hide(this.iefix);
+ },
+
+ startIndicator: function() {
+ if(this.options.indicator) Element.show(this.options.indicator);
+ },
+
+ stopIndicator: function() {
+ if(this.options.indicator) Element.hide(this.options.indicator);
+ },
+
+ onKeyPress: function(event) {
+ if(this.active)
+ switch(event.keyCode) {
+ case Event.KEY_TAB:
+ case Event.KEY_RETURN:
+ this.selectEntry();
+ Event.stop(event);
+ case Event.KEY_ESC:
+ this.hide();
+ this.active = false;
+ Event.stop(event);
+ return;
+ case Event.KEY_LEFT:
+ case Event.KEY_RIGHT:
+ return;
+ case Event.KEY_UP:
+ this.markPrevious();
+ this.render();
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
+ return;
+ case Event.KEY_DOWN:
+ this.markNext();
+ this.render();
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
+ return;
+ }
+ else
+ if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
+ (navigator.appVersion.indexOf('AppleWebKit') > 0 && event.keyCode == 0)) return;
+
+ this.changed = true;
+ this.hasFocus = true;
+
+ if(this.observer) clearTimeout(this.observer);
+ this.observer =
+ setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
+ },
+
+ activate: function() {
+ this.changed = false;
+ this.hasFocus = true;
+ this.getUpdatedChoices();
+ },
+
+ onHover: function(event) {
+ var element = Event.findElement(event, 'LI');
+ if(this.index != element.autocompleteIndex)
+ {
+ this.index = element.autocompleteIndex;
+ this.render();
+ }
+ Event.stop(event);
+ },
+
+ onClick: function(event) {
+ var element = Event.findElement(event, 'LI');
+ this.index = element.autocompleteIndex;
+ this.selectEntry();
+ this.hide();
+ },
+
+ onBlur: function(event) {
+ // needed to make click events working
+ setTimeout(this.hide.bind(this), 250);
+ this.hasFocus = false;
+ this.active = false;
+ },
+
+ render: function() {
+ if(this.entryCount > 0) {
+ for (var i = 0; i < this.entryCount; i++)
+ this.index==i ?
+ Element.addClassName(this.getEntry(i),"selected") :
+ Element.removeClassName(this.getEntry(i),"selected");
+
+ if(this.hasFocus) {
+ this.show();
+ this.active = true;
+ }
+ } else {
+ this.active = false;
+ this.hide();
+ }
+ },
+
+ markPrevious: function() {
+ if(this.index > 0) this.index--
+ else this.index = this.entryCount-1;
+ this.getEntry(this.index).scrollIntoView(true);
+ },
+
+ markNext: function() {
+ if(this.index < this.entryCount-1) this.index++
+ else this.index = 0;
+ this.getEntry(this.index).scrollIntoView(false);
+ },
+
+ getEntry: function(index) {
+ return this.update.firstChild.childNodes[index];
+ },
+
+ getCurrentEntry: function() {
+ return this.getEntry(this.index);
+ },
+
+ selectEntry: function() {
+ this.active = false;
+ this.updateElement(this.getCurrentEntry());
+ },
+
+ updateElement: function(selectedElement) {
+ if (this.options.updateElement) {
+ this.options.updateElement(selectedElement);
+ return;
+ }
+ var value = '';
+ if (this.options.select) {
+ var nodes = document.getElementsByClassName(this.options.select, selectedElement) || [];
+ if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
+ } else
+ value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
+
+ var lastTokenPos = this.findLastToken();
+ if (lastTokenPos != -1) {
+ var newValue = this.element.value.substr(0, lastTokenPos + 1);
+ var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/);
+ if (whitespace)
+ newValue += whitespace[0];
+ this.element.value = newValue + value;
+ } else {
+ this.element.value = value;
+ }
+ this.element.focus();
+
+ if (this.options.afterUpdateElement)
+ this.options.afterUpdateElement(this.element, selectedElement);
+ },
+
+ updateChoices: function(choices) {
+ if(!this.changed && this.hasFocus) {
+ this.update.innerHTML = choices;
+ Element.cleanWhitespace(this.update);
+ Element.cleanWhitespace(this.update.firstChild);
+
+ if(this.update.firstChild && this.update.firstChild.childNodes) {
+ this.entryCount =
+ this.update.firstChild.childNodes.length;
+ for (var i = 0; i < this.entryCount; i++) {
+ var entry = this.getEntry(i);
+ entry.autocompleteIndex = i;
+ this.addObservers(entry);
+ }
+ } else {
+ this.entryCount = 0;
+ }
+
+ this.stopIndicator();
+ this.index = 0;
+
+ if(this.entryCount==1 && this.options.autoSelect) {
+ this.selectEntry();
+ this.hide();
+ } else {
+ this.render();
+ }
+ }
+ },
+
+ addObservers: function(element) {
+ Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this));
+ Event.observe(element, "click", this.onClick.bindAsEventListener(this));
+ },
+
+ onObserverEvent: function() {
+ this.changed = false;
+ if(this.getToken().length>=this.options.minChars) {
+ this.startIndicator();
+ this.getUpdatedChoices();
+ } else {
+ this.active = false;
+ this.hide();
+ }
+ },
+
+ getToken: function() {
+ var tokenPos = this.findLastToken();
+ if (tokenPos != -1)
+ var ret = this.element.value.substr(tokenPos + 1).replace(/^\s+/,'').replace(/\s+$/,'');
+ else
+ var ret = this.element.value;
+
+ return /\n/.test(ret) ? '' : ret;
+ },
+
+ findLastToken: function() {
+ var lastTokenPos = -1;
+
+ for (var i=0; i<this.options.tokens.length; i++) {
+ var thisTokenPos = this.element.value.lastIndexOf(this.options.tokens[i]);
+ if (thisTokenPos > lastTokenPos)
+ lastTokenPos = thisTokenPos;
+ }
+ return lastTokenPos;
+ }
+}
+
+Ajax.Autocompleter = Class.create();
+Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), {
+ initialize: function(element, update, url, options) {
+ this.baseInitialize(element, update, options);
+ this.options.asynchronous = true;
+ this.options.onComplete = this.onComplete.bind(this);
+ this.options.defaultParams = this.options.parameters || null;
+ this.url = url;
+ },
+
+ getUpdatedChoices: function() {
+ entry = encodeURIComponent(this.options.paramName) + '=' +
+ encodeURIComponent(this.getToken());
+
+ this.options.parameters = this.options.callback ?
+ this.options.callback(this.element, entry) : entry;
+
+ if(this.options.defaultParams)
+ this.options.parameters += '&' + this.options.defaultParams;
+
+ new Ajax.Request(this.url, this.options);
+ },
+
+ onComplete: function(request) {
+ this.updateChoices(request.responseText);
+ }
+
+});
+
+// The local array autocompleter. Used when you'd prefer to
+// inject an array of autocompletion options into the page, rather
+// than sending out Ajax queries, which can be quite slow sometimes.
+//
+// The constructor takes four parameters. The first two are, as usual,
+// the id of the monitored textbox, and id of the autocompletion menu.
+// The third is the array you want to autocomplete from, and the fourth
+// is the options block.
+//
+// Extra local autocompletion options:
+// - choices - How many autocompletion choices to offer
+//
+// - partialSearch - If false, the autocompleter will match entered
+// text only at the beginning of strings in the
+// autocomplete array. Defaults to true, which will
+// match text at the beginning of any *word* in the
+// strings in the autocomplete array. If you want to
+// search anywhere in the string, additionally set
+// the option fullSearch to true (default: off).
+//
+// - fullSsearch - Search anywhere in autocomplete array strings.
+//
+// - partialChars - How many characters to enter before triggering
+// a partial match (unlike minChars, which defines
+// how many characters are required to do any match
+// at all). Defaults to 2.
+//
+// - ignoreCase - Whether to ignore case when autocompleting.
+// Defaults to true.
+//
+// It's possible to pass in a custom function as the 'selector'
+// option, if you prefer to write your own autocompletion logic.
+// In that case, the other options above will not apply unless
+// you support them.
+
+Autocompleter.Local = Class.create();
+Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), {
+ initialize: function(element, update, array, options) {
+ this.baseInitialize(element, update, options);
+ this.options.array = array;
+ },
+
+ getUpdatedChoices: function() {
+ this.updateChoices(this.options.selector(this));
+ },
+
+ setOptions: function(options) {
+ this.options = Object.extend({
+ choices: 10,
+ partialSearch: true,
+ partialChars: 2,
+ ignoreCase: true,
+ fullSearch: false,
+ selector: function(instance) {
+ var ret = []; // Beginning matches
+ var partial = []; // Inside matches
+ var entry = instance.getToken();
+ var count = 0;
+
+ for (var i = 0; i < instance.options.array.length &&
+ ret.length < instance.options.choices ; i++) {
+
+ var elem = instance.options.array[i];
+ var foundPos = instance.options.ignoreCase ?
+ elem.toLowerCase().indexOf(entry.toLowerCase()) :
+ elem.indexOf(entry);
+
+ while (foundPos != -1) {
+ if (foundPos == 0 && elem.length != entry.length) {
+ ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
+ elem.substr(entry.length) + "</li>");
+ break;
+ } else if (entry.length >= instance.options.partialChars &&
+ instance.options.partialSearch && foundPos != -1) {
+ if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
+ partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" +
+ elem.substr(foundPos, entry.length) + "</strong>" + elem.substr(
+ foundPos + entry.length) + "</li>");
+ break;
+ }
+ }
+
+ foundPos = instance.options.ignoreCase ?
+ elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
+ elem.indexOf(entry, foundPos + 1);
+
+ }
+ }
+ if (partial.length)
+ ret = ret.concat(partial.slice(0, instance.options.choices - ret.length))
+ return "<ul>" + ret.join('') + "</ul>";
+ }
+ }, options || {});
+ }
+});
+
+// AJAX in-place editor
+//
+// see documentation on http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor
+
+// Use this if you notice weird scrolling problems on some browsers,
+// the DOM might be a bit confused when this gets called so do this
+// waits 1 ms (with setTimeout) until it does the activation
+Field.scrollFreeActivate = function(field) {
+ setTimeout(function() {
+ Field.activate(field);
+ }, 1);
+}
+
+Ajax.InPlaceEditor = Class.create();
+Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99";
+Ajax.InPlaceEditor.prototype = {
+ initialize: function(element, url, options) {
+ this.url = url;
+ this.element = $(element);
+
+ this.options = Object.extend({
+ okButton: true,
+ okText: "ok",
+ cancelLink: true,
+ cancelText: "cancel",
+ savingText: "Saving...",
+ clickToEditText: "Click to edit",
+ okText: "ok",
+ rows: 1,
+ onComplete: function(transport, element) {
+ new Effect.Highlight(element, {startcolor: this.options.highlightcolor});
+ },
+ onFailure: function(transport) {
+ alert("Error communicating with the server: " + transport.responseText.stripTags());
+ },
+ callback: function(form) {
+ return Form.serialize(form);
+ },
+ handleLineBreaks: true,
+ loadingText: 'Loading...',
+ savingClassName: 'inplaceeditor-saving',
+ loadingClassName: 'inplaceeditor-loading',
+ formClassName: 'inplaceeditor-form',
+ highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor,
+ highlightendcolor: "#FFFFFF",
+ externalControl: null,
+ submitOnBlur: false,
+ ajaxOptions: {},
+ evalScripts: false
+ }, options || {});
+
+ if(!this.options.formId && this.element.id) {
+ this.options.formId = this.element.id + "-inplaceeditor";
+ if ($(this.options.formId)) {
+ // there's already a form with that name, don't specify an id
+ this.options.formId = null;
+ }
+ }
+
+ if (this.options.externalControl) {
+ this.options.externalControl = $(this.options.externalControl);
+ }
+
+ this.originalBackground = Element.getStyle(this.element, 'background-color');
+ if (!this.originalBackground) {
+ this.originalBackground = "transparent";
+ }
+
+ this.element.title = this.options.clickToEditText;
+
+ this.onclickListener = this.enterEditMode.bindAsEventListener(this);
+ this.mouseoverListener = this.enterHover.bindAsEventListener(this);
+ this.mouseoutListener = this.leaveHover.bindAsEventListener(this);
+ Event.observe(this.element, 'click', this.onclickListener);
+ Event.observe(this.element, 'mouseover', this.mouseoverListener);
+ Event.observe(this.element, 'mouseout', this.mouseoutListener);
+ if (this.options.externalControl) {
+ Event.observe(this.options.externalControl, 'click', this.onclickListener);
+ Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener);
+ Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener);
+ }
+ },
+ enterEditMode: function(evt) {
+ if (this.saving) return;
+ if (this.editing) return;
+ this.editing = true;
+ this.onEnterEditMode();
+ if (this.options.externalControl) {
+ Element.hide(this.options.externalControl);
+ }
+ Element.hide(this.element);
+ this.createForm();
+ this.element.parentNode.insertBefore(this.form, this.element);
+ if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField);
+ // stop the event to avoid a page refresh in Safari
+ if (evt) {
+ Event.stop(evt);
+ }
+ return false;
+ },
+ createForm: function() {
+ this.form = document.createElement("form");
+ this.form.id = this.options.formId;
+ Element.addClassName(this.form, this.options.formClassName)
+ this.form.onsubmit = this.onSubmit.bind(this);
+
+ this.createEditField();
+
+ if (this.options.textarea) {
+ var br = document.createElement("br");
+ this.form.appendChild(br);
+ }
+
+ if (this.options.okButton) {
+ okButton = document.createElement("input");
+ okButton.type = "submit";
+ okButton.value = this.options.okText;
+ okButton.className = 'editor_ok_button';
+ this.form.appendChild(okButton);
+ }
+
+ if (this.options.cancelLink) {
+ cancelLink = document.createElement("a");
+ cancelLink.href = "#";
+ cancelLink.appendChild(document.createTextNode(this.options.cancelText));
+ cancelLink.onclick = this.onclickCancel.bind(this);
+ cancelLink.className = 'editor_cancel';
+ this.form.appendChild(cancelLink);
+ }
+ },
+ hasHTMLLineBreaks: function(string) {
+ if (!this.options.handleLineBreaks) return false;
+ return string.match(/<br/i) || string.match(/<p>/i);
+ },
+ convertHTMLLineBreaks: function(string) {
+ return string.replace(/<br>/gi, "\n").replace(/<br\/>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<p>/gi, "");
+ },
+ createEditField: function() {
+ var text;
+ if(this.options.loadTextURL) {
+ text = this.options.loadingText;
+ } else {
+ text = this.getText();
+ }
+
+ var obj = this;
+
+ if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) {
+ this.options.textarea = false;
+ var textField = document.createElement("input");
+ textField.obj = this;
+ textField.type = "text";
+ textField.name = "value";
+ textField.value = text;
+ textField.style.backgroundColor = this.options.highlightcolor;
+ textField.className = 'editor_field';
+ var size = this.options.size || this.options.cols || 0;
+ if (size != 0) textField.size = size;
+ if (this.options.submitOnBlur)
+ textField.onblur = this.onSubmit.bind(this);
+ this.editField = textField;
+ } else {
+ this.options.textarea = true;
+ var textArea = document.createElement("textarea");
+ textArea.obj = this;
+ textArea.name = "value";
+ textArea.value = this.convertHTMLLineBreaks(text);
+ textArea.rows = this.options.rows;
+ textArea.cols = this.options.cols || 40;
+ textArea.className = 'editor_field';
+ if (this.options.submitOnBlur)
+ textArea.onblur = this.onSubmit.bind(this);
+ this.editField = textArea;
+ }
+
+ if(this.options.loadTextURL) {
+ this.loadExternalText();
+ }
+ this.form.appendChild(this.editField);
+ },
+ getText: function() {
+ return this.element.innerHTML;
+ },
+ loadExternalText: function() {
+ Element.addClassName(this.form, this.options.loadingClassName);
+ this.editField.disabled = true;
+ new Ajax.Request(
+ this.options.loadTextURL,
+ Object.extend({
+ asynchronous: true,
+ onComplete: this.onLoadedExternalText.bind(this)
+ }, this.options.ajaxOptions)
+ );
+ },
+ onLoadedExternalText: function(transport) {
+ Element.removeClassName(this.form, this.options.loadingClassName);
+ this.editField.disabled = false;
+ this.editField.value = transport.responseText.stripTags();
+ Field.scrollFreeActivate(this.editField);
+ },
+ onclickCancel: function() {
+ this.onComplete();
+ this.leaveEditMode();
+ return false;
+ },
+ onFailure: function(transport) {
+ this.options.onFailure(transport);
+ if (this.oldInnerHTML) {
+ this.element.innerHTML = this.oldInnerHTML;
+ this.oldInnerHTML = null;
+ }
+ return false;
+ },
+ onSubmit: function() {
+ // onLoading resets these so we need to save them away for the Ajax call
+ var form = this.form;
+ var value = this.editField.value;
+
+ // do this first, sometimes the ajax call returns before we get a chance to switch on Saving...
+ // which means this will actually switch on Saving... *after* we've left edit mode causing Saving...
+ // to be displayed indefinitely
+ this.onLoading();
+
+ if (this.options.evalScripts) {
+ new Ajax.Request(
+ this.url, Object.extend({
+ parameters: this.options.callback(form, value),
+ onComplete: this.onComplete.bind(this),
+ onFailure: this.onFailure.bind(this),
+ asynchronous:true,
+ evalScripts:true
+ }, this.options.ajaxOptions));
+ } else {
+ new Ajax.Updater(
+ { success: this.element,
+ // don't update on failure (this could be an option)
+ failure: null },
+ this.url, Object.extend({
+ parameters: this.options.callback(form, value),
+ onComplete: this.onComplete.bind(this),
+ onFailure: this.onFailure.bind(this)
+ }, this.options.ajaxOptions));
+ }
+ // stop the event to avoid a page refresh in Safari
+ if (arguments.length > 1) {
+ Event.stop(arguments[0]);
+ }
+ return false;
+ },
+ onLoading: function() {
+ this.saving = true;
+ this.removeForm();
+ this.leaveHover();
+ this.showSaving();
+ },
+ showSaving: function() {
+ this.oldInnerHTML = this.element.innerHTML;
+ this.element.innerHTML = this.options.savingText;
+ Element.addClassName(this.element, this.options.savingClassName);
+ this.element.style.backgroundColor = this.originalBackground;
+ Element.show(this.element);
+ },
+ removeForm: function() {
+ if(this.form) {
+ if (this.form.parentNode) Element.remove(this.form);
+ this.form = null;
+ }
+ },
+ enterHover: function() {
+ if (this.saving) return;
+ this.element.style.backgroundColor = this.options.highlightcolor;
+ if (this.effect) {
+ this.effect.cancel();
+ }
+ Element.addClassName(this.element, this.options.hoverClassName)
+ },
+ leaveHover: function() {
+ if (this.options.backgroundColor) {
+ this.element.style.backgroundColor = this.oldBackground;
+ }
+ Element.removeClassName(this.element, this.options.hoverClassName)
+ if (this.saving) return;
+ this.effect = new Effect.Highlight(this.element, {
+ startcolor: this.options.highlightcolor,
+ endcolor: this.options.highlightendcolor,
+ restorecolor: this.originalBackground
+ });
+ },
+ leaveEditMode: function() {
+ Element.removeClassName(this.element, this.options.savingClassName);
+ this.removeForm();
+ this.leaveHover();
+ this.element.style.backgroundColor = this.originalBackground;
+ Element.show(this.element);
+ if (this.options.externalControl) {
+ Element.show(this.options.externalControl);
+ }
+ this.editing = false;
+ this.saving = false;
+ this.oldInnerHTML = null;
+ this.onLeaveEditMode();
+ },
+ onComplete: function(transport) {
+ this.leaveEditMode();
+ this.options.onComplete.bind(this)(transport, this.element);
+ },
+ onEnterEditMode: function() {},
+ onLeaveEditMode: function() {},
+ dispose: function() {
+ if (this.oldInnerHTML) {
+ this.element.innerHTML = this.oldInnerHTML;
+ }
+ this.leaveEditMode();
+ Event.stopObserving(this.element, 'click', this.onclickListener);
+ Event.stopObserving(this.element, 'mouseover', this.mouseoverListener);
+ Event.stopObserving(this.element, 'mouseout', this.mouseoutListener);
+ if (this.options.externalControl) {
+ Event.stopObserving(this.options.externalControl, 'click', this.onclickListener);
+ Event.stopObserving(this.options.externalControl, 'mouseover', this.mouseoverListener);
+ Event.stopObserving(this.options.externalControl, 'mouseout', this.mouseoutListener);
+ }
+ }
+};
+
+Ajax.InPlaceCollectionEditor = Class.create();
+Object.extend(Ajax.InPlaceCollectionEditor.prototype, Ajax.InPlaceEditor.prototype);
+Object.extend(Ajax.InPlaceCollectionEditor.prototype, {
+ createEditField: function() {
+ if (!this.cached_selectTag) {
+ var selectTag = document.createElement("select");
+ var collection = this.options.collection || [];
+ var optionTag;
+ collection.each(function(e,i) {
+ optionTag = document.createElement("option");
+ optionTag.value = (e instanceof Array) ? e[0] : e;
+ if((typeof this.options.value == 'undefined') &&
+ ((e instanceof Array) ? this.element.innerHTML == e[1] : e == optionTag.value)) optionTag.selected = true;
+ if(this.options.value==optionTag.value) optionTag.selected = true;
+ optionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e));
+ selectTag.appendChild(optionTag);
+ }.bind(this));
+ this.cached_selectTag = selectTag;
+ }
+
+ this.editField = this.cached_selectTag;
+ if(this.options.loadTextURL) this.loadExternalText();
+ this.form.appendChild(this.editField);
+ this.options.callback = function(form, value) {
+ return "value=" + encodeURIComponent(value);
+ }
+ }
+});
+
+// Delayed observer, like Form.Element.Observer,
+// but waits for delay after last key input
+// Ideal for live-search fields
+
+Form.Element.DelayedObserver = Class.create();
+Form.Element.DelayedObserver.prototype = {
+ initialize: function(element, delay, callback) {
+ this.delay = delay || 0.5;
+ this.element = $(element);
+ this.callback = callback;
+ this.timer = null;
+ this.lastValue = $F(this.element);
+ Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));
+ },
+ delayedListener: function(event) {
+ if(this.lastValue == $F(this.element)) return;
+ if(this.timer) clearTimeout(this.timer);
+ this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000);
+ this.lastValue = $F(this.element);
+ },
+ onTimerEvent: function() {
+ this.timer = null;
+ this.callback(this.element, $F(this.element));
+ }
+};
--- /dev/null
+// script.aculo.us dragdrop.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006
+
+// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// (c) 2005 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
+//
+// See scriptaculous.js for full license.
+
+/*--------------------------------------------------------------------------*/
+
+if(typeof Effect == 'undefined')
+ throw("dragdrop.js requires including script.aculo.us' effects.js library");
+
+var Droppables = {
+ drops: [],
+
+ remove: function(element) {
+ this.drops = this.drops.reject(function(d) { return d.element==$(element) });
+ },
+
+ add: function(element) {
+ element = $(element);
+ var options = Object.extend({
+ greedy: true,
+ hoverclass: null,
+ tree: false
+ }, arguments[1] || {});
+
+ // cache containers
+ if(options.containment) {
+ options._containers = [];
+ var containment = options.containment;
+ if((typeof containment == 'object') &&
+ (containment.constructor == Array)) {
+ containment.each( function(c) { options._containers.push($(c)) });
+ } else {
+ options._containers.push($(containment));
+ }
+ }
+
+ if(options.accept) options.accept = [options.accept].flatten();
+
+ Element.makePositioned(element); // fix IE
+ options.element = element;
+
+ this.drops.push(options);
+ },
+
+ findDeepestChild: function(drops) {
+ deepest = drops[0];
+
+ for (i = 1; i < drops.length; ++i)
+ if (Element.isParent(drops[i].element, deepest.element))
+ deepest = drops[i];
+
+ return deepest;
+ },
+
+ isContained: function(element, drop) {
+ var containmentNode;
+ if(drop.tree) {
+ containmentNode = element.treeNode;
+ } else {
+ containmentNode = element.parentNode;
+ }
+ return drop._containers.detect(function(c) { return containmentNode == c });
+ },
+
+ isAffected: function(point, element, drop) {
+ return (
+ (drop.element!=element) &&
+ ((!drop._containers) ||
+ this.isContained(element, drop)) &&
+ ((!drop.accept) ||
+ (Element.classNames(element).detect(
+ function(v) { return drop.accept.include(v) } ) )) &&
+ Position.within(drop.element, point[0], point[1]) );
+ },
+
+ deactivate: function(drop) {
+ if(drop.hoverclass)
+ Element.removeClassName(drop.element, drop.hoverclass);
+ this.last_active = null;
+ },
+
+ activate: function(drop) {
+ if(drop.hoverclass)
+ Element.addClassName(drop.element, drop.hoverclass);
+ this.last_active = drop;
+ },
+
+ show: function(point, element) {
+ if(!this.drops.length) return;
+ var affected = [];
+
+ if(this.last_active) this.deactivate(this.last_active);
+ this.drops.each( function(drop) {
+ if(Droppables.isAffected(point, element, drop))
+ affected.push(drop);
+ });
+
+ if(affected.length>0) {
+ drop = Droppables.findDeepestChild(affected);
+ Position.within(drop.element, point[0], point[1]);
+ if(drop.onHover)
+ drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
+
+ Droppables.activate(drop);
+ }
+ },
+
+ fire: function(event, element) {
+ if(!this.last_active) return;
+ Position.prepare();
+
+ if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))
+ if (this.last_active.onDrop)
+ this.last_active.onDrop(element, this.last_active.element, event);
+ },
+
+ reset: function() {
+ if(this.last_active)
+ this.deactivate(this.last_active);
+ }
+}
+
+var Draggables = {
+ drags: [],
+ observers: [],
+
+ register: function(draggable) {
+ if(this.drags.length == 0) {
+ this.eventMouseUp = this.endDrag.bindAsEventListener(this);
+ this.eventMouseMove = this.updateDrag.bindAsEventListener(this);
+ this.eventKeypress = this.keyPress.bindAsEventListener(this);
+
+ Event.observe(document, "mouseup", this.eventMouseUp);
+ Event.observe(document, "mousemove", this.eventMouseMove);
+ Event.observe(document, "keypress", this.eventKeypress);
+ }
+ this.drags.push(draggable);
+ },
+
+ unregister: function(draggable) {
+ this.drags = this.drags.reject(function(d) { return d==draggable });
+ if(this.drags.length == 0) {
+ Event.stopObserving(document, "mouseup", this.eventMouseUp);
+ Event.stopObserving(document, "mousemove", this.eventMouseMove);
+ Event.stopObserving(document, "keypress", this.eventKeypress);
+ }
+ },
+
+ activate: function(draggable) {
+ if(draggable.options.delay) {
+ this._timeout = setTimeout(function() {
+ Draggables._timeout = null;
+ window.focus();
+ Draggables.activeDraggable = draggable;
+ }.bind(this), draggable.options.delay);
+ } else {
+ window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
+ this.activeDraggable = draggable;
+ }
+ },
+
+ deactivate: function() {
+ this.activeDraggable = null;
+ },
+
+ updateDrag: function(event) {
+ if(!this.activeDraggable) return;
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ // Mozilla-based browsers fire successive mousemove events with
+ // the same coordinates, prevent needless redrawing (moz bug?)
+ if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
+ this._lastPointer = pointer;
+
+ this.activeDraggable.updateDrag(event, pointer);
+ },
+
+ endDrag: function(event) {
+ if(this._timeout) {
+ clearTimeout(this._timeout);
+ this._timeout = null;
+ }
+ if(!this.activeDraggable) return;
+ this._lastPointer = null;
+ this.activeDraggable.endDrag(event);
+ this.activeDraggable = null;
+ },
+
+ keyPress: function(event) {
+ if(this.activeDraggable)
+ this.activeDraggable.keyPress(event);
+ },
+
+ addObserver: function(observer) {
+ this.observers.push(observer);
+ this._cacheObserverCallbacks();
+ },
+
+ removeObserver: function(element) { // element instead of observer fixes mem leaks
+ this.observers = this.observers.reject( function(o) { return o.element==element });
+ this._cacheObserverCallbacks();
+ },
+
+ notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag'
+ if(this[eventName+'Count'] > 0)
+ this.observers.each( function(o) {
+ if(o[eventName]) o[eventName](eventName, draggable, event);
+ });
+ if(draggable.options[eventName]) draggable.options[eventName](draggable, event);
+ },
+
+ _cacheObserverCallbacks: function() {
+ ['onStart','onEnd','onDrag'].each( function(eventName) {
+ Draggables[eventName+'Count'] = Draggables.observers.select(
+ function(o) { return o[eventName]; }
+ ).length;
+ });
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+
+var Draggable = Class.create();
+Draggable._dragging = {};
+
+Draggable.prototype = {
+ initialize: function(element) {
+ var defaults = {
+ handle: false,
+ reverteffect: function(element, top_offset, left_offset) {
+ var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;
+ new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur,
+ queue: {scope:'_draggable', position:'end'}
+ });
+ },
+ endeffect: function(element) {
+ var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0;
+ new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
+ queue: {scope:'_draggable', position:'end'},
+ afterFinish: function(){
+ Draggable._dragging[element] = false
+ }
+ });
+ },
+ zindex: 1000,
+ revert: false,
+ scroll: false,
+ scrollSensitivity: 20,
+ scrollSpeed: 15,
+ snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] }
+ delay: 0
+ };
+
+ if(arguments[1] && typeof arguments[1].endeffect == 'undefined')
+ Object.extend(defaults, {
+ starteffect: function(element) {
+ element._opacity = Element.getOpacity(element);
+ Draggable._dragging[element] = true;
+ new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
+ }
+ });
+
+ var options = Object.extend(defaults, arguments[1] || {});
+
+ this.element = $(element);
+
+ if(options.handle && (typeof options.handle == 'string')) {
+ var h = Element.childrenWithClassName(this.element, options.handle, true);
+ if(h.length>0) this.handle = h[0];
+ }
+ if(!this.handle) this.handle = $(options.handle);
+ if(!this.handle) this.handle = this.element;
+
+ if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) {
+ options.scroll = $(options.scroll);
+ this._isScrollChild = Element.childOf(this.element, options.scroll);
+ }
+
+ Element.makePositioned(this.element); // fix IE
+
+ this.delta = this.currentDelta();
+ this.options = options;
+ this.dragging = false;
+
+ this.eventMouseDown = this.initDrag.bindAsEventListener(this);
+ Event.observe(this.handle, "mousedown", this.eventMouseDown);
+
+ Draggables.register(this);
+ },
+
+ destroy: function() {
+ Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
+ Draggables.unregister(this);
+ },
+
+ currentDelta: function() {
+ return([
+ parseInt(Element.getStyle(this.element,'left') || '0'),
+ parseInt(Element.getStyle(this.element,'top') || '0')]);
+ },
+
+ initDrag: function(event) {
+ if(typeof Draggable._dragging[this.element] != 'undefined' &&
+ Draggable._dragging[this.element]) return;
+ if(Event.isLeftClick(event)) {
+ // abort on form elements, fixes a Firefox issue
+ var src = Event.element(event);
+ if(src.tagName && (
+ src.tagName=='INPUT' ||
+ src.tagName=='SELECT' ||
+ src.tagName=='OPTION' ||
+ src.tagName=='BUTTON' ||
+ src.tagName=='TEXTAREA')) return;
+
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var pos = Position.cumulativeOffset(this.element);
+ this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
+
+ Draggables.activate(this);
+ Event.stop(event);
+ }
+ },
+
+ startDrag: function(event) {
+ this.dragging = true;
+
+ if(this.options.zindex) {
+ this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
+ this.element.style.zIndex = this.options.zindex;
+ }
+
+ if(this.options.ghosting) {
+ this._clone = this.element.cloneNode(true);
+ Position.absolutize(this.element);
+ this.element.parentNode.insertBefore(this._clone, this.element);
+ }
+
+ if(this.options.scroll) {
+ if (this.options.scroll == window) {
+ var where = this._getWindowScroll(this.options.scroll);
+ this.originalScrollLeft = where.left;
+ this.originalScrollTop = where.top;
+ } else {
+ this.originalScrollLeft = this.options.scroll.scrollLeft;
+ this.originalScrollTop = this.options.scroll.scrollTop;
+ }
+ }
+
+ Draggables.notify('onStart', this, event);
+
+ if(this.options.starteffect) this.options.starteffect(this.element);
+ },
+
+ updateDrag: function(event, pointer) {
+ if(!this.dragging) this.startDrag(event);
+ Position.prepare();
+ Droppables.show(pointer, this.element);
+ Draggables.notify('onDrag', this, event);
+
+ this.draw(pointer);
+ if(this.options.change) this.options.change(this);
+
+ if(this.options.scroll) {
+ this.stopScrolling();
+
+ var p;
+ if (this.options.scroll == window) {
+ with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; }
+ } else {
+ p = Position.page(this.options.scroll);
+ p[0] += this.options.scroll.scrollLeft;
+ p[1] += this.options.scroll.scrollTop;
+
+ p[0] += (window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0);
+ p[1] += (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0);
+
+ p.push(p[0]+this.options.scroll.offsetWidth);
+ p.push(p[1]+this.options.scroll.offsetHeight);
+ }
+ var speed = [0,0];
+ if(pointer[0] < (p[0]+this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[0]+this.options.scrollSensitivity);
+ if(pointer[1] < (p[1]+this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[1]+this.options.scrollSensitivity);
+ if(pointer[0] > (p[2]-this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[2]-this.options.scrollSensitivity);
+ if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity);
+ this.startScrolling(speed);
+ }
+
+ // fix AppleWebKit rendering
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
+
+ Event.stop(event);
+ },
+
+ finishDrag: function(event, success) {
+ this.dragging = false;
+
+ if(this.options.ghosting) {
+ Position.relativize(this.element);
+ Element.remove(this._clone);
+ this._clone = null;
+ }
+
+ if(success) Droppables.fire(event, this.element);
+ Draggables.notify('onEnd', this, event);
+
+ var revert = this.options.revert;
+ if(revert && typeof revert == 'function') revert = revert(this.element);
+
+ var d = this.currentDelta();
+ if(revert && this.options.reverteffect) {
+ this.options.reverteffect(this.element,
+ d[1]-this.delta[1], d[0]-this.delta[0]);
+ } else {
+ this.delta = d;
+ }
+
+ if(this.options.zindex)
+ this.element.style.zIndex = this.originalZ;
+
+ if(this.options.endeffect)
+ this.options.endeffect(this.element);
+
+ Draggables.deactivate(this);
+ Droppables.reset();
+ },
+
+ keyPress: function(event) {
+ if(event.keyCode!=Event.KEY_ESC) return;
+ this.finishDrag(event, false);
+ Event.stop(event);
+ },
+
+ endDrag: function(event) {
+ if(!this.dragging) return;
+ this.stopScrolling();
+ this.finishDrag(event, true);
+ Event.stop(event);
+ },
+
+ draw: function(point) {
+ var pos = Position.cumulativeOffset(this.element);
+ if(this.options.ghosting) {
+ var r = Position.realOffset(this.element);
+ window.status = r.inspect();
+ pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
+ }
+
+ var d = this.currentDelta();
+ pos[0] -= d[0]; pos[1] -= d[1];
+
+ if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {
+ pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;
+ pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;
+ }
+
+ var p = [0,1].map(function(i){
+ return (point[i]-pos[i]-this.offset[i])
+ }.bind(this));
+
+ if(this.options.snap) {
+ if(typeof this.options.snap == 'function') {
+ p = this.options.snap(p[0],p[1],this);
+ } else {
+ if(this.options.snap instanceof Array) {
+ p = p.map( function(v, i) {
+ return Math.round(v/this.options.snap[i])*this.options.snap[i] }.bind(this))
+ } else {
+ p = p.map( function(v) {
+ return Math.round(v/this.options.snap)*this.options.snap }.bind(this))
+ }
+ }}
+
+ var style = this.element.style;
+ if((!this.options.constraint) || (this.options.constraint=='horizontal'))
+ style.left = p[0] + "px";
+ if((!this.options.constraint) || (this.options.constraint=='vertical'))
+ style.top = p[1] + "px";
+
+ if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
+ },
+
+ stopScrolling: function() {
+ if(this.scrollInterval) {
+ clearInterval(this.scrollInterval);
+ this.scrollInterval = null;
+ Draggables._lastScrollPointer = null;
+ }
+ },
+
+ startScrolling: function(speed) {
+ if(!(speed[0] || speed[1])) return;
+ this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
+ this.lastScrolled = new Date();
+ this.scrollInterval = setInterval(this.scroll.bind(this), 10);
+ },
+
+ scroll: function() {
+ var current = new Date();
+ var delta = current - this.lastScrolled;
+ this.lastScrolled = current;
+ if(this.options.scroll == window) {
+ with (this._getWindowScroll(this.options.scroll)) {
+ if (this.scrollSpeed[0] || this.scrollSpeed[1]) {
+ var d = delta / 1000;
+ this.options.scroll.scrollTo( left + d*this.scrollSpeed[0], top + d*this.scrollSpeed[1] );
+ }
+ }
+ } else {
+ this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;
+ this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000;
+ }
+
+ Position.prepare();
+ Droppables.show(Draggables._lastPointer, this.element);
+ Draggables.notify('onDrag', this);
+ if (this._isScrollChild) {
+ Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer);
+ Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000;
+ Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000;
+ if (Draggables._lastScrollPointer[0] < 0)
+ Draggables._lastScrollPointer[0] = 0;
+ if (Draggables._lastScrollPointer[1] < 0)
+ Draggables._lastScrollPointer[1] = 0;
+ this.draw(Draggables._lastScrollPointer);
+ }
+
+ if(this.options.change) this.options.change(this);
+ },
+
+ _getWindowScroll: function(w) {
+ var T, L, W, H;
+ with (w.document) {
+ if (w.document.documentElement && documentElement.scrollTop) {
+ T = documentElement.scrollTop;
+ L = documentElement.scrollLeft;
+ } else if (w.document.body) {
+ T = body.scrollTop;
+ L = body.scrollLeft;
+ }
+ if (w.innerWidth) {
+ W = w.innerWidth;
+ H = w.innerHeight;
+ } else if (w.document.documentElement && documentElement.clientWidth) {
+ W = documentElement.clientWidth;
+ H = documentElement.clientHeight;
+ } else {
+ W = body.offsetWidth;
+ H = body.offsetHeight
+ }
+ }
+ return { top: T, left: L, width: W, height: H };
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+
+var SortableObserver = Class.create();
+SortableObserver.prototype = {
+ initialize: function(element, observer) {
+ this.element = $(element);
+ this.observer = observer;
+ this.lastValue = Sortable.serialize(this.element);
+ },
+
+ onStart: function() {
+ this.lastValue = Sortable.serialize(this.element);
+ },
+
+ onEnd: function() {
+ Sortable.unmark();
+ if(this.lastValue != Sortable.serialize(this.element))
+ this.observer(this.element)
+ }
+}
+
+var Sortable = {
+ SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,
+
+ sortables: {},
+
+ _findRootElement: function(element) {
+ while (element.tagName != "BODY") {
+ if(element.id && Sortable.sortables[element.id]) return element;
+ element = element.parentNode;
+ }
+ },
+
+ options: function(element) {
+ element = Sortable._findRootElement($(element));
+ if(!element) return;
+ return Sortable.sortables[element.id];
+ },
+
+ destroy: function(element){
+ var s = Sortable.options(element);
+
+ if(s) {
+ Draggables.removeObserver(s.element);
+ s.droppables.each(function(d){ Droppables.remove(d) });
+ s.draggables.invoke('destroy');
+
+ delete Sortable.sortables[s.element.id];
+ }
+ },
+
+ create: function(element) {
+ element = $(element);
+ var options = Object.extend({
+ element: element,
+ tag: 'li', // assumes li children, override with tag: 'tagname'
+ dropOnEmpty: false,
+ tree: false,
+ treeTag: 'ul',
+ overlap: 'vertical', // one of 'vertical', 'horizontal'
+ constraint: 'vertical', // one of 'vertical', 'horizontal', false
+ containment: element, // also takes array of elements (or id's); or false
+ handle: false, // or a CSS class
+ only: false,
+ delay: 0,
+ hoverclass: null,
+ ghosting: false,
+ scroll: false,
+ scrollSensitivity: 20,
+ scrollSpeed: 15,
+ format: this.SERIALIZE_RULE,
+ onChange: Prototype.emptyFunction,
+ onUpdate: Prototype.emptyFunction
+ }, arguments[1] || {});
+
+ // clear any old sortable with same element
+ this.destroy(element);
+
+ // build options for the draggables
+ var options_for_draggable = {
+ revert: true,
+ scroll: options.scroll,
+ scrollSpeed: options.scrollSpeed,
+ scrollSensitivity: options.scrollSensitivity,
+ delay: options.delay,
+ ghosting: options.ghosting,
+ constraint: options.constraint,
+ handle: options.handle };
+
+ if(options.starteffect)
+ options_for_draggable.starteffect = options.starteffect;
+
+ if(options.reverteffect)
+ options_for_draggable.reverteffect = options.reverteffect;
+ else
+ if(options.ghosting) options_for_draggable.reverteffect = function(element) {
+ element.style.top = 0;
+ element.style.left = 0;
+ };
+
+ if(options.endeffect)
+ options_for_draggable.endeffect = options.endeffect;
+
+ if(options.zindex)
+ options_for_draggable.zindex = options.zindex;
+
+ // build options for the droppables
+ var options_for_droppable = {
+ overlap: options.overlap,
+ containment: options.containment,
+ tree: options.tree,
+ hoverclass: options.hoverclass,
+ onHover: Sortable.onHover
+ //greedy: !options.dropOnEmpty
+ }
+
+ var options_for_tree = {
+ onHover: Sortable.onEmptyHover,
+ overlap: options.overlap,
+ containment: options.containment,
+ hoverclass: options.hoverclass
+ }
+
+ // fix for gecko engine
+ Element.cleanWhitespace(element);
+
+ options.draggables = [];
+ options.droppables = [];
+
+ // drop on empty handling
+ if(options.dropOnEmpty || options.tree) {
+ Droppables.add(element, options_for_tree);
+ options.droppables.push(element);
+ }
+
+ (this.findElements(element, options) || []).each( function(e) {
+ // handles are per-draggable
+ var handle = options.handle ?
+ Element.childrenWithClassName(e, options.handle)[0] : e;
+ options.draggables.push(
+ new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
+ Droppables.add(e, options_for_droppable);
+ if(options.tree) e.treeNode = element;
+ options.droppables.push(e);
+ });
+
+ if(options.tree) {
+ (Sortable.findTreeElements(element, options) || []).each( function(e) {
+ Droppables.add(e, options_for_tree);
+ e.treeNode = element;
+ options.droppables.push(e);
+ });
+ }
+
+ // keep reference
+ this.sortables[element.id] = options;
+
+ // for onupdate
+ Draggables.addObserver(new SortableObserver(element, options.onUpdate));
+
+ },
+
+ // return all suitable-for-sortable elements in a guaranteed order
+ findElements: function(element, options) {
+ return Element.findChildren(
+ element, options.only, options.tree ? true : false, options.tag);
+ },
+
+ findTreeElements: function(element, options) {
+ return Element.findChildren(
+ element, options.only, options.tree ? true : false, options.treeTag);
+ },
+
+ onHover: function(element, dropon, overlap) {
+ if(Element.isParent(dropon, element)) return;
+
+ if(overlap > .33 && overlap < .66 && Sortable.options(dropon).tree) {
+ return;
+ } else if(overlap>0.5) {
+ Sortable.mark(dropon, 'before');
+ if(dropon.previousSibling != element) {
+ var oldParentNode = element.parentNode;
+ element.style.visibility = "hidden"; // fix gecko rendering
+ dropon.parentNode.insertBefore(element, dropon);
+ if(dropon.parentNode!=oldParentNode)
+ Sortable.options(oldParentNode).onChange(element);
+ Sortable.options(dropon.parentNode).onChange(element);
+ }
+ } else {
+ Sortable.mark(dropon, 'after');
+ var nextElement = dropon.nextSibling || null;
+ if(nextElement != element) {
+ var oldParentNode = element.parentNode;
+ element.style.visibility = "hidden"; // fix gecko rendering
+ dropon.parentNode.insertBefore(element, nextElement);
+ if(dropon.parentNode!=oldParentNode)
+ Sortable.options(oldParentNode).onChange(element);
+ Sortable.options(dropon.parentNode).onChange(element);
+ }
+ }
+ },
+
+ onEmptyHover: function(element, dropon, overlap) {
+ var oldParentNode = element.parentNode;
+ var droponOptions = Sortable.options(dropon);
+
+ if(!Element.isParent(dropon, element)) {
+ var index;
+
+ var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only});
+ var child = null;
+
+ if(children) {
+ var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap);
+
+ for (index = 0; index < children.length; index += 1) {
+ if (offset - Element.offsetSize (children[index], droponOptions.overlap) >= 0) {
+ offset -= Element.offsetSize (children[index], droponOptions.overlap);
+ } else if (offset - (Element.offsetSize (children[index], droponOptions.overlap) / 2) >= 0) {
+ child = index + 1 < children.length ? children[index + 1] : null;
+ break;
+ } else {
+ child = children[index];
+ break;
+ }
+ }
+ }
+
+ dropon.insertBefore(element, child);
+
+ Sortable.options(oldParentNode).onChange(element);
+ droponOptions.onChange(element);
+ }
+ },
+
+ unmark: function() {
+ if(Sortable._marker) Element.hide(Sortable._marker);
+ },
+
+ mark: function(dropon, position) {
+ // mark on ghosting only
+ var sortable = Sortable.options(dropon.parentNode);
+ if(sortable && !sortable.ghosting) return;
+
+ if(!Sortable._marker) {
+ Sortable._marker = $('dropmarker') || document.createElement('DIV');
+ Element.hide(Sortable._marker);
+ Element.addClassName(Sortable._marker, 'dropmarker');
+ Sortable._marker.style.position = 'absolute';
+ document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
+ }
+ var offsets = Position.cumulativeOffset(dropon);
+ Sortable._marker.style.left = offsets[0] + 'px';
+ Sortable._marker.style.top = offsets[1] + 'px';
+
+ if(position=='after')
+ if(sortable.overlap == 'horizontal')
+ Sortable._marker.style.left = (offsets[0]+dropon.clientWidth) + 'px';
+ else
+ Sortable._marker.style.top = (offsets[1]+dropon.clientHeight) + 'px';
+
+ Element.show(Sortable._marker);
+ },
+
+ _tree: function(element, options, parent) {
+ var children = Sortable.findElements(element, options) || [];
+
+ for (var i = 0; i < children.length; ++i) {
+ var match = children[i].id.match(options.format);
+
+ if (!match) continue;
+
+ var child = {
+ id: encodeURIComponent(match ? match[1] : null),
+ element: element,
+ parent: parent,
+ children: new Array,
+ position: parent.children.length,
+ container: Sortable._findChildrenElement(children[i], options.treeTag.toUpperCase())
+ }
+
+ /* Get the element containing the children and recurse over it */
+ if (child.container)
+ this._tree(child.container, options, child)
+
+ parent.children.push (child);
+ }
+
+ return parent;
+ },
+
+ /* Finds the first element of the given tag type within a parent element.
+ Used for finding the first LI[ST] within a L[IST]I[TEM].*/
+ _findChildrenElement: function (element, containerTag) {
+ if (element && element.hasChildNodes)
+ for (var i = 0; i < element.childNodes.length; ++i)
+ if (element.childNodes[i].tagName == containerTag)
+ return element.childNodes[i];
+
+ return null;
+ },
+
+ tree: function(element) {
+ element = $(element);
+ var sortableOptions = this.options(element);
+ var options = Object.extend({
+ tag: sortableOptions.tag,
+ treeTag: sortableOptions.treeTag,
+ only: sortableOptions.only,
+ name: element.id,
+ format: sortableOptions.format
+ }, arguments[1] || {});
+
+ var root = {
+ id: null,
+ parent: null,
+ children: new Array,
+ container: element,
+ position: 0
+ }
+
+ return Sortable._tree (element, options, root);
+ },
+
+ /* Construct a [i] index for a particular node */
+ _constructIndex: function(node) {
+ var index = '';
+ do {
+ if (node.id) index = '[' + node.position + ']' + index;
+ } while ((node = node.parent) != null);
+ return index;
+ },
+
+ sequence: function(element) {
+ element = $(element);
+ var options = Object.extend(this.options(element), arguments[1] || {});
+
+ return $(this.findElements(element, options) || []).map( function(item) {
+ return item.id.match(options.format) ? item.id.match(options.format)[1] : '';
+ });
+ },
+
+ setSequence: function(element, new_sequence) {
+ element = $(element);
+ var options = Object.extend(this.options(element), arguments[2] || {});
+
+ var nodeMap = {};
+ this.findElements(element, options).each( function(n) {
+ if (n.id.match(options.format))
+ nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode];
+ n.parentNode.removeChild(n);
+ });
+
+ new_sequence.each(function(ident) {
+ var n = nodeMap[ident];
+ if (n) {
+ n[1].appendChild(n[0]);
+ delete nodeMap[ident];
+ }
+ });
+ },
+
+ serialize: function(element) {
+ element = $(element);
+ var options = Object.extend(Sortable.options(element), arguments[1] || {});
+ var name = encodeURIComponent(
+ (arguments[1] && arguments[1].name) ? arguments[1].name : element.id);
+
+ if (options.tree) {
+ return Sortable.tree(element, arguments[1]).children.map( function (item) {
+ return [name + Sortable._constructIndex(item) + "[id]=" +
+ encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
+ }).flatten().join('&');
+ } else {
+ return Sortable.sequence(element, arguments[1]).map( function(item) {
+ return name + "[]=" + encodeURIComponent(item);
+ }).join('&');
+ }
+ }
+}
+
+/* Returns true if child is contained within element */
+Element.isParent = function(child, element) {
+ if (!child.parentNode || child == element) return false;
+
+ if (child.parentNode == element) return true;
+
+ return Element.isParent(child.parentNode, element);
+}
+
+Element.findChildren = function(element, only, recursive, tagName) {
+ if(!element.hasChildNodes()) return null;
+ tagName = tagName.toUpperCase();
+ if(only) only = [only].flatten();
+ var elements = [];
+ $A(element.childNodes).each( function(e) {
+ if(e.tagName && e.tagName.toUpperCase()==tagName &&
+ (!only || (Element.classNames(e).detect(function(v) { return only.include(v) }))))
+ elements.push(e);
+ if(recursive) {
+ var grandchildren = Element.findChildren(e, only, recursive, tagName);
+ if(grandchildren) elements.push(grandchildren);
+ }
+ });
+
+ return (elements.length>0 ? elements.flatten() : []);
+}
+
+Element.offsetSize = function (element, type) {
+ if (type == 'vertical' || type == 'height')
+ return element.offsetHeight;
+ else
+ return element.offsetWidth;
+}
\ No newline at end of file
--- /dev/null
+// script.aculo.us effects.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006
+
+// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// Contributors:
+// Justin Palmer (http://encytemedia.com/)
+// Mark Pilgrim (http://diveintomark.org/)
+// Martin Bialasinki
+//
+// See scriptaculous.js for full license.
+
+// converts rgb() and #xxx to #xxxxxx format,
+// returns self (or first argument) if not convertable
+String.prototype.parseColor = function() {
+ var color = '#';
+ if(this.slice(0,4) == 'rgb(') {
+ var cols = this.slice(4,this.length-1).split(',');
+ var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
+ } else {
+ if(this.slice(0,1) == '#') {
+ if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();
+ if(this.length==7) color = this.toLowerCase();
+ }
+ }
+ return(color.length==7 ? color : (arguments[0] || this));
+}
+
+/*--------------------------------------------------------------------------*/
+
+Element.collectTextNodes = function(element) {
+ return $A($(element).childNodes).collect( function(node) {
+ return (node.nodeType==3 ? node.nodeValue :
+ (node.hasChildNodes() ? Element.collectTextNodes(node) : ''));
+ }).flatten().join('');
+}
+
+Element.collectTextNodesIgnoreClass = function(element, className) {
+ return $A($(element).childNodes).collect( function(node) {
+ return (node.nodeType==3 ? node.nodeValue :
+ ((node.hasChildNodes() && !Element.hasClassName(node,className)) ?
+ Element.collectTextNodesIgnoreClass(node, className) : ''));
+ }).flatten().join('');
+}
+
+Element.setContentZoom = function(element, percent) {
+ element = $(element);
+ Element.setStyle(element, {fontSize: (percent/100) + 'em'});
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
+}
+
+Element.getOpacity = function(element){
+ var opacity;
+ if (opacity = Element.getStyle(element, 'opacity'))
+ return parseFloat(opacity);
+ if (opacity = (Element.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/))
+ if(opacity[1]) return parseFloat(opacity[1]) / 100;
+ return 1.0;
+}
+
+Element.setOpacity = function(element, value){
+ element= $(element);
+ if (value == 1){
+ Element.setStyle(element, { opacity:
+ (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ?
+ 0.999999 : 1.0 });
+ if(/MSIE/.test(navigator.userAgent) && !window.opera)
+ Element.setStyle(element, {filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')});
+ } else {
+ if(value < 0.00001) value = 0;
+ Element.setStyle(element, {opacity: value});
+ if(/MSIE/.test(navigator.userAgent) && !window.opera)
+ Element.setStyle(element,
+ { filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') +
+ 'alpha(opacity='+value*100+')' });
+ }
+}
+
+Element.getInlineOpacity = function(element){
+ return $(element).style.opacity || '';
+}
+
+Element.childrenWithClassName = function(element, className, findFirst) {
+ var classNameRegExp = new RegExp("(^|\\s)" + className + "(\\s|$)");
+ var results = $A($(element).getElementsByTagName('*'))[findFirst ? 'detect' : 'select']( function(c) {
+ return (c.className && c.className.match(classNameRegExp));
+ });
+ if(!results) results = [];
+ return results;
+}
+
+Element.forceRerendering = function(element) {
+ try {
+ element = $(element);
+ var n = document.createTextNode(' ');
+ element.appendChild(n);
+ element.removeChild(n);
+ } catch(e) { }
+};
+
+/*--------------------------------------------------------------------------*/
+
+Array.prototype.call = function() {
+ var args = arguments;
+ this.each(function(f){ f.apply(this, args) });
+}
+
+/*--------------------------------------------------------------------------*/
+
+var Effect = {
+ _elementDoesNotExistError: {
+ name: 'ElementDoesNotExistError',
+ message: 'The specified DOM element does not exist, but is required for this effect to operate'
+ },
+ tagifyText: function(element) {
+ if(typeof Builder == 'undefined')
+ throw("Effect.tagifyText requires including script.aculo.us' builder.js library");
+
+ var tagifyStyle = 'position:relative';
+ if(/MSIE/.test(navigator.userAgent) && !window.opera) tagifyStyle += ';zoom:1';
+ element = $(element);
+ $A(element.childNodes).each( function(child) {
+ if(child.nodeType==3) {
+ child.nodeValue.toArray().each( function(character) {
+ element.insertBefore(
+ Builder.node('span',{style: tagifyStyle},
+ character == ' ' ? String.fromCharCode(160) : character),
+ child);
+ });
+ Element.remove(child);
+ }
+ });
+ },
+ multiple: function(element, effect) {
+ var elements;
+ if(((typeof element == 'object') ||
+ (typeof element == 'function')) &&
+ (element.length))
+ elements = element;
+ else
+ elements = $(element).childNodes;
+
+ var options = Object.extend({
+ speed: 0.1,
+ delay: 0.0
+ }, arguments[2] || {});
+ var masterDelay = options.delay;
+
+ $A(elements).each( function(element, index) {
+ new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay }));
+ });
+ },
+ PAIRS: {
+ 'slide': ['SlideDown','SlideUp'],
+ 'blind': ['BlindDown','BlindUp'],
+ 'appear': ['Appear','Fade']
+ },
+ toggle: function(element, effect) {
+ element = $(element);
+ effect = (effect || 'appear').toLowerCase();
+ var options = Object.extend({
+ queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
+ }, arguments[2] || {});
+ Effect[element.visible() ?
+ Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options);
+ }
+};
+
+var Effect2 = Effect; // deprecated
+
+/* ------------- transitions ------------- */
+
+Effect.Transitions = {}
+
+Effect.Transitions.linear = Prototype.K;
+
+Effect.Transitions.sinoidal = function(pos) {
+ return (-Math.cos(pos*Math.PI)/2) + 0.5;
+}
+Effect.Transitions.reverse = function(pos) {
+ return 1-pos;
+}
+Effect.Transitions.flicker = function(pos) {
+ return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
+}
+Effect.Transitions.wobble = function(pos) {
+ return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
+}
+Effect.Transitions.pulse = function(pos) {
+ return (Math.floor(pos*10) % 2 == 0 ?
+ (pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10)));
+}
+Effect.Transitions.none = function(pos) {
+ return 0;
+}
+Effect.Transitions.full = function(pos) {
+ return 1;
+}
+
+/* ------------- core effects ------------- */
+
+Effect.ScopedQueue = Class.create();
+Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
+ initialize: function() {
+ this.effects = [];
+ this.interval = null;
+ },
+ _each: function(iterator) {
+ this.effects._each(iterator);
+ },
+ add: function(effect) {
+ var timestamp = new Date().getTime();
+
+ var position = (typeof effect.options.queue == 'string') ?
+ effect.options.queue : effect.options.queue.position;
+
+ switch(position) {
+ case 'front':
+ // move unstarted effects after this effect
+ this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) {
+ e.startOn += effect.finishOn;
+ e.finishOn += effect.finishOn;
+ });
+ break;
+ case 'end':
+ // start effect after last queued effect has finished
+ timestamp = this.effects.pluck('finishOn').max() || timestamp;
+ break;
+ }
+
+ effect.startOn += timestamp;
+ effect.finishOn += timestamp;
+
+ if(!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit))
+ this.effects.push(effect);
+
+ if(!this.interval)
+ this.interval = setInterval(this.loop.bind(this), 40);
+ },
+ remove: function(effect) {
+ this.effects = this.effects.reject(function(e) { return e==effect });
+ if(this.effects.length == 0) {
+ clearInterval(this.interval);
+ this.interval = null;
+ }
+ },
+ loop: function() {
+ var timePos = new Date().getTime();
+ this.effects.invoke('loop', timePos);
+ }
+});
+
+Effect.Queues = {
+ instances: $H(),
+ get: function(queueName) {
+ if(typeof queueName != 'string') return queueName;
+
+ if(!this.instances[queueName])
+ this.instances[queueName] = new Effect.ScopedQueue();
+
+ return this.instances[queueName];
+ }
+}
+Effect.Queue = Effect.Queues.get('global');
+
+Effect.DefaultOptions = {
+ transition: Effect.Transitions.sinoidal,
+ duration: 1.0, // seconds
+ fps: 25.0, // max. 25fps due to Effect.Queue implementation
+ sync: false, // true for combining
+ from: 0.0,
+ to: 1.0,
+ delay: 0.0,
+ queue: 'parallel'
+}
+
+Effect.Base = function() {};
+Effect.Base.prototype = {
+ position: null,
+ start: function(options) {
+ this.options = Object.extend(Object.extend({},Effect.DefaultOptions), options || {});
+ this.currentFrame = 0;
+ this.state = 'idle';
+ this.startOn = this.options.delay*1000;
+ this.finishOn = this.startOn + (this.options.duration*1000);
+ this.event('beforeStart');
+ if(!this.options.sync)
+ Effect.Queues.get(typeof this.options.queue == 'string' ?
+ 'global' : this.options.queue.scope).add(this);
+ },
+ loop: function(timePos) {
+ if(timePos >= this.startOn) {
+ if(timePos >= this.finishOn) {
+ this.render(1.0);
+ this.cancel();
+ this.event('beforeFinish');
+ if(this.finish) this.finish();
+ this.event('afterFinish');
+ return;
+ }
+ var pos = (timePos - this.startOn) / (this.finishOn - this.startOn);
+ var frame = Math.round(pos * this.options.fps * this.options.duration);
+ if(frame > this.currentFrame) {
+ this.render(pos);
+ this.currentFrame = frame;
+ }
+ }
+ },
+ render: function(pos) {
+ if(this.state == 'idle') {
+ this.state = 'running';
+ this.event('beforeSetup');
+ if(this.setup) this.setup();
+ this.event('afterSetup');
+ }
+ if(this.state == 'running') {
+ if(this.options.transition) pos = this.options.transition(pos);
+ pos *= (this.options.to-this.options.from);
+ pos += this.options.from;
+ this.position = pos;
+ this.event('beforeUpdate');
+ if(this.update) this.update(pos);
+ this.event('afterUpdate');
+ }
+ },
+ cancel: function() {
+ if(!this.options.sync)
+ Effect.Queues.get(typeof this.options.queue == 'string' ?
+ 'global' : this.options.queue.scope).remove(this);
+ this.state = 'finished';
+ },
+ event: function(eventName) {
+ if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);
+ if(this.options[eventName]) this.options[eventName](this);
+ },
+ inspect: function() {
+ return '#<Effect:' + $H(this).inspect() + ',options:' + $H(this.options).inspect() + '>';
+ }
+}
+
+Effect.Parallel = Class.create();
+Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), {
+ initialize: function(effects) {
+ this.effects = effects || [];
+ this.start(arguments[1]);
+ },
+ update: function(position) {
+ this.effects.invoke('render', position);
+ },
+ finish: function(position) {
+ this.effects.each( function(effect) {
+ effect.render(1.0);
+ effect.cancel();
+ effect.event('beforeFinish');
+ if(effect.finish) effect.finish(position);
+ effect.event('afterFinish');
+ });
+ }
+});
+
+Effect.Opacity = Class.create();
+Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
+ initialize: function(element) {
+ this.element = $(element);
+ if(!this.element) throw(Effect._elementDoesNotExistError);
+ // make this work on IE on elements without 'layout'
+ if(/MSIE/.test(navigator.userAgent) && !window.opera && (!this.element.currentStyle.hasLayout))
+ this.element.setStyle({zoom: 1});
+ var options = Object.extend({
+ from: this.element.getOpacity() || 0.0,
+ to: 1.0
+ }, arguments[1] || {});
+ this.start(options);
+ },
+ update: function(position) {
+ this.element.setOpacity(position);
+ }
+});
+
+Effect.Move = Class.create();
+Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {
+ initialize: function(element) {
+ this.element = $(element);
+ if(!this.element) throw(Effect._elementDoesNotExistError);
+ var options = Object.extend({
+ x: 0,
+ y: 0,
+ mode: 'relative'
+ }, arguments[1] || {});
+ this.start(options);
+ },
+ setup: function() {
+ // Bug in Opera: Opera returns the "real" position of a static element or
+ // relative element that does not have top/left explicitly set.
+ // ==> Always set top and left for position relative elements in your stylesheets
+ // (to 0 if you do not need them)
+ this.element.makePositioned();
+ this.originalLeft = parseFloat(this.element.getStyle('left') || '0');
+ this.originalTop = parseFloat(this.element.getStyle('top') || '0');
+ if(this.options.mode == 'absolute') {
+ // absolute movement, so we need to calc deltaX and deltaY
+ this.options.x = this.options.x - this.originalLeft;
+ this.options.y = this.options.y - this.originalTop;
+ }
+ },
+ update: function(position) {
+ this.element.setStyle({
+ left: Math.round(this.options.x * position + this.originalLeft) + 'px',
+ top: Math.round(this.options.y * position + this.originalTop) + 'px'
+ });
+ }
+});
+
+// for backwards compatibility
+Effect.MoveBy = function(element, toTop, toLeft) {
+ return new Effect.Move(element,
+ Object.extend({ x: toLeft, y: toTop }, arguments[3] || {}));
+};
+
+Effect.Scale = Class.create();
+Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
+ initialize: function(element, percent) {
+ this.element = $(element);
+ if(!this.element) throw(Effect._elementDoesNotExistError);
+ var options = Object.extend({
+ scaleX: true,
+ scaleY: true,
+ scaleContent: true,
+ scaleFromCenter: false,
+ scaleMode: 'box', // 'box' or 'contents' or {} with provided values
+ scaleFrom: 100.0,
+ scaleTo: percent
+ }, arguments[2] || {});
+ this.start(options);
+ },
+ setup: function() {
+ this.restoreAfterFinish = this.options.restoreAfterFinish || false;
+ this.elementPositioning = this.element.getStyle('position');
+
+ this.originalStyle = {};
+ ['top','left','width','height','fontSize'].each( function(k) {
+ this.originalStyle[k] = this.element.style[k];
+ }.bind(this));
+
+ this.originalTop = this.element.offsetTop;
+ this.originalLeft = this.element.offsetLeft;
+
+ var fontSize = this.element.getStyle('font-size') || '100%';
+ ['em','px','%','pt'].each( function(fontSizeType) {
+ if(fontSize.indexOf(fontSizeType)>0) {
+ this.fontSize = parseFloat(fontSize);
+ this.fontSizeType = fontSizeType;
+ }
+ }.bind(this));
+
+ this.factor = (this.options.scaleTo - this.options.scaleFrom)/100;
+
+ this.dims = null;
+ if(this.options.scaleMode=='box')
+ this.dims = [this.element.offsetHeight, this.element.offsetWidth];
+ if(/^content/.test(this.options.scaleMode))
+ this.dims = [this.element.scrollHeight, this.element.scrollWidth];
+ if(!this.dims)
+ this.dims = [this.options.scaleMode.originalHeight,
+ this.options.scaleMode.originalWidth];
+ },
+ update: function(position) {
+ var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
+ if(this.options.scaleContent && this.fontSize)
+ this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType });
+ this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
+ },
+ finish: function(position) {
+ if (this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
+ },
+ setDimensions: function(height, width) {
+ var d = {};
+ if(this.options.scaleX) d.width = Math.round(width) + 'px';
+ if(this.options.scaleY) d.height = Math.round(height) + 'px';
+ if(this.options.scaleFromCenter) {
+ var topd = (height - this.dims[0])/2;
+ var leftd = (width - this.dims[1])/2;
+ if(this.elementPositioning == 'absolute') {
+ if(this.options.scaleY) d.top = this.originalTop-topd + 'px';
+ if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px';
+ } else {
+ if(this.options.scaleY) d.top = -topd + 'px';
+ if(this.options.scaleX) d.left = -leftd + 'px';
+ }
+ }
+ this.element.setStyle(d);
+ }
+});
+
+Effect.Highlight = Class.create();
+Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {
+ initialize: function(element) {
+ this.element = $(element);
+ if(!this.element) throw(Effect._elementDoesNotExistError);
+ var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {});
+ this.start(options);
+ },
+ setup: function() {
+ // Prevent executing on elements not in the layout flow
+ if(this.element.getStyle('display')=='none') { this.cancel(); return; }
+ // Disable background image during the effect
+ this.oldStyle = {
+ backgroundImage: this.element.getStyle('background-image') };
+ this.element.setStyle({backgroundImage: 'none'});
+ if(!this.options.endcolor)
+ this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff');
+ if(!this.options.restorecolor)
+ this.options.restorecolor = this.element.getStyle('background-color');
+ // init color calculations
+ this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
+ this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this));
+ },
+ update: function(position) {
+ this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){
+ return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) });
+ },
+ finish: function() {
+ this.element.setStyle(Object.extend(this.oldStyle, {
+ backgroundColor: this.options.restorecolor
+ }));
+ }
+});
+
+Effect.ScrollTo = Class.create();
+Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), {
+ initialize: function(element) {
+ this.element = $(element);
+ this.start(arguments[1] || {});
+ },
+ setup: function() {
+ Position.prepare();
+ var offsets = Position.cumulativeOffset(this.element);
+ if(this.options.offset) offsets[1] += this.options.offset;
+ var max = window.innerHeight ?
+ window.height - window.innerHeight :
+ document.body.scrollHeight -
+ (document.documentElement.clientHeight ?
+ document.documentElement.clientHeight : document.body.clientHeight);
+ this.scrollStart = Position.deltaY;
+ this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart;
+ },
+ update: function(position) {
+ Position.prepare();
+ window.scrollTo(Position.deltaX,
+ this.scrollStart + (position*this.delta));
+ }
+});
+
+/* ------------- combination effects ------------- */
+
+Effect.Fade = function(element) {
+ element = $(element);
+ var oldOpacity = element.getInlineOpacity();
+ var options = Object.extend({
+ from: element.getOpacity() || 1.0,
+ to: 0.0,
+ afterFinishInternal: function(effect) {
+ if(effect.options.to!=0) return;
+ effect.element.hide();
+ effect.element.setStyle({opacity: oldOpacity});
+ }}, arguments[1] || {});
+ return new Effect.Opacity(element,options);
+}
+
+Effect.Appear = function(element) {
+ element = $(element);
+ var options = Object.extend({
+ from: (element.getStyle('display') == 'none' ? 0.0 : element.getOpacity() || 0.0),
+ to: 1.0,
+ // force Safari to render floated elements properly
+ afterFinishInternal: function(effect) {
+ effect.element.forceRerendering();
+ },
+ beforeSetup: function(effect) {
+ effect.element.setOpacity(effect.options.from);
+ effect.element.show();
+ }}, arguments[1] || {});
+ return new Effect.Opacity(element,options);
+}
+
+Effect.Puff = function(element) {
+ element = $(element);
+ var oldStyle = {
+ opacity: element.getInlineOpacity(),
+ position: element.getStyle('position'),
+ top: element.style.top,
+ left: element.style.left,
+ width: element.style.width,
+ height: element.style.height
+ };
+ return new Effect.Parallel(
+ [ new Effect.Scale(element, 200,
+ { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }),
+ new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],
+ Object.extend({ duration: 1.0,
+ beforeSetupInternal: function(effect) {
+ Position.absolutize(effect.effects[0].element)
+ },
+ afterFinishInternal: function(effect) {
+ effect.effects[0].element.hide();
+ effect.effects[0].element.setStyle(oldStyle); }
+ }, arguments[1] || {})
+ );
+}
+
+Effect.BlindUp = function(element) {
+ element = $(element);
+ element.makeClipping();
+ return new Effect.Scale(element, 0,
+ Object.extend({ scaleContent: false,
+ scaleX: false,
+ restoreAfterFinish: true,
+ afterFinishInternal: function(effect) {
+ effect.element.hide();
+ effect.element.undoClipping();
+ }
+ }, arguments[1] || {})
+ );
+}
+
+Effect.BlindDown = function(element) {
+ element = $(element);
+ var elementDimensions = element.getDimensions();
+ return new Effect.Scale(element, 100, Object.extend({
+ scaleContent: false,
+ scaleX: false,
+ scaleFrom: 0,
+ scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
+ restoreAfterFinish: true,
+ afterSetup: function(effect) {
+ effect.element.makeClipping();
+ effect.element.setStyle({height: '0px'});
+ effect.element.show();
+ },
+ afterFinishInternal: function(effect) {
+ effect.element.undoClipping();
+ }
+ }, arguments[1] || {}));
+}
+
+Effect.SwitchOff = function(element) {
+ element = $(element);
+ var oldOpacity = element.getInlineOpacity();
+ return new Effect.Appear(element, Object.extend({
+ duration: 0.4,
+ from: 0,
+ transition: Effect.Transitions.flicker,
+ afterFinishInternal: function(effect) {
+ new Effect.Scale(effect.element, 1, {
+ duration: 0.3, scaleFromCenter: true,
+ scaleX: false, scaleContent: false, restoreAfterFinish: true,
+ beforeSetup: function(effect) {
+ effect.element.makePositioned();
+ effect.element.makeClipping();
+ },
+ afterFinishInternal: function(effect) {
+ effect.element.hide();
+ effect.element.undoClipping();
+ effect.element.undoPositioned();
+ effect.element.setStyle({opacity: oldOpacity});
+ }
+ })
+ }
+ }, arguments[1] || {}));
+}
+
+Effect.DropOut = function(element) {
+ element = $(element);
+ var oldStyle = {
+ top: element.getStyle('top'),
+ left: element.getStyle('left'),
+ opacity: element.getInlineOpacity() };
+ return new Effect.Parallel(
+ [ new Effect.Move(element, {x: 0, y: 100, sync: true }),
+ new Effect.Opacity(element, { sync: true, to: 0.0 }) ],
+ Object.extend(
+ { duration: 0.5,
+ beforeSetup: function(effect) {
+ effect.effects[0].element.makePositioned();
+ },
+ afterFinishInternal: function(effect) {
+ effect.effects[0].element.hide();
+ effect.effects[0].element.undoPositioned();
+ effect.effects[0].element.setStyle(oldStyle);
+ }
+ }, arguments[1] || {}));
+}
+
+Effect.Shake = function(element) {
+ element = $(element);
+ var oldStyle = {
+ top: element.getStyle('top'),
+ left: element.getStyle('left') };
+ return new Effect.Move(element,
+ { x: 20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
+ new Effect.Move(effect.element,
+ { x: -40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
+ new Effect.Move(effect.element,
+ { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
+ new Effect.Move(effect.element,
+ { x: -40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
+ new Effect.Move(effect.element,
+ { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
+ new Effect.Move(effect.element,
+ { x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
+ effect.element.undoPositioned();
+ effect.element.setStyle(oldStyle);
+ }}) }}) }}) }}) }}) }});
+}
+
+Effect.SlideDown = function(element) {
+ element = $(element);
+ element.cleanWhitespace();
+ // SlideDown need to have the content of the element wrapped in a container element with fixed height!
+ var oldInnerBottom = $(element.firstChild).getStyle('bottom');
+ var elementDimensions = element.getDimensions();
+ return new Effect.Scale(element, 100, Object.extend({
+ scaleContent: false,
+ scaleX: false,
+ scaleFrom: window.opera ? 0 : 1,
+ scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
+ restoreAfterFinish: true,
+ afterSetup: function(effect) {
+ effect.element.makePositioned();
+ effect.element.firstChild.makePositioned();
+ if(window.opera) effect.element.setStyle({top: ''});
+ effect.element.makeClipping();
+ effect.element.setStyle({height: '0px'});
+ effect.element.show(); },
+ afterUpdateInternal: function(effect) {
+ effect.element.firstChild.setStyle({bottom:
+ (effect.dims[0] - effect.element.clientHeight) + 'px' });
+ },
+ afterFinishInternal: function(effect) {
+ effect.element.undoClipping();
+ // IE will crash if child is undoPositioned first
+ if(/MSIE/.test(navigator.userAgent) && !window.opera){
+ effect.element.undoPositioned();
+ effect.element.firstChild.undoPositioned();
+ }else{
+ effect.element.firstChild.undoPositioned();
+ effect.element.undoPositioned();
+ }
+ effect.element.firstChild.setStyle({bottom: oldInnerBottom}); }
+ }, arguments[1] || {})
+ );
+}
+
+Effect.SlideUp = function(element) {
+ element = $(element);
+ element.cleanWhitespace();
+ var oldInnerBottom = $(element.firstChild).getStyle('bottom');
+ return new Effect.Scale(element, window.opera ? 0 : 1,
+ Object.extend({ scaleContent: false,
+ scaleX: false,
+ scaleMode: 'box',
+ scaleFrom: 100,
+ restoreAfterFinish: true,
+ beforeStartInternal: function(effect) {
+ effect.element.makePositioned();
+ effect.element.firstChild.makePositioned();
+ if(window.opera) effect.element.setStyle({top: ''});
+ effect.element.makeClipping();
+ effect.element.show(); },
+ afterUpdateInternal: function(effect) {
+ effect.element.firstChild.setStyle({bottom:
+ (effect.dims[0] - effect.element.clientHeight) + 'px' }); },
+ afterFinishInternal: function(effect) {
+ effect.element.hide();
+ effect.element.undoClipping();
+ effect.element.firstChild.undoPositioned();
+ effect.element.undoPositioned();
+ effect.element.setStyle({bottom: oldInnerBottom}); }
+ }, arguments[1] || {})
+ );
+}
+
+// Bug in opera makes the TD containing this element expand for a instance after finish
+Effect.Squish = function(element) {
+ return new Effect.Scale(element, window.opera ? 1 : 0,
+ { restoreAfterFinish: true,
+ beforeSetup: function(effect) {
+ effect.element.makeClipping(effect.element); },
+ afterFinishInternal: function(effect) {
+ effect.element.hide(effect.element);
+ effect.element.undoClipping(effect.element); }
+ });
+}
+
+Effect.Grow = function(element) {
+ element = $(element);
+ var options = Object.extend({
+ direction: 'center',
+ moveTransition: Effect.Transitions.sinoidal,
+ scaleTransition: Effect.Transitions.sinoidal,
+ opacityTransition: Effect.Transitions.full
+ }, arguments[1] || {});
+ var oldStyle = {
+ top: element.style.top,
+ left: element.style.left,
+ height: element.style.height,
+ width: element.style.width,
+ opacity: element.getInlineOpacity() };
+
+ var dims = element.getDimensions();
+ var initialMoveX, initialMoveY;
+ var moveX, moveY;
+
+ switch (options.direction) {
+ case 'top-left':
+ initialMoveX = initialMoveY = moveX = moveY = 0;
+ break;
+ case 'top-right':
+ initialMoveX = dims.width;
+ initialMoveY = moveY = 0;
+ moveX = -dims.width;
+ break;
+ case 'bottom-left':
+ initialMoveX = moveX = 0;
+ initialMoveY = dims.height;
+ moveY = -dims.height;
+ break;
+ case 'bottom-right':
+ initialMoveX = dims.width;
+ initialMoveY = dims.height;
+ moveX = -dims.width;
+ moveY = -dims.height;
+ break;
+ case 'center':
+ initialMoveX = dims.width / 2;
+ initialMoveY = dims.height / 2;
+ moveX = -dims.width / 2;
+ moveY = -dims.height / 2;
+ break;
+ }
+
+ return new Effect.Move(element, {
+ x: initialMoveX,
+ y: initialMoveY,
+ duration: 0.01,
+ beforeSetup: function(effect) {
+ effect.element.hide();
+ effect.element.makeClipping();
+ effect.element.makePositioned();
+ },
+ afterFinishInternal: function(effect) {
+ new Effect.Parallel(
+ [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),
+ new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }),
+ new Effect.Scale(effect.element, 100, {
+ scaleMode: { originalHeight: dims.height, originalWidth: dims.width },
+ sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
+ ], Object.extend({
+ beforeSetup: function(effect) {
+ effect.effects[0].element.setStyle({height: '0px'});
+ effect.effects[0].element.show();
+ },
+ afterFinishInternal: function(effect) {
+ effect.effects[0].element.undoClipping();
+ effect.effects[0].element.undoPositioned();
+ effect.effects[0].element.setStyle(oldStyle);
+ }
+ }, options)
+ )
+ }
+ });
+}
+
+Effect.Shrink = function(element) {
+ element = $(element);
+ var options = Object.extend({
+ direction: 'center',
+ moveTransition: Effect.Transitions.sinoidal,
+ scaleTransition: Effect.Transitions.sinoidal,
+ opacityTransition: Effect.Transitions.none
+ }, arguments[1] || {});
+ var oldStyle = {
+ top: element.style.top,
+ left: element.style.left,
+ height: element.style.height,
+ width: element.style.width,
+ opacity: element.getInlineOpacity() };
+
+ var dims = element.getDimensions();
+ var moveX, moveY;
+
+ switch (options.direction) {
+ case 'top-left':
+ moveX = moveY = 0;
+ break;
+ case 'top-right':
+ moveX = dims.width;
+ moveY = 0;
+ break;
+ case 'bottom-left':
+ moveX = 0;
+ moveY = dims.height;
+ break;
+ case 'bottom-right':
+ moveX = dims.width;
+ moveY = dims.height;
+ break;
+ case 'center':
+ moveX = dims.width / 2;
+ moveY = dims.height / 2;
+ break;
+ }
+
+ return new Effect.Parallel(
+ [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }),
+ new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}),
+ new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition })
+ ], Object.extend({
+ beforeStartInternal: function(effect) {
+ effect.effects[0].element.makePositioned();
+ effect.effects[0].element.makeClipping(); },
+ afterFinishInternal: function(effect) {
+ effect.effects[0].element.hide();
+ effect.effects[0].element.undoClipping();
+ effect.effects[0].element.undoPositioned();
+ effect.effects[0].element.setStyle(oldStyle); }
+ }, options)
+ );
+}
+
+Effect.Pulsate = function(element) {
+ element = $(element);
+ var options = arguments[1] || {};
+ var oldOpacity = element.getInlineOpacity();
+ var transition = options.transition || Effect.Transitions.sinoidal;
+ var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) };
+ reverser.bind(transition);
+ return new Effect.Opacity(element,
+ Object.extend(Object.extend({ duration: 3.0, from: 0,
+ afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); }
+ }, options), {transition: reverser}));
+}
+
+Effect.Fold = function(element) {
+ element = $(element);
+ var oldStyle = {
+ top: element.style.top,
+ left: element.style.left,
+ width: element.style.width,
+ height: element.style.height };
+ Element.makeClipping(element);
+ return new Effect.Scale(element, 5, Object.extend({
+ scaleContent: false,
+ scaleX: false,
+ afterFinishInternal: function(effect) {
+ new Effect.Scale(element, 1, {
+ scaleContent: false,
+ scaleY: false,
+ afterFinishInternal: function(effect) {
+ effect.element.hide();
+ effect.element.undoClipping();
+ effect.element.setStyle(oldStyle);
+ } });
+ }}, arguments[1] || {}));
+};
+
+['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom',
+ 'collectTextNodes','collectTextNodesIgnoreClass','childrenWithClassName'].each(
+ function(f) { Element.Methods[f] = Element[f]; }
+);
+
+Element.Methods.visualEffect = function(element, effect, options) {
+ s = effect.gsub(/_/, '-').camelize();
+ effect_class = s.charAt(0).toUpperCase() + s.substring(1);
+ new Effect[effect_class](element, options);
+ return $(element);
+};
+
+Element.addMethods();
\ No newline at end of file
--- /dev/null
+/*
+Copyright (c) 2005 JSON.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+/*
+ The global object JSON contains two methods.
+
+ JSON.stringify(value) takes a JavaScript value and produces a JSON text.
+ The value must not be cyclical.
+
+ JSON.parse(text) takes a JSON text and produces a JavaScript value. It will
+ return false if there is an error.
+*/
+var JSON = function () {
+ var m = {
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '\\': '\\\\'
+ },
+ s = {
+ 'boolean': function (x) {
+ return String(x);
+ },
+ number: function (x) {
+ return isFinite(x) ? String(x) : 'null';
+ },
+ string: function (x) {
+ if (/["\\\x00-\x1f]/.test(x)) {
+ x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) {
+ var c = m[b];
+ if (c) {
+ return c;
+ }
+ c = b.charCodeAt();
+ return '\\u00' +
+ Math.floor(c / 16).toString(16) +
+ (c % 16).toString(16);
+ });
+ }
+ return '"' + x + '"';
+ },
+ object: function (x) {
+ if (x) {
+ var a = [], b, f, i, l, v;
+ if (x instanceof Array) {
+ a[0] = '[';
+ l = x.length;
+ for (i = 0; i < l; i += 1) {
+ v = x[i];
+ f = s[typeof v];
+ if (f) {
+ v = f(v);
+ if (typeof v == 'string') {
+ if (b) {
+ a[a.length] = ',';
+ }
+ a[a.length] = v;
+ b = true;
+ }
+ }
+ }
+ a[a.length] = ']';
+ } else if (x instanceof Object) {
+ a[0] = '{';
+ for (i in x) {
+ v = x[i];
+ f = s[typeof v];
+ if (f) {
+ v = f(v);
+ if (typeof v == 'string') {
+ if (b) {
+ a[a.length] = ',';
+ }
+ a.push(s.string(i), ':', v);
+ b = true;
+ }
+ }
+ }
+ a[a.length] = '}';
+ } else {
+ return;
+ }
+ return a.join('');
+ }
+ return 'null';
+ }
+ };
+ return {
+ copyright: '(c)2005 JSON.org',
+ license: 'http://www.crockford.com/JSON/license.html',
+/*
+ Stringify a JavaScript value, producing a JSON text.
+*/
+ stringify: function (v) {
+ var f = s[typeof v];
+ if (f) {
+ v = f(v);
+ if (typeof v == 'string') {
+ return v;
+ }
+ }
+ return null;
+ },
+/*
+ Parse a JSON text, producing a JavaScript value.
+ It returns false if there is a syntax error.
+*/
+ parse: function (text) {
+ try {
+ return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
+ text.replace(/"(\\.|[^"\\])*"/g, ''))) &&
+ eval('(' + text + ')');
+ } catch (e) {
+ return false;
+ }
+ }
+ };
+}();
\ No newline at end of file
--- /dev/null
+/* Prototype JavaScript framework, version 1.5.0_rc1
+ * (c) 2005 Sam Stephenson <sam@conio.net>
+ *
+ * Prototype is freely distributable under the terms of an MIT-style license.
+ * For details, see the Prototype web site: http://prototype.conio.net/
+ *
+/*--------------------------------------------------------------------------*/
+
+var Prototype = {
+ Version: '1.5.0_rc1',
+ ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
+
+ emptyFunction: function() {},
+ K: function(x) {return x}
+}
+
+var Class = {
+ create: function() {
+ return function() {
+ this.initialize.apply(this, arguments);
+ }
+ }
+}
+
+var Abstract = new Object();
+
+Object.extend = function(destination, source) {
+ for (var property in source) {
+ destination[property] = source[property];
+ }
+ return destination;
+}
+
+Object.extend(Object, {
+ inspect: function(object) {
+ try {
+ if (object == undefined) return 'undefined';
+ if (object == null) return 'null';
+ return object.inspect ? object.inspect() : object.toString();
+ } catch (e) {
+ if (e instanceof RangeError) return '...';
+ throw e;
+ }
+ },
+
+ keys: function(object) {
+ var keys = [];
+ for (var property in object)
+ keys.push(property);
+ return keys;
+ },
+
+ values: function(object) {
+ var values = [];
+ for (var property in object)
+ values.push(object[property]);
+ return values;
+ },
+
+ clone: function(object) {
+ return Object.extend({}, object);
+ }
+});
+
+Function.prototype.bind = function() {
+ var __method = this, args = $A(arguments), object = args.shift();
+ return function() {
+ return __method.apply(object, args.concat($A(arguments)));
+ }
+}
+
+Function.prototype.bindAsEventListener = function(object) {
+ var __method = this, args = $A(arguments), object = args.shift();
+ return function(event) {
+ return __method.apply(object, [( event || window.event)].concat(args).concat($A(arguments)));
+ }
+}
+
+Object.extend(Number.prototype, {
+ toColorPart: function() {
+ var digits = this.toString(16);
+ if (this < 16) return '0' + digits;
+ return digits;
+ },
+
+ succ: function() {
+ return this + 1;
+ },
+
+ times: function(iterator) {
+ $R(0, this, true).each(iterator);
+ return this;
+ }
+});
+
+var Try = {
+ these: function() {
+ var returnValue;
+
+ for (var i = 0; i < arguments.length; i++) {
+ var lambda = arguments[i];
+ try {
+ returnValue = lambda();
+ break;
+ } catch (e) {}
+ }
+
+ return returnValue;
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+
+var PeriodicalExecuter = Class.create();
+PeriodicalExecuter.prototype = {
+ initialize: function(callback, frequency) {
+ this.callback = callback;
+ this.frequency = frequency;
+ this.currentlyExecuting = false;
+
+ this.registerCallback();
+ },
+
+ registerCallback: function() {
+ this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
+ },
+
+ stop: function() {
+ if (!this.timer) return;
+ clearInterval(this.timer);
+ this.timer = null;
+ },
+
+ onTimerEvent: function() {
+ if (!this.currentlyExecuting) {
+ try {
+ this.currentlyExecuting = true;
+ this.callback(this);
+ } finally {
+ this.currentlyExecuting = false;
+ }
+ }
+ }
+}
+Object.extend(String.prototype, {
+ gsub: function(pattern, replacement) {
+ var result = '', source = this, match;
+ replacement = arguments.callee.prepareReplacement(replacement);
+
+ while (source.length > 0) {
+ if (match = source.match(pattern)) {
+ result += source.slice(0, match.index);
+ result += (replacement(match) || '').toString();
+ source = source.slice(match.index + match[0].length);
+ } else {
+ result += source, source = '';
+ }
+ }
+ return result;
+ },
+
+ sub: function(pattern, replacement, count) {
+ replacement = this.gsub.prepareReplacement(replacement);
+ count = count === undefined ? 1 : count;
+
+ return this.gsub(pattern, function(match) {
+ if (--count < 0) return match[0];
+ return replacement(match);
+ });
+ },
+
+ scan: function(pattern, iterator) {
+ this.gsub(pattern, iterator);
+ return this;
+ },
+
+ truncate: function(length, truncation) {
+ length = length || 30;
+ truncation = truncation === undefined ? '...' : truncation;
+ return this.length > length ?
+ this.slice(0, length - truncation.length) + truncation : this;
+ },
+
+ strip: function() {
+ return this.replace(/^\s+/, '').replace(/\s+$/, '');
+ },
+
+ stripTags: function() {
+ return this.replace(/<\/?[^>]+>/gi, '');
+ },
+
+ stripScripts: function() {
+ return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
+ },
+
+ extractScripts: function() {
+ var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
+ var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
+ return (this.match(matchAll) || []).map(function(scriptTag) {
+ return (scriptTag.match(matchOne) || ['', ''])[1];
+ });
+ },
+
+ evalScripts: function() {
+ return this.extractScripts().map(function(script) { return eval(script) });
+ },
+
+ escapeHTML: function() {
+ var div = document.createElement('div');
+ var text = document.createTextNode(this);
+ div.appendChild(text);
+ return div.innerHTML;
+ },
+
+ unescapeHTML: function() {
+ var div = document.createElement('div');
+ div.innerHTML = this.stripTags();
+ return div.childNodes[0] ? div.childNodes[0].nodeValue : '';
+ },
+
+ toQueryParams: function() {
+ var pairs = this.match(/^\??(.*)$/)[1].split('&');
+ return pairs.inject({}, function(params, pairString) {
+ var pair = pairString.split('=');
+ var value = pair[1] ? decodeURIComponent(pair[1]) : undefined;
+ params[decodeURIComponent(pair[0])] = value;
+ return params;
+ });
+ },
+
+ toArray: function() {
+ return this.split('');
+ },
+
+ camelize: function() {
+ var oStringList = this.split('-');
+ if (oStringList.length == 1) return oStringList[0];
+
+ var camelizedString = this.indexOf('-') == 0
+ ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1)
+ : oStringList[0];
+
+ for (var i = 1, len = oStringList.length; i < len; i++) {
+ var s = oStringList[i];
+ camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
+ }
+
+ return camelizedString;
+ },
+
+ inspect: function(useDoubleQuotes) {
+ var escapedString = this.replace(/\\/g, '\\\\');
+ if (useDoubleQuotes)
+ return '"' + escapedString.replace(/"/g, '\\"') + '"';
+ else
+ return "'" + escapedString.replace(/'/g, '\\\'') + "'";
+ }
+});
+
+String.prototype.gsub.prepareReplacement = function(replacement) {
+ if (typeof replacement == 'function') return replacement;
+ var template = new Template(replacement);
+ return function(match) { return template.evaluate(match) };
+}
+
+String.prototype.parseQuery = String.prototype.toQueryParams;
+
+var Template = Class.create();
+Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
+Template.prototype = {
+ initialize: function(template, pattern) {
+ this.template = template.toString();
+ this.pattern = pattern || Template.Pattern;
+ },
+
+ evaluate: function(object) {
+ return this.template.gsub(this.pattern, function(match) {
+ var before = match[1];
+ if (before == '\\') return match[2];
+ return before + (object[match[3]] || '').toString();
+ });
+ }
+}
+
+var $break = new Object();
+var $continue = new Object();
+
+var Enumerable = {
+ each: function(iterator) {
+ var index = 0;
+ try {
+ this._each(function(value) {
+ try {
+ iterator(value, index++);
+ } catch (e) {
+ if (e != $continue) throw e;
+ }
+ });
+ } catch (e) {
+ if (e != $break) throw e;
+ }
+ },
+
+ all: function(iterator) {
+ var result = true;
+ this.each(function(value, index) {
+ result = result && !!(iterator || Prototype.K)(value, index);
+ if (!result) throw $break;
+ });
+ return result;
+ },
+
+ any: function(iterator) {
+ var result = false;
+ this.each(function(value, index) {
+ if (result = !!(iterator || Prototype.K)(value, index))
+ throw $break;
+ });
+ return result;
+ },
+
+ collect: function(iterator) {
+ var results = [];
+ this.each(function(value, index) {
+ results.push(iterator(value, index));
+ });
+ return results;
+ },
+
+ detect: function (iterator) {
+ var result;
+ this.each(function(value, index) {
+ if (iterator(value, index)) {
+ result = value;
+ throw $break;
+ }
+ });
+ return result;
+ },
+
+ findAll: function(iterator) {
+ var results = [];
+ this.each(function(value, index) {
+ if (iterator(value, index))
+ results.push(value);
+ });
+ return results;
+ },
+
+ grep: function(pattern, iterator) {
+ var results = [];
+ this.each(function(value, index) {
+ var stringValue = value.toString();
+ if (stringValue.match(pattern))
+ results.push((iterator || Prototype.K)(value, index));
+ })
+ return results;
+ },
+
+ include: function(object) {
+ var found = false;
+ this.each(function(value) {
+ if (value == object) {
+ found = true;
+ throw $break;
+ }
+ });
+ return found;
+ },
+
+ inject: function(memo, iterator) {
+ this.each(function(value, index) {
+ memo = iterator(memo, value, index);
+ });
+ return memo;
+ },
+
+ invoke: function(method) {
+ var args = $A(arguments).slice(1);
+ return this.collect(function(value) {
+ return value[method].apply(value, args);
+ });
+ },
+
+ max: function(iterator) {
+ var result;
+ this.each(function(value, index) {
+ value = (iterator || Prototype.K)(value, index);
+ if (result == undefined || value >= result)
+ result = value;
+ });
+ return result;
+ },
+
+ min: function(iterator) {
+ var result;
+ this.each(function(value, index) {
+ value = (iterator || Prototype.K)(value, index);
+ if (result == undefined || value < result)
+ result = value;
+ });
+ return result;
+ },
+
+ partition: function(iterator) {
+ var trues = [], falses = [];
+ this.each(function(value, index) {
+ ((iterator || Prototype.K)(value, index) ?
+ trues : falses).push(value);
+ });
+ return [trues, falses];
+ },
+
+ pluck: function(property) {
+ var results = [];
+ this.each(function(value, index) {
+ results.push(value[property]);
+ });
+ return results;
+ },
+
+ reject: function(iterator) {
+ var results = [];
+ this.each(function(value, index) {
+ if (!iterator(value, index))
+ results.push(value);
+ });
+ return results;
+ },
+
+ sortBy: function(iterator) {
+ return this.collect(function(value, index) {
+ return {value: value, criteria: iterator(value, index)};
+ }).sort(function(left, right) {
+ var a = left.criteria, b = right.criteria;
+ return a < b ? -1 : a > b ? 1 : 0;
+ }).pluck('value');
+ },
+
+ toArray: function() {
+ return this.collect(Prototype.K);
+ },
+
+ zip: function() {
+ var iterator = Prototype.K, args = $A(arguments);
+ if (typeof args.last() == 'function')
+ iterator = args.pop();
+
+ var collections = [this].concat(args).map($A);
+ return this.map(function(value, index) {
+ return iterator(collections.pluck(index));
+ });
+ },
+
+ inspect: function() {
+ return '#<Enumerable:' + this.toArray().inspect() + '>';
+ }
+}
+
+Object.extend(Enumerable, {
+ map: Enumerable.collect,
+ find: Enumerable.detect,
+ select: Enumerable.findAll,
+ member: Enumerable.include,
+ entries: Enumerable.toArray
+});
+var $A = Array.from = function(iterable) {
+ if (!iterable) return [];
+ if (iterable.toArray) {
+ return iterable.toArray();
+ } else {
+ var results = [];
+ for (var i = 0; i < iterable.length; i++)
+ results.push(iterable[i]);
+ return results;
+ }
+}
+
+Object.extend(Array.prototype, Enumerable);
+
+if (!Array.prototype._reverse)
+ Array.prototype._reverse = Array.prototype.reverse;
+
+Object.extend(Array.prototype, {
+ _each: function(iterator) {
+ for (var i = 0; i < this.length; i++)
+ iterator(this[i]);
+ },
+
+ clear: function() {
+ this.length = 0;
+ return this;
+ },
+
+ first: function() {
+ return this[0];
+ },
+
+ last: function() {
+ return this[this.length - 1];
+ },
+
+ compact: function() {
+ return this.select(function(value) {
+ return value != undefined || value != null;
+ });
+ },
+
+ flatten: function() {
+ return this.inject([], function(array, value) {
+ return array.concat(value && value.constructor == Array ?
+ value.flatten() : [value]);
+ });
+ },
+
+ without: function() {
+ var values = $A(arguments);
+ return this.select(function(value) {
+ return !values.include(value);
+ });
+ },
+
+ indexOf: function(object) {
+ for (var i = 0; i < this.length; i++)
+ if (this[i] == object) return i;
+ return -1;
+ },
+
+ reverse: function(inline) {
+ return (inline !== false ? this : this.toArray())._reverse();
+ },
+
+ reduce: function() {
+ return this.length > 1 ? this : this[0];
+ },
+
+ uniq: function() {
+ return this.inject([], function(array, value) {
+ return array.include(value) ? array : array.concat([value]);
+ });
+ },
+
+ inspect: function() {
+ return '[' + this.map(Object.inspect).join(', ') + ']';
+ }
+});
+var Hash = {
+ _each: function(iterator) {
+ for (var key in this) {
+ var value = this[key];
+ if (typeof value == 'function') continue;
+
+ var pair = [key, value];
+ pair.key = key;
+ pair.value = value;
+ iterator(pair);
+ }
+ },
+
+ keys: function() {
+ return this.pluck('key');
+ },
+
+ values: function() {
+ return this.pluck('value');
+ },
+
+ merge: function(hash) {
+ return $H(hash).inject($H(this), function(mergedHash, pair) {
+ mergedHash[pair.key] = pair.value;
+ return mergedHash;
+ });
+ },
+
+ toQueryString: function() {
+ return this.map(function(pair) {
+ return pair.map(encodeURIComponent).join('=');
+ }).join('&');
+ },
+
+ inspect: function() {
+ return '#<Hash:{' + this.map(function(pair) {
+ return pair.map(Object.inspect).join(': ');
+ }).join(', ') + '}>';
+ }
+}
+
+function $H(object) {
+ var hash = Object.extend({}, object || {});
+ Object.extend(hash, Enumerable);
+ Object.extend(hash, Hash);
+ return hash;
+}
+ObjectRange = Class.create();
+Object.extend(ObjectRange.prototype, Enumerable);
+Object.extend(ObjectRange.prototype, {
+ initialize: function(start, end, exclusive) {
+ this.start = start;
+ this.end = end;
+ this.exclusive = exclusive;
+ },
+
+ _each: function(iterator) {
+ var value = this.start;
+ while (this.include(value)) {
+ iterator(value);
+ value = value.succ();
+ }
+ },
+
+ include: function(value) {
+ if (value < this.start)
+ return false;
+ if (this.exclusive)
+ return value < this.end;
+ return value <= this.end;
+ }
+});
+
+var $R = function(start, end, exclusive) {
+ return new ObjectRange(start, end, exclusive);
+}
+
+var Ajax = {
+ getTransport: function() {
+ return Try.these(
+ function() {return new XMLHttpRequest()},
+ function() {return new ActiveXObject('Msxml2.XMLHTTP')},
+ function() {return new ActiveXObject('Microsoft.XMLHTTP')}
+ ) || false;
+ },
+
+ activeRequestCount: 0
+}
+
+Ajax.Responders = {
+ responders: [],
+
+ _each: function(iterator) {
+ this.responders._each(iterator);
+ },
+
+ register: function(responderToAdd) {
+ if (!this.include(responderToAdd))
+ this.responders.push(responderToAdd);
+ },
+
+ unregister: function(responderToRemove) {
+ this.responders = this.responders.without(responderToRemove);
+ },
+
+ dispatch: function(callback, request, transport, json) {
+ this.each(function(responder) {
+ if (responder[callback] && typeof responder[callback] == 'function') {
+ try {
+ responder[callback].apply(responder, [request, transport, json]);
+ } catch (e) {}
+ }
+ });
+ }
+};
+
+Object.extend(Ajax.Responders, Enumerable);
+
+Ajax.Responders.register({
+ onCreate: function() {
+ Ajax.activeRequestCount++;
+ },
+
+ onComplete: function() {
+ Ajax.activeRequestCount--;
+ }
+});
+
+Ajax.Base = function() {};
+Ajax.Base.prototype = {
+ setOptions: function(options) {
+ this.options = {
+ method: 'post',
+ asynchronous: true,
+ contentType: 'application/x-www-form-urlencoded',
+ parameters: ''
+ }
+ Object.extend(this.options, options || {});
+ },
+
+ responseIsSuccess: function() {
+ return this.transport.status == undefined
+ || this.transport.status == 0
+ || (this.transport.status >= 200 && this.transport.status < 300);
+ },
+
+ responseIsFailure: function() {
+ return !this.responseIsSuccess();
+ }
+}
+
+Ajax.Request = Class.create();
+Ajax.Request.Events =
+ ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
+
+Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
+ initialize: function(url, options) {
+ this.transport = Ajax.getTransport();
+ this.setOptions(options);
+ this.request(url);
+ },
+
+ request: function(url) {
+ var parameters = this.options.parameters || '';
+ if (parameters.length > 0) parameters += '&_=';
+
+ /* Simulate other verbs over post */
+ if (this.options.method != 'get' && this.options.method != 'post') {
+ parameters += (parameters.length > 0 ? '&' : '') + '_method=' + this.options.method;
+ this.options.method = 'post';
+ }
+
+ try {
+ this.url = url;
+ if (this.options.method == 'get' && parameters.length > 0)
+ this.url += (this.url.match(/\?/) ? '&' : '?') + parameters;
+
+ Ajax.Responders.dispatch('onCreate', this, this.transport);
+
+ this.transport.open(this.options.method, this.url,
+ this.options.asynchronous);
+
+ if (this.options.asynchronous)
+ setTimeout(function() { this.respondToReadyState(1) }.bind(this), 10);
+
+ this.transport.onreadystatechange = this.onStateChange.bind(this);
+ this.setRequestHeaders();
+
+ var body = this.options.postBody ? this.options.postBody : parameters;
+ this.transport.send(this.options.method == 'post' ? body : null);
+
+ /* Force Firefox to handle ready state 4 for synchronous requests */
+ if (!this.options.asynchronous && this.transport.overrideMimeType)
+ this.onStateChange();
+
+ } catch (e) {
+ this.dispatchException(e);
+ }
+ },
+
+ setRequestHeaders: function() {
+ var requestHeaders =
+ ['X-Requested-With', 'XMLHttpRequest',
+ 'X-Prototype-Version', Prototype.Version,
+ 'Accept', 'text/javascript, text/html, application/xml, text/xml, */*'];
+
+ if (this.options.method == 'post') {
+ requestHeaders.push('Content-type', this.options.contentType);
+
+ /* Force "Connection: close" for Mozilla browsers to work around
+ * a bug where XMLHttpReqeuest sends an incorrect Content-length
+ * header. See Mozilla Bugzilla #246651.
+ */
+ if (this.transport.overrideMimeType)
+ requestHeaders.push('Connection', 'close');
+ }
+
+ if (this.options.requestHeaders)
+ requestHeaders.push.apply(requestHeaders, this.options.requestHeaders);
+
+ for (var i = 0; i < requestHeaders.length; i += 2)
+ this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]);
+ },
+
+ onStateChange: function() {
+ var readyState = this.transport.readyState;
+ if (readyState != 1)
+ this.respondToReadyState(this.transport.readyState);
+ },
+
+ header: function(name) {
+ try {
+ return this.transport.getResponseHeader(name);
+ } catch (e) {}
+ },
+
+ evalJSON: function() {
+ try {
+ return eval('(' + this.header('X-JSON') + ')');
+ } catch (e) {}
+ },
+
+ evalResponse: function() {
+ try {
+ return eval(this.transport.responseText);
+ } catch (e) {
+ this.dispatchException(e);
+ }
+ },
+
+ respondToReadyState: function(readyState) {
+ var event = Ajax.Request.Events[readyState];
+ var transport = this.transport, json = this.evalJSON();
+
+ if (event == 'Complete') {
+ try {
+ (this.options['on' + this.transport.status]
+ || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]
+ || Prototype.emptyFunction)(transport, json);
+ } catch (e) {
+ this.dispatchException(e);
+ }
+
+ if ((this.header('Content-type') || '').match(/^text\/javascript/i))
+ this.evalResponse();
+ }
+
+ try {
+ (this.options['on' + event] || Prototype.emptyFunction)(transport, json);
+ Ajax.Responders.dispatch('on' + event, this, transport, json);
+ } catch (e) {
+ this.dispatchException(e);
+ }
+
+ /* Avoid memory leak in MSIE: clean up the oncomplete event handler */
+ if (event == 'Complete')
+ this.transport.onreadystatechange = Prototype.emptyFunction;
+ },
+
+ dispatchException: function(exception) {
+ (this.options.onException || Prototype.emptyFunction)(this, exception);
+ Ajax.Responders.dispatch('onException', this, exception);
+ }
+});
+
+Ajax.Updater = Class.create();
+
+Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), {
+ initialize: function(container, url, options) {
+ this.containers = {
+ success: container.success ? $(container.success) : $(container),
+ failure: container.failure ? $(container.failure) :
+ (container.success ? null : $(container))
+ }
+
+ this.transport = Ajax.getTransport();
+ this.setOptions(options);
+
+ var onComplete = this.options.onComplete || Prototype.emptyFunction;
+ this.options.onComplete = (function(transport, object) {
+ this.updateContent();
+ onComplete(transport, object);
+ }).bind(this);
+
+ this.request(url);
+ },
+
+ updateContent: function() {
+ var receiver = this.responseIsSuccess() ?
+ this.containers.success : this.containers.failure;
+ var response = this.transport.responseText;
+
+ if (!this.options.evalScripts)
+ response = response.stripScripts();
+
+ if (receiver) {
+ if (this.options.insertion) {
+ new this.options.insertion(receiver, response);
+ } else {
+ Element.update(receiver, response);
+ }
+ }
+
+ if (this.responseIsSuccess()) {
+ if (this.onComplete)
+ setTimeout(this.onComplete.bind(this), 10);
+ }
+ }
+});
+
+Ajax.PeriodicalUpdater = Class.create();
+Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), {
+ initialize: function(container, url, options) {
+ this.setOptions(options);
+ this.onComplete = this.options.onComplete;
+
+ this.frequency = (this.options.frequency || 2);
+ this.decay = (this.options.decay || 1);
+
+ this.updater = {};
+ this.container = container;
+ this.url = url;
+
+ this.start();
+ },
+
+ start: function() {
+ this.options.onComplete = this.updateComplete.bind(this);
+ this.onTimerEvent();
+ },
+
+ stop: function() {
+ this.updater.options.onComplete = undefined;
+ clearTimeout(this.timer);
+ (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
+ },
+
+ updateComplete: function(request) {
+ if (this.options.decay) {
+ this.decay = (request.responseText == this.lastText ?
+ this.decay * this.options.decay : 1);
+
+ this.lastText = request.responseText;
+ }
+ this.timer = setTimeout(this.onTimerEvent.bind(this),
+ this.decay * this.frequency * 1000);
+ },
+
+ onTimerEvent: function() {
+ this.updater = new Ajax.Updater(this.container, this.url, this.options);
+ }
+});
+function $() {
+ var results = [], element;
+ for (var i = 0; i < arguments.length; i++) {
+ element = arguments[i];
+ if (typeof element == 'string')
+ element = document.getElementById(element);
+ results.push(Element.extend(element));
+ }
+ return results.reduce();
+}
+
+document.getElementsByClassName = function(className, parentElement) {
+ var children = ($(parentElement) || document.body).getElementsByTagName('*');
+ return $A(children).inject([], function(elements, child) {
+ if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))
+ elements.push(Element.extend(child));
+ return elements;
+ });
+}
+
+/*--------------------------------------------------------------------------*/
+
+if (!window.Element)
+ var Element = new Object();
+
+Element.extend = function(element) {
+ if (!element) return;
+ if (_nativeExtensions || element.nodeType == 3) return element;
+
+ if (!element._extended && element.tagName && element != window) {
+ var methods = Object.clone(Element.Methods), cache = Element.extend.cache;
+
+ if (element.tagName == 'FORM')
+ Object.extend(methods, Form.Methods);
+ if (['INPUT', 'TEXTAREA', 'SELECT'].include(element.tagName))
+ Object.extend(methods, Form.Element.Methods);
+
+ for (var property in methods) {
+ var value = methods[property];
+ if (typeof value == 'function')
+ element[property] = cache.findOrStore(value);
+ }
+ }
+
+ element._extended = true;
+ return element;
+}
+
+Element.extend.cache = {
+ findOrStore: function(value) {
+ return this[value] = this[value] || function() {
+ return value.apply(null, [this].concat($A(arguments)));
+ }
+ }
+}
+
+Element.Methods = {
+ visible: function(element) {
+ return $(element).style.display != 'none';
+ },
+
+ toggle: function(element) {
+ element = $(element);
+ Element[Element.visible(element) ? 'hide' : 'show'](element);
+ return element;
+ },
+
+ hide: function(element) {
+ $(element).style.display = 'none';
+ return element;
+ },
+
+ show: function(element) {
+ $(element).style.display = '';
+ return element;
+ },
+
+ remove: function(element) {
+ element = $(element);
+ element.parentNode.removeChild(element);
+ return element;
+ },
+
+ update: function(element, html) {
+ $(element).innerHTML = html.stripScripts();
+ setTimeout(function() {html.evalScripts()}, 10);
+ return element;
+ },
+
+ replace: function(element, html) {
+ element = $(element);
+ if (element.outerHTML) {
+ element.outerHTML = html.stripScripts();
+ } else {
+ var range = element.ownerDocument.createRange();
+ range.selectNodeContents(element);
+ element.parentNode.replaceChild(
+ range.createContextualFragment(html.stripScripts()), element);
+ }
+ setTimeout(function() {html.evalScripts()}, 10);
+ return element;
+ },
+
+ inspect: function(element) {
+ element = $(element);
+ var result = '<' + element.tagName.toLowerCase();
+ $H({'id': 'id', 'className': 'class'}).each(function(pair) {
+ var property = pair.first(), attribute = pair.last();
+ var value = (element[property] || '').toString();
+ if (value) result += ' ' + attribute + '=' + value.inspect(true);
+ });
+ return result + '>';
+ },
+
+ recursivelyCollect: function(element, property) {
+ element = $(element);
+ var elements = [];
+ while (element = element[property])
+ if (element.nodeType == 1)
+ elements.push(Element.extend(element));
+ return elements;
+ },
+
+ ancestors: function(element) {
+ return $(element).recursivelyCollect('parentNode');
+ },
+
+ descendants: function(element) {
+ element = $(element);
+ return $A(element.getElementsByTagName('*'));
+ },
+
+ previousSiblings: function(element) {
+ return $(element).recursivelyCollect('previousSibling');
+ },
+
+ nextSiblings: function(element) {
+ return $(element).recursivelyCollect('nextSibling');
+ },
+
+ siblings: function(element) {
+ element = $(element);
+ return element.previousSiblings().reverse().concat(element.nextSiblings());
+ },
+
+ match: function(element, selector) {
+ element = $(element);
+ if (typeof selector == 'string')
+ selector = new Selector(selector);
+ return selector.match(element);
+ },
+
+ up: function(element, expression, index) {
+ return Selector.findElement($(element).ancestors(), expression, index);
+ },
+
+ down: function(element, expression, index) {
+ return Selector.findElement($(element).descendants(), expression, index);
+ },
+
+ previous: function(element, expression, index) {
+ return Selector.findElement($(element).previousSiblings(), expression, index);
+ },
+
+ next: function(element, expression, index) {
+ return Selector.findElement($(element).nextSiblings(), expression, index);
+ },
+
+ getElementsBySelector: function() {
+ var args = $A(arguments), element = $(args.shift());
+ return Selector.findChildElements(element, args);
+ },
+
+ getElementsByClassName: function(element, className) {
+ element = $(element);
+ return document.getElementsByClassName(className, element);
+ },
+
+ getHeight: function(element) {
+ element = $(element);
+ return element.offsetHeight;
+ },
+
+ classNames: function(element) {
+ return new Element.ClassNames(element);
+ },
+
+ hasClassName: function(element, className) {
+ if (!(element = $(element))) return;
+ return Element.classNames(element).include(className);
+ },
+
+ addClassName: function(element, className) {
+ if (!(element = $(element))) return;
+ Element.classNames(element).add(className);
+ return element;
+ },
+
+ removeClassName: function(element, className) {
+ if (!(element = $(element))) return;
+ Element.classNames(element).remove(className);
+ return element;
+ },
+
+ observe: function() {
+ Event.observe.apply(Event, arguments);
+ return $A(arguments).first();
+ },
+
+ stopObserving: function() {
+ Event.stopObserving.apply(Event, arguments);
+ return $A(arguments).first();
+ },
+
+ // removes whitespace-only text node children
+ cleanWhitespace: function(element) {
+ element = $(element);
+ var node = element.firstChild;
+ while (node) {
+ var nextNode = node.nextSibling;
+ if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
+ element.removeChild(node);
+ node = nextNode;
+ }
+ return element;
+ },
+
+ empty: function(element) {
+ return $(element).innerHTML.match(/^\s*$/);
+ },
+
+ childOf: function(element, ancestor) {
+ element = $(element), ancestor = $(ancestor);
+ while (element = element.parentNode)
+ if (element == ancestor) return true;
+ return false;
+ },
+
+ scrollTo: function(element) {
+ element = $(element);
+ var x = element.x ? element.x : element.offsetLeft,
+ y = element.y ? element.y : element.offsetTop;
+ window.scrollTo(x, y);
+ return element;
+ },
+
+ getStyle: function(element, style) {
+ element = $(element);
+ var value = element.style[style.camelize()];
+ if (!value) {
+ if (document.defaultView && document.defaultView.getComputedStyle) {
+ var css = document.defaultView.getComputedStyle(element, null);
+ value = css ? css.getPropertyValue(style) : null;
+ } else if (element.currentStyle) {
+ value = element.currentStyle[style.camelize()];
+ }
+ }
+
+ if (window.opera && ['left', 'top', 'right', 'bottom'].include(style))
+ if (Element.getStyle(element, 'position') == 'static') value = 'auto';
+
+ return value == 'auto' ? null : value;
+ },
+
+ setStyle: function(element, style) {
+ element = $(element);
+ for (var name in style)
+ element.style[name.camelize()] = style[name];
+ return element;
+ },
+
+ getDimensions: function(element) {
+ element = $(element);
+ if (Element.getStyle(element, 'display') != 'none')
+ return {width: element.offsetWidth, height: element.offsetHeight};
+
+ // All *Width and *Height properties give 0 on elements with display none,
+ // so enable the element temporarily
+ var els = element.style;
+ var originalVisibility = els.visibility;
+ var originalPosition = els.position;
+ els.visibility = 'hidden';
+ els.position = 'absolute';
+ els.display = '';
+ var originalWidth = element.clientWidth;
+ var originalHeight = element.clientHeight;
+ els.display = 'none';
+ els.position = originalPosition;
+ els.visibility = originalVisibility;
+ return {width: originalWidth, height: originalHeight};
+ },
+
+ makePositioned: function(element) {
+ element = $(element);
+ var pos = Element.getStyle(element, 'position');
+ if (pos == 'static' || !pos) {
+ element._madePositioned = true;
+ element.style.position = 'relative';
+ // Opera returns the offset relative to the positioning context, when an
+ // element is position relative but top and left have not been defined
+ if (window.opera) {
+ element.style.top = 0;
+ element.style.left = 0;
+ }
+ }
+ return element;
+ },
+
+ undoPositioned: function(element) {
+ element = $(element);
+ if (element._madePositioned) {
+ element._madePositioned = undefined;
+ element.style.position =
+ element.style.top =
+ element.style.left =
+ element.style.bottom =
+ element.style.right = '';
+ }
+ return element;
+ },
+
+ makeClipping: function(element) {
+ element = $(element);
+ if (element._overflow) return;
+ element._overflow = element.style.overflow || 'auto';
+ if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden')
+ element.style.overflow = 'hidden';
+ return element;
+ },
+
+ undoClipping: function(element) {
+ element = $(element);
+ if (!element._overflow) return;
+ element.style.overflow = element._overflow == 'auto' ? '' : element._overflow;
+ element._overflow = null;
+ return element;
+ }
+}
+
+// IE is missing .innerHTML support for TABLE-related elements
+if(document.all){
+ Element.Methods.update = function(element, html) {
+ element = $(element);
+ var tagName = element.tagName.toUpperCase();
+ if (['THEAD','TBODY','TR','TD'].indexOf(tagName) > -1) {
+ var div = document.createElement('div');
+ switch (tagName) {
+ case 'THEAD':
+ case 'TBODY':
+ div.innerHTML = '<table><tbody>' + html.stripScripts() + '</tbody></table>';
+ depth = 2;
+ break;
+ case 'TR':
+ div.innerHTML = '<table><tbody><tr>' + html.stripScripts() + '</tr></tbody></table>';
+ depth = 3;
+ break;
+ case 'TD':
+ div.innerHTML = '<table><tbody><tr><td>' + html.stripScripts() + '</td></tr></tbody></table>';
+ depth = 4;
+ }
+ $A(element.childNodes).each(function(node){
+ element.removeChild(node)
+ });
+ depth.times(function(){ div = div.firstChild });
+
+ $A(div.childNodes).each(
+ function(node){ element.appendChild(node) });
+ } else {
+ element.innerHTML = html.stripScripts();
+ }
+ setTimeout(function() {html.evalScripts()}, 10);
+ return element;
+ }
+}
+
+Object.extend(Element, Element.Methods);
+
+var _nativeExtensions = false;
+
+if (!window.HTMLElement && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) {
+ /* Emulate HTMLElement, HTMLFormElement, HTMLInputElement, HTMLTextAreaElement,
+ and HTMLSelectElement in Safari */
+ ['', 'Form', 'Input', 'TextArea', 'Select'].each(function(tag) {
+ var klass = window['HTML' + tag + 'Element'] = {};
+ klass.prototype = document.createElement(tag ? tag.toLowerCase() : 'div').__proto__;
+ });
+}
+
+Element.addMethods = function(methods) {
+ Object.extend(Element.Methods, methods || {});
+
+ function copy(methods, destination) {
+ var cache = Element.extend.cache;
+ for (var property in methods) {
+ var value = methods[property];
+ destination[property] = cache.findOrStore(value);
+ }
+ }
+
+ if (typeof HTMLElement != 'undefined') {
+ copy(Element.Methods, HTMLElement.prototype);
+ copy(Form.Methods, HTMLFormElement.prototype);
+ [HTMLInputElement, HTMLTextAreaElement, HTMLSelectElement].each(function(klass) {
+ copy(Form.Element.Methods, klass.prototype);
+ });
+ _nativeExtensions = true;
+ }
+}
+
+var Toggle = new Object();
+Toggle.display = Element.toggle;
+
+/*--------------------------------------------------------------------------*/
+
+Abstract.Insertion = function(adjacency) {
+ this.adjacency = adjacency;
+}
+
+Abstract.Insertion.prototype = {
+ initialize: function(element, content) {
+ this.element = $(element);
+ this.content = content.stripScripts();
+
+ if (this.adjacency && this.element.insertAdjacentHTML) {
+ try {
+ this.element.insertAdjacentHTML(this.adjacency, this.content);
+ } catch (e) {
+ var tagName = this.element.tagName.toLowerCase();
+ if (tagName == 'tbody' || tagName == 'tr') {
+ this.insertContent(this.contentFromAnonymousTable());
+ } else {
+ throw e;
+ }
+ }
+ } else {
+ this.range = this.element.ownerDocument.createRange();
+ if (this.initializeRange) this.initializeRange();
+ this.insertContent([this.range.createContextualFragment(this.content)]);
+ }
+
+ setTimeout(function() {content.evalScripts()}, 10);
+ },
+
+ contentFromAnonymousTable: function() {
+ var div = document.createElement('div');
+ div.innerHTML = '<table><tbody>' + this.content + '</tbody></table>';
+ return $A(div.childNodes[0].childNodes[0].childNodes);
+ }
+}
+
+var Insertion = new Object();
+
+Insertion.Before = Class.create();
+Insertion.Before.prototype = Object.extend(new Abstract.Insertion('beforeBegin'), {
+ initializeRange: function() {
+ this.range.setStartBefore(this.element);
+ },
+
+ insertContent: function(fragments) {
+ fragments.each((function(fragment) {
+ this.element.parentNode.insertBefore(fragment, this.element);
+ }).bind(this));
+ }
+});
+
+Insertion.Top = Class.create();
+Insertion.Top.prototype = Object.extend(new Abstract.Insertion('afterBegin'), {
+ initializeRange: function() {
+ this.range.selectNodeContents(this.element);
+ this.range.collapse(true);
+ },
+
+ insertContent: function(fragments) {
+ fragments.reverse(false).each((function(fragment) {
+ this.element.insertBefore(fragment, this.element.firstChild);
+ }).bind(this));
+ }
+});
+
+Insertion.Bottom = Class.create();
+Insertion.Bottom.prototype = Object.extend(new Abstract.Insertion('beforeEnd'), {
+ initializeRange: function() {
+ this.range.selectNodeContents(this.element);
+ this.range.collapse(this.element);
+ },
+
+ insertContent: function(fragments) {
+ fragments.each((function(fragment) {
+ this.element.appendChild(fragment);
+ }).bind(this));
+ }
+});
+
+Insertion.After = Class.create();
+Insertion.After.prototype = Object.extend(new Abstract.Insertion('afterEnd'), {
+ initializeRange: function() {
+ this.range.setStartAfter(this.element);
+ },
+
+ insertContent: function(fragments) {
+ fragments.each((function(fragment) {
+ this.element.parentNode.insertBefore(fragment,
+ this.element.nextSibling);
+ }).bind(this));
+ }
+});
+
+/*--------------------------------------------------------------------------*/
+
+Element.ClassNames = Class.create();
+Element.ClassNames.prototype = {
+ initialize: function(element) {
+ this.element = $(element);
+ },
+
+ _each: function(iterator) {
+ this.element.className.split(/\s+/).select(function(name) {
+ return name.length > 0;
+ })._each(iterator);
+ },
+
+ set: function(className) {
+ this.element.className = className;
+ },
+
+ add: function(classNameToAdd) {
+ if (this.include(classNameToAdd)) return;
+ this.set(this.toArray().concat(classNameToAdd).join(' '));
+ },
+
+ remove: function(classNameToRemove) {
+ if (!this.include(classNameToRemove)) return;
+ this.set(this.select(function(className) {
+ return className != classNameToRemove;
+ }).join(' '));
+ },
+
+ toString: function() {
+ return this.toArray().join(' ');
+ }
+}
+
+Object.extend(Element.ClassNames.prototype, Enumerable);
+var Selector = Class.create();
+Selector.prototype = {
+ initialize: function(expression) {
+ this.params = {classNames: []};
+ this.expression = expression.toString().strip();
+ this.parseExpression();
+ this.compileMatcher();
+ },
+
+ parseExpression: function() {
+ function abort(message) { throw 'Parse error in selector: ' + message; }
+
+ if (this.expression == '') abort('empty expression');
+
+ var params = this.params, expr = this.expression, match, modifier, clause, rest;
+ while (match = expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)) {
+ params.attributes = params.attributes || [];
+ params.attributes.push({name: match[2], operator: match[3], value: match[4] || match[5] || ''});
+ expr = match[1];
+ }
+
+ if (expr == '*') return this.params.wildcard = true;
+
+ while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)) {
+ modifier = match[1], clause = match[2], rest = match[3];
+ switch (modifier) {
+ case '#': params.id = clause; break;
+ case '.': params.classNames.push(clause); break;
+ case '':
+ case undefined: params.tagName = clause.toUpperCase(); break;
+ default: abort(expr.inspect());
+ }
+ expr = rest;
+ }
+
+ if (expr.length > 0) abort(expr.inspect());
+ },
+
+ buildMatchExpression: function() {
+ var params = this.params, conditions = [], clause;
+
+ if (params.wildcard)
+ conditions.push('true');
+ if (clause = params.id)
+ conditions.push('element.id == ' + clause.inspect());
+ if (clause = params.tagName)
+ conditions.push('element.tagName.toUpperCase() == ' + clause.inspect());
+ if ((clause = params.classNames).length > 0)
+ for (var i = 0; i < clause.length; i++)
+ conditions.push('Element.hasClassName(element, ' + clause[i].inspect() + ')');
+ if (clause = params.attributes) {
+ clause.each(function(attribute) {
+ var value = 'element.getAttribute(' + attribute.name.inspect() + ')';
+ var splitValueBy = function(delimiter) {
+ return value + ' && ' + value + '.split(' + delimiter.inspect() + ')';
+ }
+
+ switch (attribute.operator) {
+ case '=': conditions.push(value + ' == ' + attribute.value.inspect()); break;
+ case '~=': conditions.push(splitValueBy(' ') + '.include(' + attribute.value.inspect() + ')'); break;
+ case '|=': conditions.push(
+ splitValueBy('-') + '.first().toUpperCase() == ' + attribute.value.toUpperCase().inspect()
+ ); break;
+ case '!=': conditions.push(value + ' != ' + attribute.value.inspect()); break;
+ case '':
+ case undefined: conditions.push(value + ' != null'); break;
+ default: throw 'Unknown operator ' + attribute.operator + ' in selector';
+ }
+ });
+ }
+
+ return conditions.join(' && ');
+ },
+
+ compileMatcher: function() {
+ this.match = new Function('element', 'if (!element.tagName) return false; \
+ return ' + this.buildMatchExpression());
+ },
+
+ findElements: function(scope) {
+ var element;
+
+ if (element = $(this.params.id))
+ if (this.match(element))
+ if (!scope || Element.childOf(element, scope))
+ return [element];
+
+ scope = (scope || document).getElementsByTagName(this.params.tagName || '*');
+
+ var results = [];
+ for (var i = 0; i < scope.length; i++)
+ if (this.match(element = scope[i]))
+ results.push(Element.extend(element));
+
+ return results;
+ },
+
+ toString: function() {
+ return this.expression;
+ }
+}
+
+Object.extend(Selector, {
+ matchElements: function(elements, expression) {
+ var selector = new Selector(expression);
+ return elements.select(selector.match.bind(selector));
+ },
+
+ findElement: function(elements, expression, index) {
+ if (typeof expression == 'number') index = expression, expression = false;
+ return Selector.matchElements(elements, expression || '*')[index || 0];
+ },
+
+ findChildElements: function(element, expressions) {
+ return expressions.map(function(expression) {
+ return expression.strip().split(/\s+/).inject([null], function(results, expr) {
+ var selector = new Selector(expr);
+ return results.inject([], function(elements, result) {
+ return elements.concat(selector.findElements(result || element));
+ });
+ });
+ }).flatten();
+ }
+});
+
+function $$() {
+ return Selector.findChildElements(document, $A(arguments));
+}
+var Form = {
+ reset: function(form) {
+ $(form).reset();
+ return form;
+ }
+};
+
+Form.Methods = {
+ serialize: function(form) {
+ var elements = Form.getElements($(form));
+ var queryComponents = new Array();
+
+ for (var i = 0; i < elements.length; i++) {
+ var queryComponent = Form.Element.serialize(elements[i]);
+ if (queryComponent)
+ queryComponents.push(queryComponent);
+ }
+
+ return queryComponents.join('&');
+ },
+
+ getElements: function(form) {
+ form = $(form);
+ var elements = new Array();
+
+ for (var tagName in Form.Element.Serializers) {
+ var tagElements = form.getElementsByTagName(tagName);
+ for (var j = 0; j < tagElements.length; j++)
+ elements.push(tagElements[j]);
+ }
+ return elements;
+ },
+
+ getInputs: function(form, typeName, name) {
+ form = $(form);
+ var inputs = form.getElementsByTagName('input');
+
+ if (!typeName && !name)
+ return inputs;
+
+ var matchingInputs = new Array();
+ for (var i = 0; i < inputs.length; i++) {
+ var input = inputs[i];
+ if ((typeName && input.type != typeName) ||
+ (name && input.name != name))
+ continue;
+ matchingInputs.push(input);
+ }
+
+ return matchingInputs;
+ },
+
+ disable: function(form) {
+ form = $(form);
+ var elements = Form.getElements(form);
+ for (var i = 0; i < elements.length; i++) {
+ var element = elements[i];
+ element.blur();
+ element.disabled = 'true';
+ }
+ return form;
+ },
+
+ enable: function(form) {
+ form = $(form);
+ var elements = Form.getElements(form);
+ for (var i = 0; i < elements.length; i++) {
+ var element = elements[i];
+ element.disabled = '';
+ }
+ return form;
+ },
+
+ findFirstElement: function(form) {
+ return Form.getElements(form).find(function(element) {
+ return element.type != 'hidden' && !element.disabled &&
+ ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
+ });
+ },
+
+ focusFirstElement: function(form) {
+ form = $(form);
+ Field.activate(Form.findFirstElement(form));
+ return form;
+ }
+}
+
+Object.extend(Form, Form.Methods);
+
+/*--------------------------------------------------------------------------*/
+
+Form.Element = {
+ focus: function(element) {
+ $(element).focus();
+ return element;
+ },
+
+ select: function(element) {
+ $(element).select();
+ return element;
+ }
+}
+
+Form.Element.Methods = {
+ serialize: function(element) {
+ element = $(element);
+ var method = element.tagName.toLowerCase();
+ var parameter = Form.Element.Serializers[method](element);
+
+ if (parameter) {
+ var key = encodeURIComponent(parameter[0]);
+ if (key.length == 0) return;
+
+ if (parameter[1].constructor != Array)
+ parameter[1] = [parameter[1]];
+
+ return parameter[1].map(function(value) {
+ return key + '=' + encodeURIComponent(value);
+ }).join('&');
+ }
+ },
+
+ getValue: function(element) {
+ element = $(element);
+ var method = element.tagName.toLowerCase();
+ var parameter = Form.Element.Serializers[method](element);
+
+ if (parameter)
+ return parameter[1];
+ },
+
+ clear: function(element) {
+ $(element).value = '';
+ return element;
+ },
+
+ present: function(element) {
+ return $(element).value != '';
+ },
+
+ activate: function(element) {
+ element = $(element);
+ element.focus();
+ if (element.select)
+ element.select();
+ return element;
+ },
+
+ disable: function(element) {
+ element = $(element);
+ element.disabled = '';
+ return element;
+ },
+
+ enable: function(element) {
+ element = $(element);
+ element.blur();
+ element.disabled = 'true';
+ return element;
+ }
+}
+
+Object.extend(Form.Element, Form.Element.Methods);
+var Field = Form.Element;
+
+/*--------------------------------------------------------------------------*/
+
+Form.Element.Serializers = {
+ input: function(element) {
+ switch (element.type.toLowerCase()) {
+ case 'checkbox':
+ case 'radio':
+ return Form.Element.Serializers.inputSelector(element);
+ default:
+ return Form.Element.Serializers.textarea(element);
+ }
+ return false;
+ },
+
+ inputSelector: function(element) {
+ if (element.checked)
+ return [element.name, element.value];
+ },
+
+ textarea: function(element) {
+ return [element.name, element.value];
+ },
+
+ select: function(element) {
+ return Form.Element.Serializers[element.type == 'select-one' ?
+ 'selectOne' : 'selectMany'](element);
+ },
+
+ selectOne: function(element) {
+ var value = '', opt, index = element.selectedIndex;
+ if (index >= 0) {
+ opt = element.options[index];
+ value = opt.value || opt.text;
+ }
+ return [element.name, value];
+ },
+
+ selectMany: function(element) {
+ var value = [];
+ for (var i = 0; i < element.length; i++) {
+ var opt = element.options[i];
+ if (opt.selected)
+ value.push(opt.value || opt.text);
+ }
+ return [element.name, value];
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+
+var $F = Form.Element.getValue;
+
+/*--------------------------------------------------------------------------*/
+
+Abstract.TimedObserver = function() {}
+Abstract.TimedObserver.prototype = {
+ initialize: function(element, frequency, callback) {
+ this.frequency = frequency;
+ this.element = $(element);
+ this.callback = callback;
+
+ this.lastValue = this.getValue();
+ this.registerCallback();
+ },
+
+ registerCallback: function() {
+ setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
+ },
+
+ onTimerEvent: function() {
+ var value = this.getValue();
+ if (this.lastValue != value) {
+ this.callback(this.element, value);
+ this.lastValue = value;
+ }
+ }
+}
+
+Form.Element.Observer = Class.create();
+Form.Element.Observer.prototype = Object.extend(new Abstract.TimedObserver(), {
+ getValue: function() {
+ return Form.Element.getValue(this.element);
+ }
+});
+
+Form.Observer = Class.create();
+Form.Observer.prototype = Object.extend(new Abstract.TimedObserver(), {
+ getValue: function() {
+ return Form.serialize(this.element);
+ }
+});
+
+/*--------------------------------------------------------------------------*/
+
+Abstract.EventObserver = function() {}
+Abstract.EventObserver.prototype = {
+ initialize: function(element, callback) {
+ this.element = $(element);
+ this.callback = callback;
+
+ this.lastValue = this.getValue();
+ if (this.element.tagName.toLowerCase() == 'form')
+ this.registerFormCallbacks();
+ else
+ this.registerCallback(this.element);
+ },
+
+ onElementEvent: function() {
+ var value = this.getValue();
+ if (this.lastValue != value) {
+ this.callback(this.element, value);
+ this.lastValue = value;
+ }
+ },
+
+ registerFormCallbacks: function() {
+ var elements = Form.getElements(this.element);
+ for (var i = 0; i < elements.length; i++)
+ this.registerCallback(elements[i]);
+ },
+
+ registerCallback: function(element) {
+ if (element.type) {
+ switch (element.type.toLowerCase()) {
+ case 'checkbox':
+ case 'radio':
+ Event.observe(element, 'click', this.onElementEvent.bind(this));
+ break;
+ default:
+ Event.observe(element, 'change', this.onElementEvent.bind(this));
+ break;
+ }
+ }
+ }
+}
+
+Form.Element.EventObserver = Class.create();
+Form.Element.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), {
+ getValue: function() {
+ return Form.Element.getValue(this.element);
+ }
+});
+
+Form.EventObserver = Class.create();
+Form.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), {
+ getValue: function() {
+ return Form.serialize(this.element);
+ }
+});
+if (!window.Event) {
+ var Event = new Object();
+}
+
+Object.extend(Event, {
+ KEY_BACKSPACE: 8,
+ KEY_TAB: 9,
+ KEY_RETURN: 13,
+ KEY_ESC: 27,
+ KEY_LEFT: 37,
+ KEY_UP: 38,
+ KEY_RIGHT: 39,
+ KEY_DOWN: 40,
+ KEY_DELETE: 46,
+ KEY_HOME: 36,
+ KEY_END: 35,
+ KEY_PAGEUP: 33,
+ KEY_PAGEDOWN: 34,
+
+ element: function(event) {
+ return event.target || event.srcElement;
+ },
+
+ isLeftClick: function(event) {
+ return (((event.which) && (event.which == 1)) ||
+ ((event.button) && (event.button == 1)));
+ },
+
+ pointerX: function(event) {
+ return event.pageX || (event.clientX +
+ (document.documentElement.scrollLeft || document.body.scrollLeft));
+ },
+
+ pointerY: function(event) {
+ return event.pageY || (event.clientY +
+ (document.documentElement.scrollTop || document.body.scrollTop));
+ },
+
+ stop: function(event) {
+ if (event.preventDefault) {
+ event.preventDefault();
+ event.stopPropagation();
+ } else {
+ event.returnValue = false;
+ event.cancelBubble = true;
+ }
+ },
+
+ // find the first node with the given tagName, starting from the
+ // node the event was triggered on; traverses the DOM upwards
+ findElement: function(event, tagName) {
+ var element = Event.element(event);
+ while (element.parentNode && (!element.tagName ||
+ (element.tagName.toUpperCase() != tagName.toUpperCase())))
+ element = element.parentNode;
+ return element;
+ },
+
+ observers: false,
+
+ _observeAndCache: function(element, name, observer, useCapture) {
+ if (!this.observers) this.observers = [];
+ if (element.addEventListener) {
+ this.observers.push([element, name, observer, useCapture]);
+ element.addEventListener(name, observer, useCapture);
+ } else if (element.attachEvent) {
+ this.observers.push([element, name, observer, useCapture]);
+ element.attachEvent('on' + name, observer);
+ }
+ },
+
+ unloadCache: function() {
+ if (!Event.observers) return;
+ for (var i = 0; i < Event.observers.length; i++) {
+ Event.stopObserving.apply(this, Event.observers[i]);
+ Event.observers[i][0] = null;
+ }
+ Event.observers = false;
+ },
+
+ observe: function(element, name, observer, useCapture) {
+ element = $(element);
+ useCapture = useCapture || false;
+
+ if (name == 'keypress' &&
+ (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
+ || element.attachEvent))
+ name = 'keydown';
+
+ Event._observeAndCache(element, name, observer, useCapture);
+ },
+
+ stopObserving: function(element, name, observer, useCapture) {
+ element = $(element);
+ useCapture = useCapture || false;
+
+ if (name == 'keypress' &&
+ (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
+ || element.detachEvent))
+ name = 'keydown';
+
+ if (element.removeEventListener) {
+ element.removeEventListener(name, observer, useCapture);
+ } else if (element.detachEvent) {
+ try {
+ element.detachEvent('on' + name, observer);
+ } catch (e) {}
+ }
+ }
+});
+
+/* prevent memory leaks in IE */
+if (navigator.appVersion.match(/\bMSIE\b/))
+ Event.observe(window, 'unload', Event.unloadCache, false);
+var Position = {
+ // set to true if needed, warning: firefox performance problems
+ // NOT neeeded for page scrolling, only if draggable contained in
+ // scrollable elements
+ includeScrollOffsets: false,
+
+ // must be called before calling withinIncludingScrolloffset, every time the
+ // page is scrolled
+ prepare: function() {
+ this.deltaX = window.pageXOffset
+ || document.documentElement.scrollLeft
+ || document.body.scrollLeft
+ || 0;
+ this.deltaY = window.pageYOffset
+ || document.documentElement.scrollTop
+ || document.body.scrollTop
+ || 0;
+ },
+
+ realOffset: function(element) {
+ var valueT = 0, valueL = 0;
+ do {
+ valueT += element.scrollTop || 0;
+ valueL += element.scrollLeft || 0;
+ element = element.parentNode;
+ } while (element);
+ return [valueL, valueT];
+ },
+
+ cumulativeOffset: function(element) {
+ var valueT = 0, valueL = 0;
+ do {
+ valueT += element.offsetTop || 0;
+ valueL += element.offsetLeft || 0;
+ element = element.offsetParent;
+ } while (element);
+ return [valueL, valueT];
+ },
+
+ positionedOffset: function(element) {
+ var valueT = 0, valueL = 0;
+ do {
+ valueT += element.offsetTop || 0;
+ valueL += element.offsetLeft || 0;
+ element = element.offsetParent;
+ if (element) {
+ p = Element.getStyle(element, 'position');
+ if (p == 'relative' || p == 'absolute') break;
+ }
+ } while (element);
+ return [valueL, valueT];
+ },
+
+ offsetParent: function(element) {
+ if (element.offsetParent) return element.offsetParent;
+ if (element == document.body) return element;
+
+ while ((element = element.parentNode) && element != document.body)
+ if (Element.getStyle(element, 'position') != 'static')
+ return element;
+
+ return document.body;
+ },
+
+ // caches x/y coordinate pair to use with overlap
+ within: function(element, x, y) {
+ if (this.includeScrollOffsets)
+ return this.withinIncludingScrolloffsets(element, x, y);
+ this.xcomp = x;
+ this.ycomp = y;
+ this.offset = this.cumulativeOffset(element);
+
+ return (y >= this.offset[1] &&
+ y < this.offset[1] + element.offsetHeight &&
+ x >= this.offset[0] &&
+ x < this.offset[0] + element.offsetWidth);
+ },
+
+ withinIncludingScrolloffsets: function(element, x, y) {
+ var offsetcache = this.realOffset(element);
+
+ this.xcomp = x + offsetcache[0] - this.deltaX;
+ this.ycomp = y + offsetcache[1] - this.deltaY;
+ this.offset = this.cumulativeOffset(element);
+
+ return (this.ycomp >= this.offset[1] &&
+ this.ycomp < this.offset[1] + element.offsetHeight &&
+ this.xcomp >= this.offset[0] &&
+ this.xcomp < this.offset[0] + element.offsetWidth);
+ },
+
+ // within must be called directly before
+ overlap: function(mode, element) {
+ if (!mode) return 0;
+ if (mode == 'vertical')
+ return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
+ element.offsetHeight;
+ if (mode == 'horizontal')
+ return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
+ element.offsetWidth;
+ },
+
+ page: function(forElement) {
+ var valueT = 0, valueL = 0;
+
+ var element = forElement;
+ do {
+ valueT += element.offsetTop || 0;
+ valueL += element.offsetLeft || 0;
+
+ // Safari fix
+ if (element.offsetParent==document.body)
+ if (Element.getStyle(element,'position')=='absolute') break;
+
+ } while (element = element.offsetParent);
+
+ element = forElement;
+ do {
+ if (!window.opera || element.tagName=='BODY') {
+ valueT -= element.scrollTop || 0;
+ valueL -= element.scrollLeft || 0;
+ }
+ } while (element = element.parentNode);
+
+ return [valueL, valueT];
+ },
+
+ clone: function(source, target) {
+ var options = Object.extend({
+ setLeft: true,
+ setTop: true,
+ setWidth: true,
+ setHeight: true,
+ offsetTop: 0,
+ offsetLeft: 0
+ }, arguments[2] || {})
+
+ // find page position of source
+ source = $(source);
+ var p = Position.page(source);
+
+ // find coordinate system to use
+ target = $(target);
+ var delta = [0, 0];
+ var parent = null;
+ // delta [0,0] will do fine with position: fixed elements,
+ // position:absolute needs offsetParent deltas
+ if (Element.getStyle(target,'position') == 'absolute') {
+ parent = Position.offsetParent(target);
+ delta = Position.page(parent);
+ }
+
+ // correct by body offsets (fixes Safari)
+ if (parent == document.body) {
+ delta[0] -= document.body.offsetLeft;
+ delta[1] -= document.body.offsetTop;
+ }
+
+ // set position
+ if(options.setLeft) target.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px';
+ if(options.setTop) target.style.top = (p[1] - delta[1] + options.offsetTop) + 'px';
+ if(options.setWidth) target.style.width = source.offsetWidth + 'px';
+ if(options.setHeight) target.style.height = source.offsetHeight + 'px';
+ },
+
+ absolutize: function(element) {
+ element = $(element);
+ if (element.style.position == 'absolute') return;
+ Position.prepare();
+
+ var offsets = Position.positionedOffset(element);
+ var top = offsets[1];
+ var left = offsets[0];
+ var width = element.clientWidth;
+ var height = element.clientHeight;
+
+ element._originalLeft = left - parseFloat(element.style.left || 0);
+ element._originalTop = top - parseFloat(element.style.top || 0);
+ element._originalWidth = element.style.width;
+ element._originalHeight = element.style.height;
+
+ element.style.position = 'absolute';
+ element.style.top = top + 'px';;
+ element.style.left = left + 'px';;
+ element.style.width = width + 'px';;
+ element.style.height = height + 'px';;
+ },
+
+ relativize: function(element) {
+ element = $(element);
+ if (element.style.position == 'relative') return;
+ Position.prepare();
+
+ element.style.position = 'relative';
+ var top = parseFloat(element.style.top || 0) - (element._originalTop || 0);
+ var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);
+
+ element.style.top = top + 'px';
+ element.style.left = left + 'px';
+ element.style.height = element._originalHeight;
+ element.style.width = element._originalWidth;
+ }
+}
+
+// Safari returns margins on body which is incorrect if the child is absolutely
+// positioned. For performance reasons, redefine Position.cumulativeOffset for
+// KHTML/WebKit only.
+if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) {
+ Position.cumulativeOffset = function(element) {
+ var valueT = 0, valueL = 0;
+ do {
+ valueT += element.offsetTop || 0;
+ valueL += element.offsetLeft || 0;
+ if (element.offsetParent == document.body)
+ if (Element.getStyle(element, 'position') == 'absolute') break;
+
+ element = element.offsetParent;
+ } while (element);
+
+ return [valueL, valueT];
+ }
+}
+
+Element.addMethods();
\ No newline at end of file
--- /dev/null
+// Copyright (c) 2005 Thomas Fakes (http://craz8.com)
+//
+// This code is substantially based on code from script.aculo.us which has the
+// following copyright and permission notice
+//
+// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var Resizeable = Class.create();
+Resizeable.prototype = {
+ initialize: function(element) {
+ var options = Object.extend({
+ top: 6,
+ bottom: 6,
+ left: 6,
+ right: 6,
+ minHeight: 0,
+ minWidth: 0,
+ zindex: 1000,
+ resize: null
+ }, arguments[1] || {});
+
+ this.element = $(element);
+ this.handle = this.element;
+
+ Element.makePositioned(this.element); // fix IE
+
+ this.options = options;
+
+ this.active = false;
+ this.resizing = false;
+ this.currentDirection = '';
+
+ this.eventMouseDown = this.startResize.bindAsEventListener(this);
+ this.eventMouseUp = this.endResize.bindAsEventListener(this);
+ this.eventMouseMove = this.update.bindAsEventListener(this);
+ this.eventCursorCheck = this.cursor.bindAsEventListener(this);
+ this.eventKeypress = this.keyPress.bindAsEventListener(this);
+
+ this.registerEvents();
+ },
+ destroy: function() {
+ Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
+ this.unregisterEvents();
+ },
+ registerEvents: function() {
+ Event.observe(document, "mouseup", this.eventMouseUp);
+ Event.observe(document, "mousemove", this.eventMouseMove);
+ Event.observe(document, "keypress", this.eventKeypress);
+ Event.observe(this.handle, "mousedown", this.eventMouseDown);
+ Event.observe(this.element, "mousemove", this.eventCursorCheck);
+ },
+ unregisterEvents: function() {
+ //if(!this.active) return;
+ //Event.stopObserving(document, "mouseup", this.eventMouseUp);
+ //Event.stopObserving(document, "mousemove", this.eventMouseMove);
+ //Event.stopObserving(document, "mousemove", this.eventCursorCheck);
+ //Event.stopObserving(document, "keypress", this.eventKeypress);
+ },
+ startResize: function(event) {
+ if(Event.isLeftClick(event)) {
+
+ // abort on form elements, fixes a Firefox issue
+ var src = Event.element(event);
+ if(src.tagName && (
+ src.tagName=='INPUT' ||
+ src.tagName=='SELECT' ||
+ src.tagName=='BUTTON' ||
+ src.tagName=='TEXTAREA')) return;
+
+ var dir = this.directions(event);
+ if (dir.length > 0) {
+ this.active = true;
+ var offsets = Position.cumulativeOffset(this.element);
+ this.startTop = offsets[1];
+ this.startLeft = offsets[0];
+ this.startWidth = parseInt(Element.getStyle(this.element, 'width'));
+ this.startHeight = parseInt(Element.getStyle(this.element, 'height'));
+ this.startX = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
+ this.startY = event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
+
+ this.currentDirection = dir;
+ Event.stop(event);
+ }
+ }
+ },
+ finishResize: function(event, success) {
+ // this.unregisterEvents();
+
+ this.active = false;
+ this.resizing = false;
+
+ if(this.options.zindex)
+ this.element.style.zIndex = this.originalZ;
+
+ if (this.options.resize) {
+ this.options.resize(this.element);
+ }
+ },
+ keyPress: function(event) {
+ if(this.active) {
+ if(event.keyCode==Event.KEY_ESC) {
+ this.finishResize(event, false);
+ Event.stop(event);
+ }
+ }
+ },
+ endResize: function(event) {
+ if(this.active && this.resizing) {
+ this.finishResize(event, true);
+ Event.stop(event);
+ }
+ this.active = false;
+ this.resizing = false;
+ },
+ draw: function(event) {
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var style = this.element.style;
+ if (this.currentDirection.indexOf('n') != -1) {
+ var pointerMoved = this.startY - pointer[1];
+ var margin = Element.getStyle(this.element, 'margin-top') || "0";
+ var newHeight = this.startHeight + pointerMoved;
+ if (newHeight > this.options.minHeight) {
+ style.height = newHeight + "px";
+ style.top = (this.startTop - pointerMoved - parseInt(margin)) + "px";
+ }
+ }
+ if (this.currentDirection.indexOf('w') != -1) {
+ var pointerMoved = this.startX - pointer[0];
+ var margin = Element.getStyle(this.element, 'margin-left') || "0";
+ var newWidth = this.startWidth + pointerMoved;
+ if (newWidth > this.options.minWidth) {
+ style.left = (this.startLeft - pointerMoved - parseInt(margin)) + "px";
+ style.width = newWidth + "px";
+ }
+ }
+ if (this.currentDirection.indexOf('s') != -1) {
+ var newHeight = this.startHeight + pointer[1] - this.startY;
+ if (newHeight > this.options.minHeight) {
+ style.height = newHeight + "px";
+ }
+ }
+ if (this.currentDirection.indexOf('e') != -1) {
+ var newWidth = this.startWidth + pointer[0] - this.startX;
+ if (newWidth > this.options.minWidth) {
+ style.width = newWidth + "px";
+ }
+ }
+ if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
+ },
+ between: function(val, low, high) {
+ return (val >= low && val < high);
+ },
+ directions: function(event) {
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var offsets = Position.cumulativeOffset(this.element);
+
+ var cursor = '';
+ if (this.between(pointer[1] - offsets[1], 0, this.options.top)) cursor += 'n';
+ if (this.between((offsets[1] + this.element.offsetHeight) - pointer[1], 0, this.options.bottom)) cursor += 's';
+ if (this.between(pointer[0] - offsets[0], 0, this.options.left)) cursor += 'w';
+ if (this.between((offsets[0] + this.element.offsetWidth) - pointer[0], 0, this.options.right)) cursor += 'e';
+
+ return cursor;
+ },
+ cursor: function(event) {
+ var cursor = this.directions(event);
+ if (cursor.length > 0) {
+ cursor += '-resize';
+ } else {
+ cursor = '';
+ }
+ this.element.style.cursor = cursor;
+ },
+ update: function(event) {
+ if(this.active) {
+ if(!this.resizing) {
+ var style = this.element.style;
+ this.resizing = true;
+
+ if(Element.getStyle(this.element,'position')=='')
+ style.position = "relative";
+
+ if(this.options.zindex) {
+ this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
+ style.zIndex = this.options.zindex;
+ }
+ }
+ this.draw(event);
+
+ // fix AppleWebKit rendering
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
+ Event.stop(event);
+ return false;
+ }
+ }
+}
--- /dev/null
+// script.aculo.us scriptaculous.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006
+
+// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var Scriptaculous = {
+ Version: '1.6.4',
+ require: function(libraryName) {
+ // inserting via DOM fails in Safari 2.0, so brute force approach
+ document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
+ },
+ load: function() {
+ if((typeof Prototype=='undefined') ||
+ (typeof Element == 'undefined') ||
+ (typeof Element.Methods=='undefined') ||
+ parseFloat(Prototype.Version.split(".")[0] + "." +
+ Prototype.Version.split(".")[1]) < 1.5)
+ throw("script.aculo.us requires the Prototype JavaScript framework >= 1.5.0");
+
+ $A(document.getElementsByTagName("script")).findAll( function(s) {
+ return (s.src && s.src.match(/scriptaculous\.js(\?.*)?$/))
+ }).each( function(s) {
+ var path = s.src.replace(/scriptaculous\.js(\?.*)?$/,'');
+ var includes = s.src.match(/\?.*load=([a-z,]*)/);
+ (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider').split(',').each(
+ function(include) { Scriptaculous.require(path+include+'.js') });
+ });
+ }
+}
+
+Scriptaculous.load();
\ No newline at end of file
--- /dev/null
+// script.aculo.us slider.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006
+
+// Copyright (c) 2005 Marty Haught, Thomas Fuchs
+//
+// See http://script.aculo.us for more info
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+if(!Control) var Control = {};
+Control.Slider = Class.create();
+
+// options:
+// axis: 'vertical', or 'horizontal' (default)
+//
+// callbacks:
+// onChange(value)
+// onSlide(value)
+Control.Slider.prototype = {
+ initialize: function(handle, track, options) {
+ var slider = this;
+
+ if(handle instanceof Array) {
+ this.handles = handle.collect( function(e) { return $(e) });
+ } else {
+ this.handles = [$(handle)];
+ }
+
+ this.track = $(track);
+ this.options = options || {};
+
+ this.axis = this.options.axis || 'horizontal';
+ this.increment = this.options.increment || 1;
+ this.step = parseInt(this.options.step || '1');
+ this.range = this.options.range || $R(0,1);
+
+ this.value = 0; // assure backwards compat
+ this.values = this.handles.map( function() { return 0 });
+ this.spans = this.options.spans ? this.options.spans.map(function(s){ return $(s) }) : false;
+ this.options.startSpan = $(this.options.startSpan || null);
+ this.options.endSpan = $(this.options.endSpan || null);
+
+ this.restricted = this.options.restricted || false;
+
+ this.maximum = this.options.maximum || this.range.end;
+ this.minimum = this.options.minimum || this.range.start;
+
+ // Will be used to align the handle onto the track, if necessary
+ this.alignX = parseInt(this.options.alignX || '0');
+ this.alignY = parseInt(this.options.alignY || '0');
+
+ this.trackLength = this.maximumOffset() - this.minimumOffset();
+
+ this.handleLength = this.isVertical() ?
+ (this.handles[0].offsetHeight != 0 ?
+ this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/,"")) :
+ (this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth :
+ this.handles[0].style.width.replace(/px$/,""));
+
+ this.active = false;
+ this.dragging = false;
+ this.disabled = false;
+
+ if(this.options.disabled) this.setDisabled();
+
+ // Allowed values array
+ this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
+ if(this.allowedValues) {
+ this.minimum = this.allowedValues.min();
+ this.maximum = this.allowedValues.max();
+ }
+
+ this.eventMouseDown = this.startDrag.bindAsEventListener(this);
+ this.eventMouseUp = this.endDrag.bindAsEventListener(this);
+ this.eventMouseMove = this.update.bindAsEventListener(this);
+
+ // Initialize handles in reverse (make sure first handle is active)
+ this.handles.each( function(h,i) {
+ i = slider.handles.length-1-i;
+ slider.setValue(parseFloat(
+ (slider.options.sliderValue instanceof Array ?
+ slider.options.sliderValue[i] : slider.options.sliderValue) ||
+ slider.range.start), i);
+ Element.makePositioned(h); // fix IE
+ Event.observe(h, "mousedown", slider.eventMouseDown);
+ });
+
+ Event.observe(this.track, "mousedown", this.eventMouseDown);
+ Event.observe(document, "mouseup", this.eventMouseUp);
+ Event.observe(document, "mousemove", this.eventMouseMove);
+
+ this.initialized = true;
+ },
+ dispose: function() {
+ var slider = this;
+ Event.stopObserving(this.track, "mousedown", this.eventMouseDown);
+ Event.stopObserving(document, "mouseup", this.eventMouseUp);
+ Event.stopObserving(document, "mousemove", this.eventMouseMove);
+ this.handles.each( function(h) {
+ Event.stopObserving(h, "mousedown", slider.eventMouseDown);
+ });
+ },
+ setDisabled: function(){
+ this.disabled = true;
+ },
+ setEnabled: function(){
+ this.disabled = false;
+ },
+ getNearestValue: function(value){
+ if(this.allowedValues){
+ if(value >= this.allowedValues.max()) return(this.allowedValues.max());
+ if(value <= this.allowedValues.min()) return(this.allowedValues.min());
+
+ var offset = Math.abs(this.allowedValues[0] - value);
+ var newValue = this.allowedValues[0];
+ this.allowedValues.each( function(v) {
+ var currentOffset = Math.abs(v - value);
+ if(currentOffset <= offset){
+ newValue = v;
+ offset = currentOffset;
+ }
+ });
+ return newValue;
+ }
+ if(value > this.range.end) return this.range.end;
+ if(value < this.range.start) return this.range.start;
+ return value;
+ },
+ setValue: function(sliderValue, handleIdx){
+ if(!this.active) {
+ this.activeHandleIdx = handleIdx || 0;
+ this.activeHandle = this.handles[this.activeHandleIdx];
+ this.updateStyles();
+ }
+ handleIdx = handleIdx || this.activeHandleIdx || 0;
+ if(this.initialized && this.restricted) {
+ if((handleIdx>0) && (sliderValue<this.values[handleIdx-1]))
+ sliderValue = this.values[handleIdx-1];
+ if((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1]))
+ sliderValue = this.values[handleIdx+1];
+ }
+ sliderValue = this.getNearestValue(sliderValue);
+ this.values[handleIdx] = sliderValue;
+ this.value = this.values[0]; // assure backwards compat
+
+ this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =
+ this.translateToPx(sliderValue);
+
+ this.drawSpans();
+ if(!this.dragging || !this.event) this.updateFinished();
+ },
+ setValueBy: function(delta, handleIdx) {
+ this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,
+ handleIdx || this.activeHandleIdx || 0);
+ },
+ translateToPx: function(value) {
+ return Math.round(
+ ((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) *
+ (value - this.range.start)) + "px";
+ },
+ translateToValue: function(offset) {
+ return ((offset/(this.trackLength-this.handleLength) *
+ (this.range.end-this.range.start)) + this.range.start);
+ },
+ getRange: function(range) {
+ var v = this.values.sortBy(Prototype.K);
+ range = range || 0;
+ return $R(v[range],v[range+1]);
+ },
+ minimumOffset: function(){
+ return(this.isVertical() ? this.alignY : this.alignX);
+ },
+ maximumOffset: function(){
+ return(this.isVertical() ?
+ (this.track.offsetHeight != 0 ? this.track.offsetHeight :
+ this.track.style.height.replace(/px$/,"")) - this.alignY :
+ (this.track.offsetWidth != 0 ? this.track.offsetWidth :
+ this.track.style.width.replace(/px$/,"")) - this.alignY);
+ },
+ isVertical: function(){
+ return (this.axis == 'vertical');
+ },
+ drawSpans: function() {
+ var slider = this;
+ if(this.spans)
+ $R(0, this.spans.length-1).each(function(r) { slider.setSpan(slider.spans[r], slider.getRange(r)) });
+ if(this.options.startSpan)
+ this.setSpan(this.options.startSpan,
+ $R(0, this.values.length>1 ? this.getRange(0).min() : this.value ));
+ if(this.options.endSpan)
+ this.setSpan(this.options.endSpan,
+ $R(this.values.length>1 ? this.getRange(this.spans.length-1).max() : this.value, this.maximum));
+ },
+ setSpan: function(span, range) {
+ if(this.isVertical()) {
+ span.style.top = this.translateToPx(range.start);
+ span.style.height = this.translateToPx(range.end - range.start + this.range.start);
+ } else {
+ span.style.left = this.translateToPx(range.start);
+ span.style.width = this.translateToPx(range.end - range.start + this.range.start);
+ }
+ },
+ updateStyles: function() {
+ this.handles.each( function(h){ Element.removeClassName(h, 'selected') });
+ Element.addClassName(this.activeHandle, 'selected');
+ },
+ startDrag: function(event) {
+ if(Event.isLeftClick(event)) {
+ if(!this.disabled){
+ this.active = true;
+
+ var handle = Event.element(event);
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var track = handle;
+ if(track==this.track) {
+ var offsets = Position.cumulativeOffset(this.track);
+ this.event = event;
+ this.setValue(this.translateToValue(
+ (this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2)
+ ));
+ var offsets = Position.cumulativeOffset(this.activeHandle);
+ this.offsetX = (pointer[0] - offsets[0]);
+ this.offsetY = (pointer[1] - offsets[1]);
+ } else {
+ // find the handle (prevents issues with Safari)
+ while((this.handles.indexOf(handle) == -1) && handle.parentNode)
+ handle = handle.parentNode;
+
+ this.activeHandle = handle;
+ this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
+ this.updateStyles();
+
+ var offsets = Position.cumulativeOffset(this.activeHandle);
+ this.offsetX = (pointer[0] - offsets[0]);
+ this.offsetY = (pointer[1] - offsets[1]);
+ }
+ }
+ Event.stop(event);
+ }
+ },
+ update: function(event) {
+ if(this.active) {
+ if(!this.dragging) this.dragging = true;
+ this.draw(event);
+ // fix AppleWebKit rendering
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
+ Event.stop(event);
+ }
+ },
+ draw: function(event) {
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var offsets = Position.cumulativeOffset(this.track);
+ pointer[0] -= this.offsetX + offsets[0];
+ pointer[1] -= this.offsetY + offsets[1];
+ this.event = event;
+ this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));
+ if(this.initialized && this.options.onSlide)
+ this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
+ },
+ endDrag: function(event) {
+ if(this.active && this.dragging) {
+ this.finishDrag(event, true);
+ Event.stop(event);
+ }
+ this.active = false;
+ this.dragging = false;
+ },
+ finishDrag: function(event, success) {
+ this.active = false;
+ this.dragging = false;
+ this.updateFinished();
+ },
+ updateFinished: function() {
+ if(this.initialized && this.options.onChange)
+ this.options.onChange(this.values.length>1 ? this.values : this.value, this);
+ this.event = null;
+ }
+}
\ No newline at end of file
--- /dev/null
+// Copyright (c) 2006 spinelz.org (http://script.spinelz.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+/**
+ * Element class
+ */
+Object.extend(Element, {
+
+ getTagNodes: function(element, tree) {
+ return this.getElementsByNodeType(element, 1, tree);
+ },
+
+ getTextNodes: function(element, tree) {
+ return this.getElementsByNodeType(element, 3, tree);
+ },
+
+ getElementsByNodeType: function(element, nodeType, tree) {
+
+ element = ($(element) || document.body);
+ var nodes = element.childNodes;
+ var result = [];
+
+ for (var i = 0; i < nodes.length; i++) {
+ if (nodes[i].nodeType == nodeType)
+ result.push(nodes[i]);
+ if (tree && (nodes[i].nodeType == 1))
+ result = result.concat(this.getElementsByNodeType(nodes[i], nodeType, tree));
+ }
+
+ return result;
+ },
+
+ getParentByClassName: function(className, element) {
+ var parent = element.parentNode;
+ if (!parent || (parent.tagName == 'BODY'))
+ return null;
+ else if (!parent.className)
+ return Element.getParentByClassName(className, parent);
+ else if (Element.hasClassName(parent, className))
+ return parent;
+ else
+ return Element.getParentByClassName(className, parent);
+ },
+
+ getParentByTagName: function(tagNames, element) {
+
+ var parent = element.parentNode;
+ if (parent.tagName == 'BODY')
+ return null;
+
+ var index = tagNames.join('/').toUpperCase().indexOf(parent.tagName.toUpperCase(), 0);
+ if (index >= 0)
+ return parent;
+ else
+ return Element.getParentByTagName(tagNames, parent);
+ },
+
+ getFirstElementByClassNames: function(element, classNames, tree) {
+
+ if (!element ||
+ !((typeof(classNames) == 'object') && (classNames.constructor == Array))) {
+ return;
+ }
+
+ element = (element || document.body);
+ var nodes = element.childNodes;
+
+ for (var i = 0; i < nodes.length; i++) {
+ for (var j = 0; j < classNames.length; j++) {
+ if (nodes[i].nodeType != 1) {
+ continue;
+
+ } else if (Element.hasClassName(nodes[i], classNames[j])) {
+ return nodes[i];
+
+ } else if (tree) {
+ var result = this.getFirstElementByClassNames(nodes[i], classNames, tree);
+ if (result) return result;
+ }
+ }
+ }
+
+ return;
+ },
+
+ getElementsByClassNames: function(element, classNames) {
+
+ if (!element ||
+ !((typeof(classNames) == 'object') && (classNames.constructor == Array))) {
+ return;
+ }
+
+ var nodes = [];
+ classNames.each(function(c) {
+ nodes = nodes.concat(document.getElementsByClassName(c, element));
+ });
+
+ return nodes;
+ },
+
+ getWindowHeight: function() {
+
+ if (window.innerHeight) {
+ return window.innerHeight; // Mozilla, Opera, NN4
+ } else if (document.documentElement && document.documentElement.offsetHeight){ // ?? IE
+ return document.documentElement.offsetHeight;
+ } else if (document.body && document.body.offsetHeight) {
+ return document.body.offsetHeight - 20;
+ }
+ return 0;
+ },
+
+ getWindowWidth:function() {
+
+ if(window.innerWidth) {
+ return window.innerWidth; // Mozilla, Opera, NN4
+ } else if (document.documentElement && document.documentElement.offsetWidth){ // ?? IE
+ return document.documentElement.offsetWidth - 20;
+ } else if (document.body && document.body.offsetWidth){
+ return document.body.offsetWidth - 20;
+ }
+ return 0;
+ },
+
+ getMaxZindex: function(element) {
+ element = $(element);
+ if (!element) {
+ element = document.body;
+ }
+ if (element.nodeType != 1) return 0;
+
+ var maxZindex = 0;
+ if (element.style) maxZindex = parseInt(Element.getStyle(element, "z-index"));
+ if (isNaN(maxZindex)) maxZindex = 0;
+
+ var tmpZindex = 0;
+ var elements = element.childNodes;
+ for (var i = 0; i < elements.length; i++) {
+ if (elements[i] && elements[i].tagName) {
+ tmpZindex = Element.getMaxZindex(elements[i]);
+ if (maxZindex < tmpZindex) maxZindex = tmpZindex;
+ }
+ }
+
+ return maxZindex;
+ },
+
+ select: function(element, value) {
+ $A($(element).options).each(function(opt) {
+ if (opt.value == value) {
+ opt.selected = true;
+ } else {
+ opt.selected = false;
+ }
+ });
+ }
+});
+
+
+/**
+ * Array
+ */
+Object.extend(Array.prototype, {
+ insert : function(index, element) {
+ this.splice(index, 0 , element);
+ },
+
+ remove : function(index) {
+ this.splice(index, 1);
+ }
+});
+
+
+/**
+ * String
+ */
+Object.extend(String.prototype, {
+
+ getPrefix: function(delimiter) {
+
+ if (!delimiter) delimiter = '_';
+ return this.split(delimiter)[0];
+ },
+
+ getSuffix: function(delimiter) {
+
+ if (!delimiter) delimiter = '_';
+ return this.split(delimiter).pop();
+ },
+
+ appendPrefix: function(prefix, delimiter) {
+
+ if (!delimiter) delimiter = '_';
+ return this + delimiter + prefix;
+ },
+
+ appendSuffix: function(suffix, delimiter) {
+
+ if (!delimiter) delimiter = '_';
+ return this + delimiter + suffix;
+ },
+
+ // for firefox
+ println: function() {
+ dump(this + '\n');
+ }
+});
+
+
+/**
+ * CssUtil
+ */
+var CssUtil = Class.create();
+
+CssUtil.appendPrefix = function(prefix, suffixes) {
+ var newHash = {};
+ $H(suffixes).each(function(pair) {
+ newHash[pair[0]] = prefix + suffixes[pair[0]];
+ });
+ return newHash;
+}
+
+CssUtil.getCssRules = function(sheet) {
+ return sheet.rules || sheet.cssRules;
+}
+
+CssUtil.getCssRuleBySelectorText = function(selector) {
+ var rule = null;
+ $A(document.styleSheets).each(function(s) {
+ var rules = CssUtil.getCssRules(s);
+ rule = $A(rules).detect(function(r) {
+ if (!r.selectorText) return false;
+ return r.selectorText.toLowerCase() == selector.toLowerCase();
+ });
+ if (rule) throw $break;
+ });
+ return rule;
+}
+
+/*
+CssUtil.require = function(file, attributes, parent) {
+ var links = document.getElementsByTagName('link');
+ var regex = /^.*\.css/;
+ var match = file.match(regex)
+ alert(file)
+ regex.compile(match);
+
+ $A(links).each(function(ln) {
+ if (ln.href.match(regex)) {
+ }
+ });
+
+// attributes = Object.extend({
+// href: file,
+// media: 'screen',
+// rel: 'stylesheet',
+// type: 'text/css'}, attributes);
+// var node = Builder.node('link', attributes);
+// if (!parent) parent = document.body;
+// parent.appendChild(node);
+// alert(file);
+}
+*/
+
+CssUtil.prototype = {
+
+ initialize: function(styles) {
+ if (!((typeof(styles) == 'object') && (styles.constructor == Array))) {
+ throw 'CssUtil#initialize: argument must be a Array object!';
+ }
+
+ this.styles = styles;
+ },
+
+ getClasses: function(key) {
+ return this.styles.collect(function(s) {
+ return s[key];
+ });
+ },
+
+ joinClassNames: function(key) {
+ return this.getClasses(key).join(' ');
+ },
+
+ addClassNames: function(element, key) {
+ this.styles.each(function(s) {
+ Element.addClassName(element, s[key]);
+ });
+ },
+
+ removeClassNames: function(element, key) {
+ this.styles.each(function(s) {
+ Element.removeClassName(element, s[key]);
+ });
+ },
+
+ refreshClassNames: function(element, key) {
+ element.className = '';
+ this.addClassNames(element, key);
+ },
+
+ hasClassName: function(element, key) {
+ return this.styles.any(function(s) {
+ return Element.hasClassName(element, s[key]);
+ });
+ }
+}
+
+
+/**
+ * Hover
+ */
+var Hover = Class.create();
+Hover.prototype = {
+
+ initialize: function(element) {
+ this.options = Object.extend({
+ defaultClass: '',
+ hoverClass: '',
+ cssUtil: '',
+ list: false
+ }, arguments[1] || {});
+
+ var element = $(element);
+ if (this.options.list) {
+ var nodes = element.childNodes;
+ for (var i = 0; i < nodes.length; i++) {
+ if (nodes[i].nodeType == 1) {
+ this.build(nodes[i]);
+ }
+ }
+ } else {
+ this.build(element);
+ }
+ },
+
+ build: function(element) {
+ this.normal = this.getNormalClass(element);
+ this.hover = this.getHoverClass(this.normal);
+
+ if (this.options.cssUtil) {
+ this.normal = this.options.cssUtil.joinClassNames(normal);
+ this.hover = this.options.cssUtil.joinClassNames(hover);
+ }
+ this.setHoverEvent(element);
+ },
+
+ setHoverEvent: function(element) {
+ Event.observe(element, "mouseout", this.toggle.bindAsEventListener(this, element, this.normal));
+ Event.observe(element, "mouseover", this.toggle.bindAsEventListener(this, element, this.hover));
+ },
+
+ toggle: function(event, element, className) {
+ Event.stop(event);
+ element.className = className;
+ },
+
+ getNormalClass: function(element) {
+ var className = (this.options.defaultClass || element.className);
+ return (className || '');
+ },
+
+ getHoverClass: function(defaultClass) {
+ var className = this.options.hoverClass;
+ if (!className) {
+ className = defaultClass.split(' ').collect(function(c) {
+ return c + 'Hover';
+ }).join(' ');
+ }
+ return className;
+ }
+}
+
+
+/**
+ * Date
+ */
+Object.extend(Date.prototype, {
+ msPerDay: function() {
+ return 24 * 60 * 60 * 1000;
+ },
+
+ advance: function(options) {
+ return new Date(this.getTime() + this.msPerDay() * options.days);
+ },
+
+ days: function() {
+ var date = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
+ return Math.round(date.getTime() / this.msPerDay());
+ },
+
+ toHash: function() {
+ return {
+ year: this.getFullYear(),
+ month: this.getMonth(),
+ day: this.getDate(),
+ hour: this.getHours(),
+ min: this.getMinutes(),
+ sec: this.getSeconds()
+ }
+ },
+
+ sameYear: function(date) {
+ return this.getFullYear() == date.getFullYear();
+ },
+
+ sameMonth: function(date) {
+ return this.sameYear(date) && this.getMonth() == date.getMonth();
+ },
+
+ sameDate: function(date) {
+ return this.sameYear(date) && this.sameMonth(date) && this.getDate() == date.getDate();
+ },
+
+ betweenDate: function(start, finish) {
+ var myDays = this.days();
+ return (start.days() <= myDays && myDays <= finish.days());
+ },
+
+ betweenTime: function(start, finish) {
+ var myTime = this.getTime();
+ return (start.getTime() <= myTime && myTime <= finish.getTime());
+ }
+});
+
+
+/**
+ * DateUtil
+ */
+var DateUtil = {
+
+ dayOfWeek: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
+
+ months: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
+
+ daysOfMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
+
+ numberOfDays: function(start, finish) {
+ return finish.days() - start.days();
+ },
+
+ isLeapYear: function(year) {
+ if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
+ return true;
+ return false;
+ },
+
+ nextDate: function(date) {
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1);
+ },
+
+ previousDate: function(date) {
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - 1);
+ },
+
+ afterDays: function(date, after) {
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + after);
+ },
+
+ getLastDate: function(year, month) {
+ var last = this.daysOfMonth[month];
+ if ((month == 1) && this.isLeapYear(year)) {
+ return new Date(year, month, last + 1);
+ }
+ return new Date(year, month, last);
+ },
+
+ getFirstDate: function(year, month) {
+ if (year.constructor == Date) {
+ return new Date(year.getFullYear(), year.getMonth(), 1);
+ }
+ return new Date(year, month, 1);
+ },
+
+ getWeekTurn: function(date, firstDWeek) {
+ var limit = 6 - firstDWeek + 1;
+ var turn = 0;
+ while (limit < date) {
+ date -= 7;
+ turn++;
+ }
+ return turn;
+ },
+
+ toDateString: function(date) {
+ return date.toDateString();
+ },
+
+ toLocaleDateString: function(date) {
+ return date.toLocaleDateString();
+ },
+
+ simpleFormat: function(formatStr) {
+ return function(date) {
+ var formated = formatStr.replace(/M+/g, DateUtil.zerofill((date.getMonth() + 1).toString(), 2));
+ formated = formated.replace(/d+/g, DateUtil.zerofill(date.getDate().toString(), 2));
+ formated = formated.replace(/y{4}/g, date.getFullYear());
+ formated = formated.replace(/y{1,3}/g, new String(date.getFullYear()).substr(2));
+ formated = formated.replace(/E+/g, DateUtil.dayOfWeek[date.getDay()]);
+
+ return formated;
+ }
+ },
+
+ zerofill: function(date,digit){
+ var result = date;
+ if(date.length < digit){
+ var tmp = digit - date.length;
+ for(i=0; i < tmp; i++){
+ result = "0" + result;
+ }
+ }
+ return result;
+ },
+
+ toDate: function(hash) {
+ return new Date(hash.year, hash.month, hash.day, hash.hour, hash.min, hash.sec || 0);
+ }
+}
+
+
+/**
+ * ZindexManager
+ */
+var ZindexManager = {
+ zIndex: 1000,
+
+ getIndex: function(zIndex) {
+ if (zIndex) {
+ if (isNaN(zIndex)) {
+ zIndex = Element.getMaxZindex() + 1;
+ } else if (ZindexManager.zIndex > zIndex) {
+ zIndex = ZindexManager.zIndex;
+ }
+ } else {
+ zIndex = ZindexManager.zIndex;
+ }
+ ZindexManager.zIndex = zIndex + 1;
+ return zIndex;
+ }
+}
+
+
+/**
+ * Modal
+ */
+var Modal = {
+ maskId: 'modalMask',
+ maskClass: 'modal_mask',
+ maskClassIE: 'modal_mask_ie',
+ element: null,
+ snaps: null,
+ listener: null,
+ resizeListener: null,
+ cover: null,
+ excepteds: null,
+
+ mask: function(excepted) {
+ var options = Object.extend({
+ cssPrefix: 'custom_',
+ zIndex: null
+ }, arguments[1] || {});
+
+ if (Modal.element) {
+ Modal._snap(excepted);
+ Modal._rebuildMask();
+ } else {
+ Modal.snaps = [];
+ Modal.excepteds = [];
+ Modal._buildMask(options.cssPrefix);
+ Modal.cover = new IECover(Modal.element, {transparent: true});
+ }
+ Modal._setZindex(excepted, options.zIndex);
+ Modal._setFullSize();
+ if (!Modal.hasExcepted(excepted)) Modal.excepteds.push(excepted);
+ },
+
+ unmask: function() {
+ if (Modal.element) {
+ if (Modal.snaps.length == 0) {
+ Element.hide(Modal.element);
+ Modal._removeEvent();
+ Modal.excepteds = [];
+ Element.remove(Modal.element);
+ Modal.element = null;
+ } else {
+ Element.setStyle(Modal.element, {zIndex: Modal.snaps.pop()});
+ Modal.excepteds.pop();
+ }
+ }
+ },
+
+ _addEvent: function() {
+ if (!Modal.listener) {
+ Modal.listener = Modal._handleEvent.bindAsEventListener();
+ Modal.resizeListener = Modal._onResize.bindAsEventListener();
+ }
+ Event.observe(document, "keypress", Modal.listener);
+ Event.observe(document, "keydown", Modal.listener);
+ Event.observe(document, "keyup", Modal.listener);
+ Event.observe(document, "focus", Modal.listener);
+ Event.observe(window, "resize", Modal.resizeListener);
+ },
+
+ _removeEvent: function() {
+ Event.stopObserving(document, "keypress", Modal.listener);
+ Event.stopObserving(document, "keydown", Modal.listener);
+ Event.stopObserving(document, "keyup", Modal.listener);
+ Event.stopObserving(document, "focus", Modal.listener);
+ Event.stopObserving(window, "resize", Modal.resizeListener);
+ },
+
+ _isMasked: function() {
+ return Modal.element && Element.visible(Modal.element);
+ },
+
+ _snap: function(excepted) {
+ var index = Element.getStyle(Modal.element, 'zIndex');
+ if (index && Modal._isMasked() && !Modal.hasExcepted(excepted)) Modal.snaps.push(index);
+ },
+
+ _setZindex: function(excepted, zIndex) {
+ zIndex = ZindexManager.getIndex(zIndex);
+ Element.setStyle(Modal.element, {zIndex: zIndex});
+ excepted = Element.makePositioned($(excepted));
+ Element.setStyle(excepted, {zIndex: ++zIndex});
+ },
+
+ _setFullSize: function() {
+ Modal.element.setStyle({
+ width: Element.getWindowWidth() + 'px',
+ height: Element.getWindowHeight() + 'px'
+ });
+ if (Modal.cover) Modal.cover.resetSize();
+ },
+
+ _buildMask: function(cssPrefix) {
+ var mask = Builder.node('div', {id: Modal.maskId});
+ Modal._setClassNames(mask, cssPrefix);
+ document.body.appendChild(mask);
+ Modal.element = mask;
+ Modal._addEvent();
+ },
+
+ _setClassNames: function(element, cssPrefix) {
+ var className = (UserAgent.isIE()) ? Modal.maskClassIE : Modal.maskClass;
+ Element.addClassName(element, className);
+ Element.addClassName(element, cssPrefix + className);
+ },
+
+ _rebuildMask: function() {
+ document.body.appendChild(Modal.element);
+ Element.show(Modal.element);
+ },
+
+ _isOutOfModal: function(src) {
+ var limit = Element.getStyle(Modal.element, 'zIndex');
+ var zIndex = null;
+ while ((src = src.parentNode) && src != document.body) {
+ if (src.style && (zIndex = Element.getStyle(src, 'zIndex'))) {
+ if (zIndex > limit) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+ return false;
+ },
+
+ _handleEvent: function (event) {
+ var src = Event.element(event);
+ if (!Modal._isOutOfModal(src)) {
+ Event.stop(event);
+ }
+ },
+
+ _onResize: function(event) {
+ Modal._setFullSize();
+ },
+
+ hasExcepted: function(excepted) {
+ return Modal.excepteds && Modal.excepteds.include(excepted);
+ }
+}
+
+
+/**
+ * IECover
+ */
+var IECover = Class.create();
+IECover.src = '/blank.html';
+IECover.prototype = {
+ idSuffix: 'iecover',
+
+ initialize: function(parent) {
+ this.options = Object.extend({
+ transparent : false,
+ padding : 0
+ }, arguments[1] || {});
+
+ if (document.all) {
+ parent = $(parent);
+ this.id = parent.id.appendSuffix(this.idSuffix);
+ this._build(parent);
+ this.resetSize();
+ }
+ },
+
+ resetSize: function() {
+ if (this.element) {
+ var parent = this.element.parentNode;
+ var padding = this.options.padding;
+ this.element.width = parent.offsetWidth - padding + 'px';
+ this.element.height = Element.getHeight(parent) - padding + 'px';
+ }
+ },
+
+ _build: function(parent) {
+ var padding = this.options.padding / 2;
+ var styles = {
+ position : 'absolute',
+ top : padding + 'px',
+ left : padding + 'px'
+ };
+ if (this.options.transparent) styles.filter = 'alpha(opacity=0)';
+ this.element = Builder.node('iframe', {src: IECover.src, id: this.id, frameborder: 0});
+ Element.setStyle(this.element, styles);
+ var firstNode = Element.down(parent, 0);
+ if (firstNode) Element.makePositioned(firstNode);
+ parent.insertBefore(this.element, parent.firstChild);
+ }
+}
+
+/**
+ * UserAgent
+ */
+var UserAgent = {
+ getUserAgent: function() {
+ return navigator.userAgent;
+ },
+ isIE: function() {
+ if(document.all && this.getUserAgent().toLowerCase().indexOf('msie') != -1) {
+ return true;
+ }
+ },
+ isIE7: function() {
+ if(document.all && this.getUserAgent().toLowerCase().indexOf('msie 7') != -1) {
+ return true;
+ }
+ }
+}
+
+/**
+ * ShortcutManager
+ */
+var ShortcutManager = {
+ initialize: function() {
+ var defaultOptions = {
+ initialStarted: true,
+ preventDefault: true
+ }
+ this.options = Object.extend(defaultOptions, arguments[0] || {});
+ if(this.documentListener) {
+ Event.stopObserving(document, 'keydown', this.documentListener);
+ }
+ this.documentListener = this.eventKeydown.bindAsEventListener(this);
+ this.functions = new Object();
+ this.functions['a'] = new Object();
+ this.functions['ac'] = new Object();
+ this.functions['as'] = new Object();
+ this.functions['acs'] = new Object();
+ this.functions['c'] = new Object();
+ this.functions['cs'] = new Object();
+ this.functions['n'] = new Object();
+ this.functions['s'] = new Object();
+ this.keyCode = {
+ 'backspace': 8,
+ 'tab': 9,
+ 'return': 13,
+ 'enter': 13,
+ 'pause': 19,
+ 'break': 19,
+ 'caps': 20,
+ 'capslock': 20,
+ 'esc': 27,
+ 'escape': 27,
+ 'space': 32,
+ 'pageup': 33,
+ 'pgup': 33,
+ 'pagedown': 34,
+ 'pgdn': 34,
+ 'end': 35,
+ 'home': 36,
+ 'left': 37,
+ 'up': 38,
+ 'right': 39,
+ 'down': 40,
+ 'insert': 45,
+ 'delete': 46,
+ '0': 48,
+ '1': 49,
+ '2': 50,
+ '3': 51,
+ '4': 52,
+ '5': 53,
+ '6': 54,
+ '7': 55,
+ '8': 56,
+ '9': 57,
+ 'a': 65,
+ 'b': 66,
+ 'c': 67,
+ 'd': 68,
+ 'e': 69,
+ 'f': 70,
+ 'g': 71,
+ 'h': 72,
+ 'i': 73,
+ 'j': 74,
+ 'k': 75,
+ 'l': 76,
+ 'm': 77,
+ 'n': 78,
+ 'o': 79,
+ 'p': 80,
+ 'q': 81,
+ 'r': 82,
+ 's': 83,
+ 't': 84,
+ 'u': 85,
+ 'v': 86,
+ 'w': 87,
+ 'x': 88,
+ 'y': 89,
+ 'z': 90,
+ 'f1': 112,
+ 'f2': 113,
+ 'f3': 114,
+ 'f4': 115,
+ 'f5': 116,
+ 'f6': 117,
+ 'f7': 118,
+ 'f8': 119,
+ 'f9': 120,
+ 'f10': 121,
+ 'f11': 122,
+ 'f12': 123,
+ 'numlock': 144,
+ 'nmlk': 144,
+ 'scrolllock': 145,
+ 'scflk': 145
+ };
+ this.numKeys = {
+ 96: 48,
+ 97: 49,
+ 98: 50,
+ 99: 51,
+ 100: 52,
+ 101: 53,
+ 102: 54,
+ 103: 55,
+ 104: 56,
+ 105: 57
+ };
+ if(this.options.initialStarted) {
+ this.start();
+ } else {
+ this.stop();
+ }
+ Event.observe(document, 'keydown', this.documentListener);
+ },
+ add: function(shortcut, callback) {
+ this._add_or_remove_function(shortcut, callback);
+ },
+ destroy: function() {
+ Event.stopObserving(document, 'keydown', this.documentListener);
+ },
+ eventKeydown: function(event) {
+ if(this.executable) {
+ var code;
+ var key = '';
+ event = event || window.event;
+ if(event.keyCode) {
+ if(event.altKey) {
+ key += 'a';
+ }
+ if(event.ctrlKey) {
+ key += 'c';
+ }
+ if(event.shiftKey) {
+ key += 's';
+ }
+ if(key == '') {
+ key = 'n';
+ }
+ code = this._mergeNumKey(event.keyCode);
+ if(this.functions[key][code]) {
+ this.functions[key][code]();
+ if(this.options.preventDefault) {
+ Event.stop(event);
+ }
+ }
+ }
+ }
+ },
+ remove: function(shortcut) {
+ this._add_or_remove_function(shortcut);
+ },
+ start: function() {
+ this.executable = true;
+ },
+ stop: function() {
+ this.executable = false;
+ },
+ _add_or_remove_function: function(shortcut, callback) {
+ var pressed_key_code;
+ var additional_keys = new Array();
+ var self = this;
+ $A(shortcut.toLowerCase().split("+")).each(
+ function(key) {
+ if(key == 'alt') {
+ additional_keys.push('a');
+ } else if(key == 'ctrl') {
+ additional_keys.push('c');
+ } else if(key == 'shift') {
+ additional_keys.push('s');
+ } else {
+ pressed_key_code = self.keyCode[key];
+ }
+ }
+ );
+ var key = additional_keys.sortBy(function(value, index) {return value;}).join('');
+ if(key == '') {
+ key = 'n';
+ }
+ if(callback) {
+ this.functions[key][pressed_key_code] = callback;
+ } else {
+ this.functions[key][pressed_key_code] = null;
+ }
+ },
+ _mergeNumKey: function(code) {
+ return (this.numKeys[code]) ? this.numKeys[code] : code;
+ }
+}
+
+
+/**
+ * Function
+ */
+Function.prototype.callAfterLoading = function(object) {
+ object = object || this;
+ if (UserAgent.isIE() && document.readyState != 'complete') {
+ Event.observe(window, 'load', this.bind(object));
+ } else {
+ this.call(object);
+ }
+}
--- /dev/null
+// script.aculo.us unittest.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006
+
+// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// (c) 2005 Jon Tirsen (http://www.tirsen.com)
+// (c) 2005 Michael Schuerig (http://www.schuerig.de/michael/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+// experimental, Firefox-only
+Event.simulateMouse = function(element, eventName) {
+ var options = Object.extend({
+ pointerX: 0,
+ pointerY: 0,
+ buttons: 0
+ }, arguments[2] || {});
+ var oEvent = document.createEvent("MouseEvents");
+ oEvent.initMouseEvent(eventName, true, true, document.defaultView,
+ options.buttons, options.pointerX, options.pointerY, options.pointerX, options.pointerY,
+ false, false, false, false, 0, $(element));
+
+ if(this.mark) Element.remove(this.mark);
+ this.mark = document.createElement('div');
+ this.mark.appendChild(document.createTextNode(" "));
+ document.body.appendChild(this.mark);
+ this.mark.style.position = 'absolute';
+ this.mark.style.top = options.pointerY + "px";
+ this.mark.style.left = options.pointerX + "px";
+ this.mark.style.width = "5px";
+ this.mark.style.height = "5px;";
+ this.mark.style.borderTop = "1px solid red;"
+ this.mark.style.borderLeft = "1px solid red;"
+
+ if(this.step)
+ alert('['+new Date().getTime().toString()+'] '+eventName+'/'+Test.Unit.inspect(options));
+
+ $(element).dispatchEvent(oEvent);
+};
+
+// Note: Due to a fix in Firefox 1.0.5/6 that probably fixed "too much", this doesn't work in 1.0.6 or DP2.
+// You need to downgrade to 1.0.4 for now to get this working
+// See https://bugzilla.mozilla.org/show_bug.cgi?id=289940 for the fix that fixed too much
+Event.simulateKey = function(element, eventName) {
+ var options = Object.extend({
+ ctrlKey: false,
+ altKey: false,
+ shiftKey: false,
+ metaKey: false,
+ keyCode: 0,
+ charCode: 0
+ }, arguments[2] || {});
+
+ var oEvent = document.createEvent("KeyEvents");
+ oEvent.initKeyEvent(eventName, true, true, window,
+ options.ctrlKey, options.altKey, options.shiftKey, options.metaKey,
+ options.keyCode, options.charCode );
+ $(element).dispatchEvent(oEvent);
+};
+
+Event.simulateKeys = function(element, command) {
+ for(var i=0; i<command.length; i++) {
+ Event.simulateKey(element,'keypress',{charCode:command.charCodeAt(i)});
+ }
+};
+
+var Test = {}
+Test.Unit = {};
+
+// security exception workaround
+Test.Unit.inspect = Object.inspect;
+
+Test.Unit.Logger = Class.create();
+Test.Unit.Logger.prototype = {
+ initialize: function(log) {
+ this.log = $(log);
+ if (this.log) {
+ this._createLogTable();
+ }
+ },
+ start: function(testName) {
+ if (!this.log) return;
+ this.testName = testName;
+ this.lastLogLine = document.createElement('tr');
+ this.statusCell = document.createElement('td');
+ this.nameCell = document.createElement('td');
+ this.nameCell.appendChild(document.createTextNode(testName));
+ this.messageCell = document.createElement('td');
+ this.lastLogLine.appendChild(this.statusCell);
+ this.lastLogLine.appendChild(this.nameCell);
+ this.lastLogLine.appendChild(this.messageCell);
+ this.loglines.appendChild(this.lastLogLine);
+ },
+ finish: function(status, summary) {
+ if (!this.log) return;
+ this.lastLogLine.className = status;
+ this.statusCell.innerHTML = status;
+ this.messageCell.innerHTML = this._toHTML(summary);
+ },
+ message: function(message) {
+ if (!this.log) return;
+ this.messageCell.innerHTML = this._toHTML(message);
+ },
+ summary: function(summary) {
+ if (!this.log) return;
+ this.logsummary.innerHTML = this._toHTML(summary);
+ },
+ _createLogTable: function() {
+ this.log.innerHTML =
+ '<div id="logsummary"></div>' +
+ '<table id="logtable">' +
+ '<thead><tr><th>Status</th><th>Test</th><th>Message</th></tr></thead>' +
+ '<tbody id="loglines"></tbody>' +
+ '</table>';
+ this.logsummary = $('logsummary')
+ this.loglines = $('loglines');
+ },
+ _toHTML: function(txt) {
+ return txt.escapeHTML().replace(/\n/g,"<br/>");
+ }
+}
+
+Test.Unit.Runner = Class.create();
+Test.Unit.Runner.prototype = {
+ initialize: function(testcases) {
+ this.options = Object.extend({
+ testLog: 'testlog'
+ }, arguments[1] || {});
+ this.options.resultsURL = this.parseResultsURLQueryParameter();
+ if (this.options.testLog) {
+ this.options.testLog = $(this.options.testLog) || null;
+ }
+ if(this.options.tests) {
+ this.tests = [];
+ for(var i = 0; i < this.options.tests.length; i++) {
+ if(/^test/.test(this.options.tests[i])) {
+ this.tests.push(new Test.Unit.Testcase(this.options.tests[i], testcases[this.options.tests[i]], testcases["setup"], testcases["teardown"]));
+ }
+ }
+ } else {
+ if (this.options.test) {
+ this.tests = [new Test.Unit.Testcase(this.options.test, testcases[this.options.test], testcases["setup"], testcases["teardown"])];
+ } else {
+ this.tests = [];
+ for(var testcase in testcases) {
+ if(/^test/.test(testcase)) {
+ this.tests.push(
+ new Test.Unit.Testcase(
+ this.options.context ? ' -> ' + this.options.titles[testcase] : testcase,
+ testcases[testcase], testcases["setup"], testcases["teardown"]
+ ));
+ }
+ }
+ }
+ }
+ this.currentTest = 0;
+ this.logger = new Test.Unit.Logger(this.options.testLog);
+ setTimeout(this.runTests.bind(this), 1000);
+ },
+ parseResultsURLQueryParameter: function() {
+ return window.location.search.parseQuery()["resultsURL"];
+ },
+ // Returns:
+ // "ERROR" if there was an error,
+ // "FAILURE" if there was a failure, or
+ // "SUCCESS" if there was neither
+ getResult: function() {
+ var hasFailure = false;
+ for(var i=0;i<this.tests.length;i++) {
+ if (this.tests[i].errors > 0) {
+ return "ERROR";
+ }
+ if (this.tests[i].failures > 0) {
+ hasFailure = true;
+ }
+ }
+ if (hasFailure) {
+ return "FAILURE";
+ } else {
+ return "SUCCESS";
+ }
+ },
+ postResults: function() {
+ if (this.options.resultsURL) {
+ new Ajax.Request(this.options.resultsURL,
+ { method: 'get', parameters: 'result=' + this.getResult(), asynchronous: false });
+ }
+ },
+ runTests: function() {
+ var test = this.tests[this.currentTest];
+ if (!test) {
+ // finished!
+ this.postResults();
+ this.logger.summary(this.summary());
+ return;
+ }
+ if(!test.isWaiting) {
+ this.logger.start(test.name);
+ }
+ test.run();
+ if(test.isWaiting) {
+ this.logger.message("Waiting for " + test.timeToWait + "ms");
+ setTimeout(this.runTests.bind(this), test.timeToWait || 1000);
+ } else {
+ this.logger.finish(test.status(), test.summary());
+ this.currentTest++;
+ // tail recursive, hopefully the browser will skip the stackframe
+ this.runTests();
+ }
+ },
+ summary: function() {
+ var assertions = 0;
+ var failures = 0;
+ var errors = 0;
+ var messages = [];
+ for(var i=0;i<this.tests.length;i++) {
+ assertions += this.tests[i].assertions;
+ failures += this.tests[i].failures;
+ errors += this.tests[i].errors;
+ }
+ return (
+ (this.options.context ? this.options.context + ': ': '') +
+ this.tests.length + " tests, " +
+ assertions + " assertions, " +
+ failures + " failures, " +
+ errors + " errors");
+ }
+}
+
+Test.Unit.Assertions = Class.create();
+Test.Unit.Assertions.prototype = {
+ initialize: function() {
+ this.assertions = 0;
+ this.failures = 0;
+ this.errors = 0;
+ this.messages = [];
+ },
+ summary: function() {
+ return (
+ this.assertions + " assertions, " +
+ this.failures + " failures, " +
+ this.errors + " errors" + "\n" +
+ this.messages.join("\n"));
+ },
+ pass: function() {
+ this.assertions++;
+ },
+ fail: function(message) {
+ this.failures++;
+ this.messages.push("Failure: " + message);
+ },
+ info: function(message) {
+ this.messages.push("Info: " + message);
+ },
+ error: function(error) {
+ this.errors++;
+ this.messages.push(error.name + ": "+ error.message + "(" + Test.Unit.inspect(error) +")");
+ },
+ status: function() {
+ if (this.failures > 0) return 'failed';
+ if (this.errors > 0) return 'error';
+ return 'passed';
+ },
+ assert: function(expression) {
+ var message = arguments[1] || 'assert: got "' + Test.Unit.inspect(expression) + '"';
+ try { expression ? this.pass() :
+ this.fail(message); }
+ catch(e) { this.error(e); }
+ },
+ assertEqual: function(expected, actual) {
+ var message = arguments[2] || "assertEqual";
+ try { (expected == actual) ? this.pass() :
+ this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
+ '", actual "' + Test.Unit.inspect(actual) + '"'); }
+ catch(e) { this.error(e); }
+ },
+ assertEnumEqual: function(expected, actual) {
+ var message = arguments[2] || "assertEnumEqual";
+ try { $A(expected).length == $A(actual).length &&
+ expected.zip(actual).all(function(pair) { return pair[0] == pair[1] }) ?
+ this.pass() : this.fail(message + ': expected ' + Test.Unit.inspect(expected) +
+ ', actual ' + Test.Unit.inspect(actual)); }
+ catch(e) { this.error(e); }
+ },
+ assertNotEqual: function(expected, actual) {
+ var message = arguments[2] || "assertNotEqual";
+ try { (expected != actual) ? this.pass() :
+ this.fail(message + ': got "' + Test.Unit.inspect(actual) + '"'); }
+ catch(e) { this.error(e); }
+ },
+ assertIdentical: function(expected, actual) {
+ var message = arguments[2] || "assertIdentical";
+ try { (expected === actual) ? this.pass() :
+ this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
+ '", actual "' + Test.Unit.inspect(actual) + '"'); }
+ catch(e) { this.error(e); }
+ },
+ assertNotIdentical: function(expected, actual) {
+ var message = arguments[2] || "assertNotIdentical";
+ try { !(expected === actual) ? this.pass() :
+ this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
+ '", actual "' + Test.Unit.inspect(actual) + '"'); }
+ catch(e) { this.error(e); }
+ },
+ assertNull: function(obj) {
+ var message = arguments[1] || 'assertNull'
+ try { (obj==null) ? this.pass() :
+ this.fail(message + ': got "' + Test.Unit.inspect(obj) + '"'); }
+ catch(e) { this.error(e); }
+ },
+ assertMatch: function(expected, actual) {
+ var message = arguments[2] || 'assertMatch';
+ var regex = new RegExp(expected);
+ try { (regex.exec(actual)) ? this.pass() :
+ this.fail(message + ' : regex: "' + Test.Unit.inspect(expected) + ' did not match: ' + Test.Unit.inspect(actual) + '"'); }
+ catch(e) { this.error(e); }
+ },
+ assertHidden: function(element) {
+ var message = arguments[1] || 'assertHidden';
+ this.assertEqual("none", element.style.display, message);
+ },
+ assertNotNull: function(object) {
+ var message = arguments[1] || 'assertNotNull';
+ this.assert(object != null, message);
+ },
+ assertType: function(expected, actual) {
+ var message = arguments[2] || 'assertType';
+ try {
+ (actual.constructor == expected) ? this.pass() :
+ this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
+ '", actual "' + (actual.constructor) + '"'); }
+ catch(e) { this.error(e); }
+ },
+ assertNotOfType: function(expected, actual) {
+ var message = arguments[2] || 'assertNotOfType';
+ try {
+ (actual.constructor != expected) ? this.pass() :
+ this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
+ '", actual "' + (actual.constructor) + '"'); }
+ catch(e) { this.error(e); }
+ },
+ assertInstanceOf: function(expected, actual) {
+ var message = arguments[2] || 'assertInstanceOf';
+ try {
+ (actual instanceof expected) ? this.pass() :
+ this.fail(message + ": object was not an instance of the expected type"); }
+ catch(e) { this.error(e); }
+ },
+ assertNotInstanceOf: function(expected, actual) {
+ var message = arguments[2] || 'assertNotInstanceOf';
+ try {
+ !(actual instanceof expected) ? this.pass() :
+ this.fail(message + ": object was an instance of the not expected type"); }
+ catch(e) { this.error(e); }
+ },
+ assertRespondsTo: function(method, obj) {
+ var message = arguments[2] || 'assertRespondsTo';
+ try {
+ (obj[method] && typeof obj[method] == 'function') ? this.pass() :
+ this.fail(message + ": object doesn't respond to [" + method + "]"); }
+ catch(e) { this.error(e); }
+ },
+ assertReturnsTrue: function(method, obj) {
+ var message = arguments[2] || 'assertReturnsTrue';
+ try {
+ var m = obj[method];
+ if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)];
+ m() ? this.pass() :
+ this.fail(message + ": method returned false"); }
+ catch(e) { this.error(e); }
+ },
+ assertReturnsFalse: function(method, obj) {
+ var message = arguments[2] || 'assertReturnsFalse';
+ try {
+ var m = obj[method];
+ if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)];
+ !m() ? this.pass() :
+ this.fail(message + ": method returned true"); }
+ catch(e) { this.error(e); }
+ },
+ assertRaise: function(exceptionName, method) {
+ var message = arguments[2] || 'assertRaise';
+ try {
+ method();
+ this.fail(message + ": exception expected but none was raised"); }
+ catch(e) {
+ (e.name==exceptionName) ? this.pass() : this.error(e);
+ }
+ },
+ assertElementsMatch: function() {
+ var expressions = $A(arguments), elements = $A(expressions.shift());
+ if (elements.length != expressions.length) {
+ this.fail('assertElementsMatch: size mismatch: ' + elements.length + ' elements, ' + expressions.length + ' expressions');
+ return false;
+ }
+ elements.zip(expressions).all(function(pair, index) {
+ var element = $(pair.first()), expression = pair.last();
+ if (element.match(expression)) return true;
+ this.fail('assertElementsMatch: (in index ' + index + ') expected ' + expression.inspect() + ' but got ' + element.inspect());
+ }.bind(this)) && this.pass();
+ },
+ assertElementMatches: function(element, expression) {
+ this.assertElementsMatch([element], expression);
+ },
+ benchmark: function(operation, iterations) {
+ var startAt = new Date();
+ (iterations || 1).times(operation);
+ var timeTaken = ((new Date())-startAt);
+ this.info((arguments[2] || 'Operation') + ' finished ' +
+ iterations + ' iterations in ' + (timeTaken/1000)+'s' );
+ return timeTaken;
+ },
+ _isVisible: function(element) {
+ element = $(element);
+ if(!element.parentNode) return true;
+ this.assertNotNull(element);
+ if(element.style && Element.getStyle(element, 'display') == 'none')
+ return false;
+
+ return this._isVisible(element.parentNode);
+ },
+ assertNotVisible: function(element) {
+ this.assert(!this._isVisible(element), Test.Unit.inspect(element) + " was not hidden and didn't have a hidden parent either. " + ("" || arguments[1]));
+ },
+ assertVisible: function(element) {
+ this.assert(this._isVisible(element), Test.Unit.inspect(element) + " was not visible. " + ("" || arguments[1]));
+ },
+ benchmark: function(operation, iterations) {
+ var startAt = new Date();
+ (iterations || 1).times(operation);
+ var timeTaken = ((new Date())-startAt);
+ this.info((arguments[2] || 'Operation') + ' finished ' +
+ iterations + ' iterations in ' + (timeTaken/1000)+'s' );
+ return timeTaken;
+ }
+}
+
+Test.Unit.Testcase = Class.create();
+Object.extend(Object.extend(Test.Unit.Testcase.prototype, Test.Unit.Assertions.prototype), {
+ initialize: function(name, test, setup, teardown) {
+ Test.Unit.Assertions.prototype.initialize.bind(this)();
+ this.name = name;
+
+ if(typeof test == 'string') {
+ test = test.gsub(/(\.should[^\(]+\()/,'#{0}this,');
+ test = test.gsub(/(\.should[^\(]+)\(this,\)/,'#{1}(this)');
+ this.test = function() {
+ eval('with(this){'+test+'}');
+ }
+ } else {
+ this.test = test || function() {};
+ }
+
+ this.setup = setup || function() {};
+ this.teardown = teardown || function() {};
+ this.isWaiting = false;
+ this.timeToWait = 1000;
+ },
+ wait: function(time, nextPart) {
+ this.isWaiting = true;
+ this.test = nextPart;
+ this.timeToWait = time;
+ },
+ run: function() {
+ try {
+ try {
+ if (!this.isWaiting) this.setup.bind(this)();
+ this.isWaiting = false;
+ this.test.bind(this)();
+ } finally {
+ if(!this.isWaiting) {
+ this.teardown.bind(this)();
+ }
+ }
+ }
+ catch(e) { this.error(e); }
+ }
+});
+
+// *EXPERIMENTAL* BDD-style testing to please non-technical folk
+// This draws many ideas from RSpec http://rspec.rubyforge.org/
+
+Test.setupBDDExtensionMethods = function(){
+ var METHODMAP = {
+ shouldEqual: 'assertEqual',
+ shouldNotEqual: 'assertNotEqual',
+ shouldEqualEnum: 'assertEnumEqual',
+ shouldBeA: 'assertType',
+ shouldNotBeA: 'assertNotOfType',
+ shouldBeAn: 'assertType',
+ shouldNotBeAn: 'assertNotOfType',
+ shouldBeNull: 'assertNull',
+ shouldNotBeNull: 'assertNotNull',
+
+ shouldBe: 'assertReturnsTrue',
+ shouldNotBe: 'assertReturnsFalse',
+ shouldRespondTo: 'assertRespondsTo'
+ };
+ Test.BDDMethods = {};
+ for(m in METHODMAP) {
+ Test.BDDMethods[m] = eval(
+ 'function(){'+
+ 'var args = $A(arguments);'+
+ 'var scope = args.shift();'+
+ 'scope.'+METHODMAP[m]+'.apply(scope,(args || []).concat([this])); }');
+ }
+ [Array.prototype, String.prototype, Number.prototype].each(
+ function(p){ Object.extend(p, Test.BDDMethods) }
+ );
+}
+
+Test.context = function(name, spec, log){
+ Test.setupBDDExtensionMethods();
+
+ var compiledSpec = {};
+ var titles = {};
+ for(specName in spec) {
+ switch(specName){
+ case "setup":
+ case "teardown":
+ compiledSpec[specName] = spec[specName];
+ break;
+ default:
+ var testName = 'test'+specName.gsub(/\s+/,'-').camelize();
+ var body = spec[specName].toString().split('\n').slice(1);
+ if(/^\{/.test(body[0])) body = body.slice(1);
+ body.pop();
+ body = body.map(function(statement){
+ return statement.strip()
+ });
+ compiledSpec[testName] = body.join('\n');
+ titles[testName] = specName;
+ }
+ }
+ new Test.Unit.Runner(compiledSpec, { titles: titles, testLog: log || 'testlog', context: name });
+};
\ No newline at end of file
--- /dev/null
+.accordion{
+ border-bottom: 1px solid #999999;
+}
+.accordion_panel{
+ border-left: 1px solid #999999;
+ border-right: 1px solid #999999;
+ overflow: auto;
+ visibility: visible;
+}
+
+.accordion_tab {
+ position: relative;
+ height: 26px;
+ cursor: pointer;
+}
+
+.accordion_tab div{
+ height: 26px;
+}
+
+.accordion_tabLeftInactive {
+ background: url('../../images/spinelz/accordion_tab_left_inactive.gif') no-repeat;
+ position: absolute;
+ left: 0;
+ width: 10px;
+}
+
+.accordion_tabLeftActive {
+ background: url('../../images/spinelz/accordion_tab_left_active.gif') no-repeat;
+ position: absolute;
+ left: 0;
+ width: 10px;
+}
+
+.accordion_tabMiddleInactive {
+ background: url('../../images/spinelz/accordion_tab_middle_inactive.gif') repeat-x;
+ margin: 0 10px;
+}
+
+.accordion_tabMiddleActive {
+ background: url('../../images/spinelz/accordion_tab_middle_active.gif') repeat-x;
+ margin: 0 10px;
+}
+
+.accordion_tabRightInactive {
+ background: url('../../images/spinelz/accordion_tab_right_inactive.gif') no-repeat;
+ position: absolute;
+ top: 0;
+ right: 0;
+ width: 10px;
+}
+
+.accordion_tabRightActive {
+ background: url('../../images/spinelz/accordion_tab_right_active.gif') no-repeat;
+ position: absolute;
+ top: 0;
+ right: 0;
+ width: 10px;
+}
--- /dev/null
+div.balloon_tooltip {
+ position: absolute;
+}
+
+/* ---- Top ---- */
+div.balloon_top {
+ width: 100%;
+ height: 30px;
+ position: relative;
+}
+
+div.balloon_top_left {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 70px;
+ height: 30px;
+ background-image: url(../../images/spinelz/balloon_top_left.gif);
+ background-repeat: no-repeat;
+}
+
+div.balloon_top_middle {
+ height: 30px;
+ background-image: url(../../images/spinelz/balloon_top_middle.gif);
+ background-repeat: repeat-x;
+ margin: 0 70px;
+}
+
+div.balloon_top_right {
+ width: 70px;
+ height: 30px;
+ background-image: url(../../images/spinelz/balloon_top_right.gif);
+ background-repeat: no-repeat;
+ position: absolute;
+ top: 0;
+ right: 0;
+}
+
+/* ---- Middle ---- */
+div.balloon_middle {
+ width: 100%;
+ position: relative;
+}
+
+div.balloon_middle_left {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 70px;
+}
+
+div.balloon_middle_left_row {
+ width: 70px;
+ height: 20px;
+ background-image: url(../../images/spinelz/balloon_middle_left.gif);
+ background-repeat: repeat-y;
+}
+
+div.balloon_middle_right {
+ position: absolute;
+ top: 0;
+ right: 0;
+ width: 70px;
+}
+
+div.balloon_middle_right_row {
+ width: 70px;
+ height: 20px;
+ background-image: url(../../images/spinelz/balloon_middle_right.gif);
+ background-repeat: repeat-y;
+}
+
+div.balloon_left_arrow {
+ width: 70px;
+ height: 60px;
+}
+
+div.balloon_left_up_arrow {
+ width: 70px;
+ height: 60px;
+ background-image: url(../../images/spinelz/balloon_left_up_arrow.gif);
+ background-repeat: no-repeat;
+}
+
+div.balloon_left_down_arrow {
+ width: 70px;
+ height: 60px;
+ background-image: url(../../images/spinelz/balloon_left_down_arrow.gif);
+ background-repeat: no-repeat;
+}
+
+div.balloon_right_arrow {
+ width: 70px;
+ height: 60px;
+}
+
+div.balloon_right_up_arrow {
+ width: 70px;
+ height: 60px;
+ background-image: url(../../images/spinelz/balloon_right_up_arrow.gif);
+ background-repeat: no-repeat;
+}
+
+div.balloon_right_down_arrow {
+ width: 70px;
+ height: 60px;
+ background-image: url(../../images/spinelz/balloon_right_down_arrow.gif);
+ background-repeat: no-repeat;
+}
+
+div.balloon_body {
+ margin: 0 70px;
+ background-image: url(../../images/spinelz/balloon_back.gif);
+ background-repeat: no-repeat;
+ background-color: #f8ffee;
+ overflow: hidden;
+}
+
+/* ---- Bottom ---- */
+div.balloon_bottom {
+ width: 100%;
+ height: 30px;
+ position: relative;
+}
+
+div.balloon_bottom_left {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 70px;
+ height: 30px;
+ background-image: url(../../images/spinelz/balloon_bottom_left.gif);
+ background-repeat: no-repeat;
+}
+
+div.balloon_bottom_middle {
+ height: 30px;
+ background-image: url(../../images/spinelz/balloon_bottom_middle.gif);
+ background-repeat: repeat-x;
+ margin: 0 70px;
+}
+
+div.balloon_bottom_right {
+ width: 70px;
+ height: 30px;
+ background-image: url(../../images/spinelz/balloon_bottom_right.gif);
+ background-repeat: no-repeat;
+ position: absolute;
+ top: 0;
+ right: 0;
+}
--- /dev/null
+.calendar {
+ margin: 0;
+ padding: 0;
+ text-decoration: none;
+ text-transform: none;
+ text-indent: 0;
+ font-weight: normal;
+ font-size: 13px;
+ font-family: Verdana, monospace;
+ width: 100%;
+ background: #ffffff;
+ color: #4F4534;
+ border: 1px solid #999999;
+}
+
+/* header */
+.calendar_scheduleHandler {
+ background: url('../../images/spinelz/calendar_default_handler.gif') no-repeat;
+ width: 16px;
+ height: 16px;
+ cursor: move;
+ float: left;
+}
+
+.calendar_header {
+ background: url(../../images/spinelz/calender_back.gif) repeat-x;
+ color: #4F4534;
+ width: 100%;
+ height: 26px;
+ border-bottom: 1px solid #999999;
+ border-collapse: collapse;
+ font-size: 13px;
+ font-weight: bold;
+}
+
+.calendar_preYears {
+ text-align: left;
+ width: 35px;
+}
+
+.calendar_years {
+ text-align: center;
+}
+
+.calendar_years span {
+ font-weight: bolder;
+ font-size: 105%;
+}
+
+.calendar_nextYears {
+ text-align: right;
+ width: 35px;
+}
+
+.calendar_nextMonthMark {
+ background: url('../../images/spinelz/calendar_next.gif') no-repeat;
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+ float: left;
+}
+
+.calendar_nextYearMark {
+ background: url('../../images/spinelz/calendar_next_second.gif') no-repeat;;
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+ margin-left: 16px;
+}
+
+.calendar_nextWeekMark {
+ background: url('../../images/spinelz/calendar_next.gif') no-repeat;;
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+ margin: 0 0 0 auto;
+}
+
+.calendar_preMonthMark {
+ background: url('../../images/spinelz/calendar_pre.gif') no-repeat;;
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+ margin-left: 16px;
+}
+
+.calendar_preYearMark {
+ background: url('../../images/spinelz/calendar_pre_second.gif') no-repeat;;
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+ float: left;
+}
+
+.calendar_preWeekMark {
+ background: url('../../images/spinelz/calendar_pre.gif') no-repeat;;
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+}
+
+.calendar_markHover {
+ margin-left: 5px;
+ margin-right: 5px;
+ cursor: pointer;
+ color: #FF8080;
+ background-color: #E6E6FA;
+}
+
+.calendar_ym {
+ margin-left: 5px;
+}
+
+.calendar_table {
+ font-size: 12px;
+ border-collapse: collapse;
+ margin: 0;
+ padding: 0;
+ width: 100%;
+ table-layout: fixed;
+}
+
+.calendar_table TH {
+ border-right: 1px solid #999999;
+ border-bottom: 1px solid gray;
+ text-align: center;
+ background: url(../../images/spinelz/calender_back_second.gif) #FFFFFF;
+ color: #4F4534;
+ cursor: pointer;
+ margin: 0;
+ padding: 0;
+ height: 24px;
+}
+
+.calendar_table TH.right {
+ border-right-style: none;
+}
+
+.calendar_table TD {
+ border-right: 1px solid #999999;
+ border-bottom: 1px solid #999999;
+ vertical-align: text-top;
+ height: 100px;
+ margin: 0;
+ padding: 0;
+}
+
+.calendar_table TD.right {
+ border-right-style: none;
+}
+
+.calendar_table TD.bottom {
+ border-bottom-style: none;
+}
+
+.calendar_date {
+ cursor: pointer;
+ color: #000000;
+ background: #FFFFFF;
+ font-weight: bold;
+}
+.calendar_holidayContainer span {
+ padding: 2px;
+}
+.calendar_regularHoliday {
+ cursor: pointer;
+ background: #ededed;
+ color: #285A94;
+ font-weight: bold;
+}
+
+.calendar_holiday {
+ cursor: pointer;
+ background-color: #dedede;
+ color: #285A94;
+ font-weight: bold;
+ overflow: hidden;
+}
+
+.calendar_schedule {
+ cursor: pointer;
+ background: url(../../images/spinelz/calendar_schedule.gif) repeat-x;
+ color: #285A94;
+ font-weight: bold;
+}
+
+.calendar_highlightDay {
+ cursor: pointer;
+ font-weight: bold;
+ text-decoration: underline;
+ color: red;
+}
+
+.calendar_selected {
+ background: #285A94;
+ color: #ffffff;
+}
+
+.calendar_dateContainer {
+ width: 100%;
+ overflow: hidden;
+ height: 15px;
+}
+
+/*
+.calendar_holidayContainer {
+ width: 100%;
+ overflow: hidden;
+}
+*/
+
+.calendar_holidayName {
+ margin-left: 10px;
+}
+
+.calendar_schedule .calendar_scheduleListContainer {
+ color: #000000;
+ margin-top: 5px;
+}
+
+.calendar_selected .calendar_scheduleListContainer {
+ color: #FFFFFF;
+ margin-top: 5px;
+}
+
+.calendar_scheduleListContainer UL {
+ list-style: square outside;
+ font-weight: normal;
+ padding: 0;
+ margin: 0 0 0 15px;
+}
+
+.calendar_scheduleItem {
+ font-size: 10px;
+}
+
+.calendar_scheduleItem DIV {
+ overflow: hidden;
+ font-size: 10px;
+}
+
+/* small size */
+.calendar_small {
+ border: 1px solid #999999;
+ font-size: 13px;
+ width: 175px;
+ background: #FFFFFF;
+ color: #4F4534;
+}
+
+.calendar_calendar_small {
+ background: #FFFFFF;
+ color: #4F4534;
+ font-size: 11px;
+}
+
+.calendar_header_small {
+ background: url(../../images/spinelz/calender_back.gif) repeat-x;
+ color: #4F4534;
+ width: 100%;
+ margin: 0;
+ padding: 0;
+ font-size: 11px;
+ font-weight: bold;
+ border-collapse: collapse;
+ border-bottom: 1px solid #999999;
+ height: 26px;
+}
+
+.calendar_tableSmall {
+ font-size: 11px;
+ text-align: left;
+ width: 100%;
+ border-collapse: collapse;
+ margin: 0 0 0 0;
+ padding: 0;
+ table-layout: fixed;
+}
+
+.calendar_tableSmall TH {
+ text-align: center;
+ background: url(../../images/spinelz/calender_back_second.gif) #FFFFFF;
+ color: #4F4534;
+ width: 14%;
+ cursor: pointer;
+ margin: 0;
+ padding: 0;
+ height: 24px;
+}
+
+.calendar_tableSmall TD {
+ text-align: center;
+ vertical-align: text-top;
+ margin: 0;
+ padding: 0;
+ height: 20px;
+ vertical-align: middle;
+}
+
+
+/* week */
+.calendar_weekContainerTable {
+ width: 100%;
+ border-collapse: collapse;
+ margin: 0;
+ padding: 0;
+ font-size: 11px;
+}
+
+.calendar_weekContainerTable TH {
+ background: url(../../images/spinelz/calender_back_second.gif) #FFFFFF;
+ color: #4F4534;
+ margin: 0;
+ padding: 0;
+ height: 24px;
+}
+
+.calendar_weekContainerTable TD {
+ margin: 0;
+ padding: 0;
+}
+
+.calendar_timeline {
+ margin: 0;
+ padding: 0;
+ width: 50px;
+}
+
+.calendar_timelineTimeTop {
+ height: 23px;
+ text-align: center;
+}
+
+.calendar_timelineTime {
+ height: 51px;
+ border-top: 1px solid #999999;
+ text-align: center;
+}
+
+.calendar_headerColumn {
+ border-left: 1px solid #999999;
+ border-bottom: 1px solid #999999;
+ height: 23px;
+ overflow: hidden;
+ cursor: pointer;
+}
+
+.calendar_headerColumn a {
+ position: relative;
+ top: 4px;
+}
+
+.calendar_columnTopDate {
+ height: 25px;
+ border-left: 1px solid #999999;
+ cursor: pointer;
+}
+
+.calendar_columnDate {
+ height: 25px;
+ border-top: 1px solid #999999;
+ border-left: 1px solid #999999;
+ cursor: pointer;
+}
+
+.calendar_columnOddDate {
+ height: 25px;
+ border-top: 1px dashed #999999;
+ border-left: 1px solid #999999;
+ cursor: pointer;
+}
+
+.calendar_scheduleItemSmall {
+ font-size: 10px;
+ height: 25px;
+ width: 100%;
+ background-color: #E6E6FA;
+ position: absolute;
+ left: 0;
+ top: 0;
+/* opacity: 0.7; */
+ z-index: 1000;
+ overflow: hidden;
+}
+
+.calendar_scheduleItemLarge {
+ font-size: 10px;
+ height: 17px;
+ width: 100%;
+ background-color: #E6E6FA;
+ position: absolute;
+ left: 0;
+ top: 0;
+ z-index: 1000;
+ overflow: hidden;
+ border: 2px solid #285A94;
+ cursor: pointer;
+}
+
+.calendar_scheduleItemNoBorder {
+ padding-top: 2px;
+ font-size: 10px;
+ height: 16px;
+ width: 100%;
+ position: absolute;
+ left: 0;
+ top: 0;
+ z-index: 1000;
+ overflow: hidden;
+ cursor: pointer;
+}
+
+.calendar_scheduleItemNoBorder div {
+ height: 16px;
+}
+
+.calendar_scheduleItemSelect {
+ border: 2px solid red;
+}
+
+/*
+.calendar_detailItem UL {
+ list-style: square outside;
+ font-weight: normal;
+ padding: 0;
+ margin: 0 0 0 15px;
+}
+*/
+
+.calendar_weekMainTable {
+ width: 100%;
+ border-collapse: collapse;
+ margin: 0;
+ padding: 0;
+ font-size: 11px;
+}
+
+.calendar_weekMainTable TH {
+ background: url(../../images/spinelz/calender_back_second.gif) #FFFFFF;
+ color: #4F4534;
+ margin: 0;
+ padding: 0;
+ text-align: center;
+}
+
+.calendar_weekMainTable TD {
+ margin: 0;
+ padding: 0;
+}
+
+.calendar_weekScheduleContainer {
+}
+
+.calendar_deleteImage {
+ background: url(../../images/spinelz/calendar_delete.gif) no-repeat;
+ position: absolute;
+ top: 0;
+ right: 0;
+ width: 16px;
+ height: 16px;
+ font-size: 5px;
+ cursor: pointer;
+}
+
+.calendar_privateImage {
+ background: url(../../images/spinelz/calendar_private_icon.gif) no-repeat;
+ float: left;
+ width: 16px;
+ height: 16px;
+ font-size: 5px;
+}
+
+.calendar_selector {
+ position: absolute;
+ top: 0;
+ left: 0;
+ border: 2px solid #9b0f0f;
+ background: #FFC0CB;
+}
+
+.calendar_scheduleItemTimeArea {
+ margin-right: 3px;
+ font-size: 9px;
+}
+
+.calendar_cover {
+ width: 100%;
+ height: 100px;
+ position: absolute;
+ left: 0;
+ top: 0;
+ z-index: 1000;
+}
--- /dev/null
+.datepicker {
+ border: 1px solid #999999;
+ font-size: 13px;
+ width: 200px;
+ height: 160px;
+ background: #FFFFFF;
+ color: #000000;
+}
+
+.datepicker table tr td {
+ padding: 0px;
+ margin: 0px;
+ border: none;
+}
+
+/* header */
+.datepicker_header {
+ padding-top: 3px;
+ width: 100%;
+ height: 26px;
+ background: url('../../images/spinelz/datepicker_back.gif') repeat-x;
+ color: #808080;
+ border-bottom: 1px solid #999999;
+ font-weight: bold;
+}
+
+.datepicker_nextMonthMark {
+ background: url('../../images/spinelz/datepicker_next.gif') no-repeat;
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+ float: left;
+}
+
+.datepicker_nextYearMark {
+ background: url('../../images/spinelz/datepicker_next_second.gif') no-repeat;
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+ margin-left: 16px;
+}
+
+.datepicker_preMonthMark {
+ background: url('../../images/spinelz/datepicker_pre.gif') no-repeat;
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+ margin-left: 16px;
+}
+
+.datepicker_preYearMark {
+ background: url('../../images/spinelz/datepicker_pre_second.gif') no-repeat;
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+ float: left;
+}
+
+.datepicker_nextYears {
+ text-align: right;
+ width: 35px;
+}
+
+.datepicker_preYears {
+ text-align: left;
+ width: 35px;
+}
+
+.datepicker_years {
+ text-align: center;
+}
+
+.datepicker_nextYears {
+ text-align: right;
+ width: 35px;
+}
+
+.datepicker_ym {
+ margin-left: 10px;
+}
+
+/* calendar */
+.datepicker_calendar {
+ padding-top: 5px;
+ background: #FFFFFF;
+ color: #000000;
+}
+
+.datepicker_table {
+ font-size: 11px;
+ text-align: center;
+ width: 100%;
+ background-position: top;
+}
+
+.datepicker_tableTh {
+ color: #999999;
+}
+
+.datepicker_date {
+ cursor: pointer;
+ background: #FFFFFF;
+ color: #000000;
+ width: 14%;
+}
+
+.datepicker_holiday {
+ cursor: pointer;
+ background: #FFFFFF;
+ font-weight: bold;
+ color: #285A94;
+ width: 14%;
+}
+
+.datepicker_dateHover {
+ cursor: pointer;
+ background: #D5DFE8;
+ font-weight: bold;
+ color: #674534;
+ width: 14%;
+}
+
+.datepicker_holidayHover {
+ cursor: pointer;
+ background-color: #D5DFE8;
+ font-weight: bold;
+ color: #674534;
+ width: 14%;
+}
+
--- /dev/null
+.grid_container {
+ position: relative;
+ width: 500px;
+ height: 200px;
+ overflow: scroll;
+}
+.grid_baseTable{
+ background-color: #F6F6F6;
+ color: #000000;
+ empty-cells: show;
+ z-index: 2;
+}
+.grid_headerIdCol{
+ background: url(../../images/spinelz/table_back.gif) repeat-x #ffffff;
+ color: #000000;
+}
+.grid_headerTable{
+ background-color: #F6F6F6;
+ color: #000000;
+ z-index: 1;
+}
+.grid_headerRow{
+ background-color: #F6F6F6;
+ color: #000000;
+
+}
+.grid_headerCell{
+ background-color: #F6F6F6;
+ color: #000000;
+}
+
+.grid_headerCellDrag {
+ background-color: #F6F6F6;
+ color: #000000;
+ overflow: hidden;
+ cursor: move;
+}
+.grid_headerCellVal {
+ background-color: #F6F6F6;
+ color: #000000;
+ text-align: center;
+ font-weight: bold;
+ overflow: hidden;
+ cursor: pointer;
+}
+
+.grid_idTable {
+ background-color: #F6F6F6;
+ color: #000000;
+ z-index: 1;
+}
+
+.grid_idRow {
+ background-color: #F6F6F6;
+ color: #000000;
+}
+
+.grid_idCell{
+ background-color: #F6F6F6;
+ color: #000000;
+ overflow: hidden;
+
+}
+.grid_idCellVal{
+ background-color: #F6F6F6;
+ color: #000000;
+ cursor: move;
+ overflow: hidden;
+ text-align: center;
+}
+
+.grid_cellTable{
+ overflow: hidden;
+}
+.grid_cellTbody{
+ position: relative;
+}
+
+.grid_cellRow{
+ background-color: #F6F6F6;
+ color: #000000;
+ position: relative;
+ overflow: hidden;
+ top: 0;
+ left: 0;
+}
+
+.grid_cell{
+ overflow: hidden;
+ background-color: #FFFFFF;
+ color: #000000;
+ position: relative;
+}
+
+.grid_cellVal{
+ overflow: hidden;
+ position: relative;
+}
+
+.grid_cellSelected{
+ background-color: #becfeb;
+ color: #000000;
+}
+.cellHover{
+ background-color: #becfeb;
+ color: #000000;
+ font-weight: bold;
+}
+
+.grid_state {
+ background-image: url(../../images/spinelz/grid_state.gif);
+ background-repeat: no-repeat;
+ background-position: 0px -22px;
+ height: 11px;
+ width: 11px;
+ overflow: hidden;
+}
+.grid_stateEmpty {
+ background-position: 0px -22px;
+}
+
+.grid_stateClose {
+ cursor: pointer;
+ background-position: 0px -11px;
+}
+
+.grid_stateOpen {
+ cursor: pointer;
+ background-position: 0px 0px;
+}
+
+.grid_inplaceEditor{
+ margin: 0;
+ padding: 0;
+ width : 100%;
+ height: 100%;
+}
--- /dev/null
+* {
+ margin: 0;
+ padding: 0;
+ text-decoration: none;
+ text-transform: none;
+ text-indent: 0;
+ font-weight: normal;
+ list-style-type: none;
+}
+
+.menubar {
+ background: url(../../images/spinelz/menubar_back.gif) repeat-x;
+ border: 1px solid #999999;
+ font-size: 0.8em;
+ line-height: 1.3em;
+ height: 26px;
+}
+
+.menubar_menu {
+}
+
+.menubar_menuBody {
+ float: left;
+ cursor: pointer;
+ padding: 3px 8px;
+ height: 20px;
+ line-height: 1.8em;
+}
+
+.menubar_menuBodyHover {
+ float: left;
+ cursor: pointer;
+ background: #defa93;
+ padding: 3px 8px;
+ height: 20px;
+ line-height: 1.8em;
+}
+
+.menubar_subMenu {
+}
+
+.menubar_subMenuBody {
+ background: url(../../images/spinelz/menubar_subcontents_back.gif) repeat-x #fff;
+ color: #4F4534;
+ padding: 0 3px;
+ cursor: pointer;
+}
+
+.menubar_subMenuBodyHover {
+ background: #C8CEF6;
+ color: #4F4534;
+ padding: 0 3px;
+ cursor: pointer;
+}
+
+.menubar_subMenuBody A {
+ background: #FFFFFF;
+ color: gray;
+ cursor: pointer;
+}
+
+.menubar_subMenuBodyHover A {
+ background-color: #C8CEF6;
+ color: #FFFFFF;
+ cursor: pointer;
+
+}
+
+.menubar_menuContainer {
+ border: 1px solid #999999;
+ position: absolute;
+ width: 100px;
+}
+
+.menubar_dirMark {
+ position: relative;
+ top: -17px;
+ left: 0;
+ float: right;
+ color: #999999;
+ cursor: pointer;
+}
+
--- /dev/null
+.modal_mask {
+ position: fixed;
+ top: 0px;
+ right:0px;
+ left: 0px;
+ width: 100%;
+ height: 100%;
+ opacity: .2;
+ background-color: #CCCCCC;
+ color: #FFFFFF;
+}
+
+.modal_mask_ie {
+ position: absolute;
+ top: expression(eval(document.documentElement.scrollTop));
+ left: expression(eval(document.documentElement.scrollLeft));
+ width: 100%;
+ height: 100%;
+ filter: alpha(opacity=20);
+ background-color: #CCCCCC;
+ color: #FFFFFF;
+}
--- /dev/null
+.navPanel{
+ border-bottom: 1px solid #919b9c;
+}
+
+.navPanel_panel{
+ border-left: 1px solid #999999;
+ border-right: 1px solid #999999;
+ padding: 10px;
+ overflow: auto;
+}
+
+.navPanel_tab {
+ height: 26px;
+ position: relative;
+ cursor: pointer;
+}
+.navPanel_tab div{
+ height: 26px;
+}
+.navPanel_tabLeftInactive {
+ background: url('../../images/spinelz/navPanel_tab_left_inactive.gif') no-repeat;
+ position: absolute;
+ left: 0;
+ width: 10px;
+}
+
+.navPanel_tabLeftActive {
+ background: url('../../images/spinelz/navPanel_tab_left_active.gif') no-repeat;
+ position: absolute;
+ left: 0;
+ width: 10px;
+}
+
+.navPanel_tabMiddleInactive {
+ background: url('../../images/spinelz/navPanel_tab_middle_inactive.gif') repeat-x;
+ margin: 0 10px;
+}
+
+.navPanel_tabMiddleActive {
+ background: url('../../images/spinelz/navPanel_tab_middle_active.gif') repeat-x;
+ margin: 0 10px;
+}
+
+.navPanel_tabRightInactive {
+ background: url('../../images/spinelz/navPanel_tab_right_inactive.gif') no-repeat;
+ position: absolute;
+ top: 0;
+ right: 0;
+ width: 10px;
+}
+
+.navPanel_tabRightActive {
+ background: url('../../images/spinelz/navPanel_tab_right_active.gif') no-repeat;
+ position: absolute;
+ top: 0;
+ right: 0;
+ width: 10px;
+}
--- /dev/null
+.selectableTable_table {
+ border-collapse: collapse;
+ margin: 0px;
+ padding: 0px;
+ width: 100%;
+}
+
+.selectableTable_tr {
+ margin: 0px;
+ padding: 0px;
+}
+
+.selectableTable_tr td {
+ border-bottom: 1px dotted black;
+ border-top: 1px dotted black;
+}
+
+.selectableTable_trSelected {
+ background: url(../../images/spinelz/selectabletable_selected.gif) repeat-x;
+ margin: 0px;
+ padding: 0px;
+}
+
+.selectableTable_trHover {
+ background-color: #eeffcc;
+ margin: 0px;
+ padding: 0px;
+}
--- /dev/null
+* {
+ margin: 0;
+ padding: 0;
+ text-decoration: none;
+ text-transform: none;
+ text-indent: 0;
+ font-weight: normal;
+ list-style-type: none;
+}
+
+.sideBarBox_panelContainer {
+ float: left;
+ border: 1px solid #999999;
+ padding: 5px;
+ position: relative;
+ z-index: 5;
+ width: 200px;
+ height: 200px;
+}
+
+.sideBarBox_tabContainer {
+ position: relative;
+ float: left;
+ width: 40px;
+}
+
+.sideBarBox_tabContent {
+}
+
+.sideBarBox_tabTitle {
+ position: relative;
+ left: 10px;
+}
+
+.sideBarBox_tab div{
+ cursor: pointer;
+ width: 40px;
+ position: relative;
+ left: -1px;
+}
+
+.sideBarBox_tabTopInactive {
+ background: url('../../images/spinelz/sideBarBox_tabTopInactive.gif') no-repeat;
+ background-position: 0 1px;
+ height: 10px;
+ z-index: 1;
+ font-size: 1px;
+}
+
+.sideBarBox_tabTopActive {
+ background: url('../../images/spinelz/sideBarBox_tabTopActive.gif') no-repeat;
+ background-position: 0 1px;
+ height: 10px;
+ z-index: 10;
+ font-size: 1px;
+}
+
+.sideBarBox_tabMiddleInactive {
+ background: url('../../images/spinelz/sideBarBox_tabMiddleInactive.gif') repeat-y;
+ background-position: left top;
+ top: -2px;
+ z-index: 1;
+}
+
+.sideBarBox_tabMiddleActive {
+ background: url('../../images/spinelz/sideBarBox_tabMiddleActive.gif') repeat-y;
+ background-position: left top;
+ top: -2px;
+ z-index: 10;
+}
+
+.sideBarBox_tabBottomInactive {
+ display: block;
+ background: url('../../images/spinelz/sideBarBox_tabBottomInactive.gif') no-repeat;
+ background-position: left top;
+ height: 10px;
+ top: -5px;
+}
+
+.sideBarBox_tabBottomActive {
+ display: block;
+ background: url('../../images/spinelz/sideBarBox_tabBottomActive.gif') no-repeat;
+ background-position: left top;
+ height: 10px;
+ top: -5px;
+ z-index: 10;
+}
--- /dev/null
+
+.sortableTable_header {
+ width: 100%;
+ border: none;
+}
+
+.sortableTable_thead {
+ background: url(../../images/spinelz/table_back.gif) repeat-x #ffffff;
+ height: 26px;
+ border: 1px solid #999;
+}
+
+.sortableTable_thead th {
+ border: 0;
+ padding: 0;
+}
+.sortableTable_tbody {
+ background: #ffffff;
+}
+
+.sortableTable_tbody th {
+ border: 0;
+}
+
+.sortableTable_title {
+ float: left;
+ width: 100%;
+ font-weight: bold;
+ height: 26px;
+}
+
+.sortableTable_empty {
+ height: 16px;
+ width: 16px;
+}
+
+.sortableTable_down {
+ background: url(../../images/spinelz/sortableTable_down.gif) no-repeat;
+ cursor: pointer;
+ height: 16px;
+ width: 16px;
+ overflow: hidden;
+}
+
+.sortableTable_up {
+ background: url(../../images/spinelz/sortableTable_up.gif) no-repeat;
+ cursor: pointer;
+ height: 16px;
+ width: 16px;
+ overflow: hidden;
+}
--- /dev/null
+.switcher_state_close {
+ float: left;
+ background-image: url('../../images/spinelz/switcher_close.gif');
+ background-repeat: no-repeat;
+ cursor: pointer;
+ height: 16px;
+ width: 16px;
+ background-position: center center;
+ overflow: visible;
+}
+
+.switcher_state_open {
+ float: left;
+ background-image: url('../../images/spinelz/switcher_open.gif');
+ background-repeat: no-repeat;
+ cursor: pointer;
+ height: 16px;
+ width: 16px;
+ background-position: center center;
+ overflow: visible;
+}
+
--- /dev/null
+.tabBox_tabBox {
+ margin: 0;
+ padding: 0;
+ text-decoration: none;
+ text-transform: none;
+ text-indent: 0;
+ font-weight: normal;
+}
+
+.tabBox_panelContainer {
+ clear: left;
+ border-left: 1px solid #999999;
+ border-right: 1px solid #999999;
+ border-bottom: 1px solid #999999;
+}
+
+.tabBox_tabContainer{
+ height: 42px;
+ background: url(../../images/spinelz/tab_bar.gif) repeat-x;
+ background-position: bottom;
+ padding-left: 5px;
+}
+
+.tabBox_tab {
+ float: left;
+}
+
+.tabBox_tab div{
+ float: left;
+ height: 24px;
+ cursor: pointer;
+ overflow: hidden;
+}
+
+.tabBox_tabLeftInactive {
+ background: url('../../images/spinelz/tabBox_tabLeftInactive.gif') no-repeat;
+ width: 8px;
+ margin-left: 4px;
+}
+
+.tabBox_tabLeftActive {
+ background: url('../../images/spinelz/tabBox_tabLeftActive.gif') no-repeat;
+ width: 8px;
+ margin-left: 4px;
+}
+
+.tabBox_tabMiddleInactive {
+ background: url('../../images/spinelz/tabBox_tabMiddleInactive.gif') repeat-x;
+ line-height: 1.8em;
+}
+
+.tabBox_tabMiddleActive {
+ background: url('../../images/spinelz/tabBox_tabMiddleActive.gif') repeat-x;
+ line-height: 1.8em;
+}
+
+.tabBox_tabRightInactive {
+ background: url('../../images/spinelz/tabBox_tabRightInactive.gif') no-repeat;
+ width: 10px;
+ padding: 0;
+}
+
+.tabBox_tabRightActive {
+ background: url('../../images/spinelz/tabBox_tabRightActive.gif') no-repeat;
+ width: 10px;
+}
+
+.tabBox_tabTitle {
+ font-weight: bold;
+ line-height: 1.5em;
+ padding: 0 10px !important;
+}
+
+.tabBox_closeButton {
+ border: 0;
+ overflow: hidden;
+ cursor: pointer;
+ font-size: 5px;
+ width: 16px;
+ height: 16px;
+ background: url('../../images/spinelz/tabBox_close.gif') no-repeat;
+ position: relative;
+ top: 5px;
+}
--- /dev/null
+.timepicker_container {
+ margin: 0;
+ padding: 0;
+ text-decoration: none;
+ text-transform: none;
+ text-indent: 0;
+ font-weight: normal;
+ font-size: 13px;
+ font-family: Verdana, monospace;
+ width: 150px;
+ background: #ffffff;
+ color: #4F4534;
+ border: 1px solid #999999;
+}
+
+/* header */
+.timepicker_scheduleHandler {
+ background: url('../../images/spinelz/calendar_default_handler.gif') no-repeat;
+ width: 16px;
+ height: 16px;
+ cursor: move;
+ float: left;
+}
+
+.timepicker_header {
+ background: url(../../images/spinelz/calender_back.gif) repeat-x;
+ color: #4F4534;
+ width: 100%;
+ height: 26px;
+ border-bottom: 1px solid #999999;
+ border-collapse: collapse;
+ font-size: 13px;
+ font-weight: bold;
+}
+
+.timepicker_preYears {
+ text-align: left;
+ width: 35px;
+}
+
+.timepicker_years {
+ text-align: center;
+}
+
+.timepicker_years span {
+ font-weight: bolder;
+ font-size: 105%;
+}
+
+.timepicker_nextYears {
+ text-align: right;
+ width: 35px;
+}
+
+.timepicker_nextMonthMark {
+ background: url('../../images/spinelz/calendar_next.gif') no-repeat;
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+ float: left;
+}
+
+.timepicker_nextYearMark {
+ background: url('../../images/spinelz/calendar_next_second.gif') no-repeat;;
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+ margin-left: 16px;
+}
+
+.timepicker_nextWeekMark {
+ background: url('../../images/spinelz/calendar_next.gif') no-repeat;;
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+ margin: 0 0 0 auto;
+}
+
+.timepicker_preMonthMark {
+ background: url('../../images/spinelz/calendar_pre.gif') no-repeat;;
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+ margin-left: 16px;
+}
+
+.timepicker_preYearMark {
+ background: url('../../images/spinelz/calendar_pre_second.gif') no-repeat;;
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+ float: left;
+}
+
+.timepicker_preWeekMark {
+ background: url('../../images/spinelz/calendar_pre.gif') no-repeat;;
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+}
+
+.timepicker_markHover {
+ margin-left: 5px;
+ margin-right: 5px;
+ cursor: pointer;
+ color: #FF8080;
+ background-color: #E6E6FA;
+}
+
+.timepicker_ym {
+ margin-left: 5px;
+}
+
+.timepicker_table {
+ font-size: 12px;
+ border-collapse: collapse;
+ margin: 0;
+ padding: 0;
+ width: 100%;
+ table-layout: fixed;
+}
+
+.timepicker_table TH {
+ border-right: 1px solid #999999;
+ border-bottom: 1px solid gray;
+ text-align: center;
+ background: url(../../images/spinelz/calender_back_second.gif) #FFFFFF;
+ color: #4F4534;
+ cursor: pointer;
+ margin: 0;
+ padding: 0;
+ height: 24px;
+}
+
+.timepicker_table TH.right {
+ border-right-style: none;
+}
+
+.timepicker_table TD {
+ border-right: 1px solid #999999;
+ border-bottom: 1px solid #999999;
+ vertical-align: text-top;
+ height: 100px;
+ margin: 0;
+ padding: 0;
+}
+
+.timepicker_table TD.right {
+ border-right-style: none;
+}
+
+.timepicker_table TD.bottom {
+ border-bottom-style: none;
+}
+
+.timepicker_date {
+ cursor: pointer;
+ color: #000000;
+ background: #FFFFFF;
+ font-weight: bold;
+}
+.timepicker_holidayContainer span {
+ padding: 2px;
+}
+.timepicker_regularHoliday {
+ cursor: pointer;
+ background: #ededed;
+ color: #285A94;
+ font-weight: bold;
+}
+
+.timepicker_holiday {
+ cursor: pointer;
+ background-color: #dedede;
+ color: #285A94;
+ font-weight: bold;
+ overflow: hidden;
+}
+
+.timepicker_schedule {
+ cursor: pointer;
+ background: url(../../images/spinelz/timepicker_schedule.gif) repeat-x;
+ color: #285A94;
+ font-weight: bold;
+}
+
+.timepicker_highlightDay {
+ cursor: pointer;
+ font-weight: bold;
+ text-decoration: underline;
+}
+
+.timepicker_selected {
+ background: #285A94;
+ color: #ffffff;
+}
+
+.timepicker_dateContainer {
+ width: 100%;
+ overflow: hidden;
+ height: 15px;
+}
+
+/*
+.timepicker_holidayContainer {
+ width: 100%;
+ overflow: hidden;
+}
+*/
+
+.timepicker_holidayName {
+ margin-left: 10px;
+}
+
+.timepicker_schedule .timepicker_scheduleListContainer {
+ color: #000000;
+ margin-top: 5px;
+}
+
+.timepicker_selected .timepicker_scheduleListContainer {
+ color: #FFFFFF;
+ margin-top: 5px;
+}
+
+.timepicker_scheduleListContainer UL {
+ list-style: square outside;
+ font-weight: normal;
+ padding: 0;
+ margin: 0 0 0 15px;
+}
+
+.timepicker_scheduleItem {
+ font-size: 10px;
+}
+
+.timepicker_scheduleItem DIV {
+ overflow: hidden;
+ font-size: 10px;
+}
+
+/* small size */
+.timepicker_small {
+ border: 1px solid #999999;
+ font-size: 13px;
+ width: 175px;
+ background: #FFFFFF;
+ color: #4F4534;
+}
+
+.timepicker_timepicker_small {
+ background: #FFFFFF;
+ color: #4F4534;
+ font-size: 11px;
+}
+
+.timepicker_header_small {
+ background: url(../../images/spinelz/calender_back.gif) repeat-x;
+ color: #4F4534;
+ width: 100%;
+ margin: 0;
+ padding: 0;
+ font-size: 11px;
+ font-weight: bold;
+ border-collapse: collapse;
+ border-bottom: 1px solid #999999;
+ height: 26px;
+}
+
+.timepicker_tableSmall {
+ font-size: 11px;
+ text-align: left;
+ width: 100%;
+ border-collapse: collapse;
+ margin: 0 0 0 0;
+ padding: 0;
+ table-layout: fixed;
+}
+
+.timepicker_tableSmall TH {
+ text-align: center;
+ background: url(../../images/spinelz/calender_back_second.gif) #FFFFFF;
+ color: #4F4534;
+ width: 14%;
+ cursor: pointer;
+ margin: 0;
+ padding: 0;
+ height: 24px;
+}
+
+.timepicker_tableSmall TD {
+ text-align: center;
+ vertical-align: text-top;
+ margin: 0;
+ padding: 0;
+ height: 20px;
+ vertical-align: middle;
+}
+
+
+/* week */
+.timepicker_weekContainerTable {
+ width: 100%;
+ border-collapse: collapse;
+ margin: 0;
+ padding: 0;
+ font-size: 11px;
+}
+
+.timepicker_weekContainerTable TH {
+ background: url(../../images/spinelz/calender_back_second.gif) #FFFFFF;
+ color: #4F4534;
+ margin: 0;
+ padding: 0;
+ height: 24px;
+}
+
+.timepicker_weekContainerTable TD {
+ margin: 0;
+ padding: 0;
+}
+
+.timepicker_timeline {
+ margin: 0;
+ padding: 0;
+ width: 25px;
+}
+
+.timepicker_timelineTimeTop {
+ height: 23px;
+ text-align: center;
+}
+
+.timepicker_timelineTime_ie {
+ height: 27px;
+ border-top: 1px solid #999999;
+ text-align: center;
+}
+
+.timepicker_timelineTime_ieTop {
+ height: 28px;
+ border-top: 1px solid #999999;
+ text-align: center;
+}
+
+.timepicker_timelineTime {
+ height: 25px;
+ border-top: 1px solid #999999;
+ text-align: center;
+}
+
+.timepicker_headerColumn {
+ border-left: 1px solid #999999;
+ border-bottom: 1px solid #999999;
+ height: 23px;
+ overflow: hidden;
+ cursor: pointer;
+}
+
+.timepicker_headerColumn a {
+ position: relative;
+ top: 4px;
+}
+
+.timepicker_columnTopDate {
+ height: 12px;
+ border-left: 1px solid #999999;
+ cursor: pointer;
+}
+
+.timepicker_columnDate {
+ height: 12px;
+ border-top: 1px solid #999999;
+ border-left: 1px solid #999999;
+ cursor: pointer;
+}
+
+.timepicker_columnOddDate {
+ height: 12px;
+ border-top: 1px dashed #999999;
+ border-left: 1px solid #999999;
+ cursor: pointer;
+}
+
+.timepicker_scheduleItemSmall {
+ font-size: 10px;
+ height: 25px;
+ width: 100%;
+ background-color: #E6E6FA;
+ position: absolute;
+ left: 0;
+ top: 0;
+/* opacity: 0.7; */
+ z-index: 1000;
+ overflow: hidden;
+}
+
+.timepicker_scheduleItemLarge {
+ font-size: 10px;
+ height: 17px;
+ width: 100%;
+ background-color: #E6E6FA;
+ position: absolute;
+ left: 0;
+ top: 0;
+ z-index: 1000;
+ overflow: hidden;
+ border: 2px solid #285A94;
+ cursor: pointer;
+}
+
+.timepicker_scheduleItemNoBorder {
+ padding-top: 2px;
+ font-size: 10px;
+ height: 16px;
+ width: 100%;
+ position: absolute;
+ left: 0;
+ top: 0;
+ z-index: 1000;
+ overflow: hidden;
+ cursor: pointer;
+}
+
+.timepicker_scheduleItemNoBorder div {
+ height: 16px;
+}
+
+.timepicker_scheduleItemSelect {
+ border: 2px solid red;
+}
+
+/*
+.timepicker_detailItem UL {
+ list-style: square outside;
+ font-weight: normal;
+ padding: 0;
+ margin: 0 0 0 15px;
+}
+*/
+
+.timepicker_weekMainTable {
+ width: 100%;
+ border-collapse: collapse;
+ margin: 0;
+ padding: 0;
+ font-size: 11px;
+}
+
+.timepicker_weekMainTable TH {
+ background: url(../../images/spinelz/calender_back_second.gif) #FFFFFF;
+ color: #4F4534;
+ margin: 0;
+ padding: 0;
+ text-align: center;
+}
+
+.timepicker_weekMainTable TD {
+ margin: 0;
+ padding: 0;
+}
+
+.timepicker_weekScheduleContainer {
+}
+
+.timepicker_deleteImage {
+ background: url(../../images/spinelz/timepicker_delete.gif) no-repeat;
+ position: absolute;
+ top: 0;
+ right: 0;
+ width: 16px;
+ height: 16px;
+ font-size: 5px;
+ cursor: pointer;
+}
+
+.timepicker_privateImage {
+ background: url(../../images/spinelz/timepicker_private_icon.gif) no-repeat;
+ float: left;
+ width: 16px;
+ height: 16px;
+ font-size: 5px;
+}
+
+.timepicker_selector {
+ position: absolute;
+ top: 0;
+ left: 0;
+ border: 2px solid #9b0f0f;
+ background: #FFC0CB;
+}
+
+.timepicker_scheduleItemTimeArea {
+ margin-right: 3px;
+ font-size: 9px;
+}
+
+.timepicker_cover {
+ width: 100%;
+ height: 100px;
+ position: absolute;
+ left: 0;
+ top: 0;
+ z-index: 1000;
+}
+
+.timepicker_displayToggle {
+ font-weight: normal;
+}
--- /dev/null
+.toolbar_container {
+ position: relative;
+ height: 25px;
+}
+
+.toolbar_containerLeft {
+ background-repeat:no-repeat;
+ background-image:url('../../images/spinelz/toolbar_left.gif');
+ position:absolute;
+ left:0px;
+ height: 25px;
+ width: 2px;
+}
+
+.toolbar_containerMiddle {
+ height: 25px;
+ background-repeat:repeat-x;
+ background-image:url('../../images/spinelz/toolbar_middle.gif');
+ margin-left: 2px;
+ margin-right: 3px;
+ padding-top: 2px;
+}
+
+.toolbar_containerRight {
+ background-repeat: no-repeat;
+ background-image: url('../../images/spinelz/toolbar_right.gif');
+ position:absolute;
+ top: 0px;
+ right:0px;
+ height: 25px;
+ width: 3px;
+}
+
+.toolbar_item {
+ position:relative;
+ margin-right:3px;
+ height:20px;
+ padding: 1px;
+ float:left;
+}
+
+.toolbar_itemHov {
+ position:relative;
+ margin-right:3px;
+ height:20px;
+ padding: 0px;
+ float:left;
+ border: 1px solid #b9cfd8;
+}
+
+.toolbar_itemPres {
+ position:relative;
+ margin-right:3px;
+ height:20px;
+ padding: 0px;
+ float:left;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #b9cfd8 #ffffff #ffffff #b9cfd8;
+}
+
+.toolbar_content {
+ position:relative;
+ height: 18px;
+ font-size:11px;
+ padding: 2px 5px 0 5px;
+ overflow: hidden;
+ cursor: pointer;
+ float: left;
+}
+
+.toolbar_contentPres {
+ position:relative;
+ height: 18px;
+ font-size:0px;
+ padding: 2px 5px 0 5px;
+ overflow: hidden;
+ cursor: pointer;
+ float: left;
+ background-color: #ffffff;
+ color: #000000;
+}
--- /dev/null
+.treeview {
+ list-style: none outside;
+ font-size: 12px;
+}
+
+.treeview_dir {
+ margin-top: 2px;
+ height: auto;
+ width: auto;
+}
+
+.treeview_dirBody {
+ cursor: pointer;
+ height: 15px;
+ width: auto;
+}
+
+.treeview_dirBodyText {
+ background-color: #FFFFFF;
+ color: black;
+}
+
+.treeview_dirBodyTextActive {
+ background-color: #becfeb;
+ color: black;
+}
+
+.treeview_dirContainerHover {
+ background-color: #becfeb;
+}
+
+.treeview_dirContainer {
+ list-style: none outside;
+ padding: 1px 0 3px 20px;
+ margin: 0px;
+ height: auto;
+ width: auto;
+}
+
+.treeview_file {
+ margin-top: 2px;
+ margin-left: 17px;
+/* position: relative; */
+/* top: 0px; */
+/* left: 0px; */
+}
+
+.treeview_fileBody {
+ height: 15px;
+ cursor: pointer;
+}
+
+.treeview_fileBodyText {
+ background-color: #FFFFFF;
+ color: black;
+}
+
+.treeview_fileBodyTextActive {
+ background-color: #becfeb;
+ color: black;
+}
+
+.treeview_stateEmpty {
+ float: left;
+ background-image: url(../../images/spinelz/treeview_state.gif);
+ background-repeat: no-repeat;
+ cursor: pointer;
+ height: 11px;
+ width: 11px;
+ margin-right: 5px;
+ background-position: 0px -22px;
+ overflow: hidden;
+}
+
+.treeview_stateClose {
+ float: left;
+ background-image: url(../../images/spinelz/treeview_state.gif);
+ background-repeat: no-repeat;
+ cursor: pointer;
+ height: 11px;
+ width: 11px;
+ margin-right: 5px;
+ background-position: 0px -11px;
+ overflow: hidden;
+}
+
+.treeview_stateOpen {
+ float: left;
+ background-image: url(../../images/spinelz/treeview_state.gif);
+ background-repeat: no-repeat;
+ cursor: pointer;
+ height: 11px;
+ width: 11px;
+ margin-right: 5px;
+ background-position: 0px 0px;
+ overflow: hidden;
+}
+
+.treeview_dirIcon {
+ float: left;
+ background-image: url(../../images/spinelz/treeview_dir.gif);
+ background-repeat: no-repeat;
+ cursor: pointer;
+ height: 16px;
+ width: 16px;
+ margin-right: 5px;
+ background-position: 0px 0px;
+ overflow: hidden;
+}
+
+.treeview_fileIcon {
+ float: left;
+ background-image: url(../../images/spinelz/treeview_file.gif);
+ background-repeat: no-repeat;
+ cursor: pointer;
+ height: 16px;
+ width: 16px;
+ margin-right: 2px;
+ background-position: 0px 0px;
+ overflow: hidden;
+}
--- /dev/null
+.window {
+ position: absolute;
+ margin: 0;
+ padding: 0;
+ text-decoration: none;
+ text-transform: none;
+ text-indent: 0;
+ font-weight: normal;
+}
+
+.window_header{
+ width: 100%;
+ height: 45px;
+ position: relative;
+}
+
+.window_headerLeft{
+ width: 30px;
+ height: 45px;
+ top: 0;
+ position: absolute;
+ left: 0;
+ background: url('../../images/spinelz/window_top_left.gif') no-repeat;
+}
+
+.window_headerMiddle{
+ height: 45px;
+ top: 0;
+ margin: 0 30px;
+ background: url('../../images/spinelz/window_top_middle.gif') repeat-x;
+ cursor: move;
+ line-height: 3.0em;
+ overflow: hidden;
+}
+
+.window_headerRight{
+ width: 30px;
+ height: 45px;
+ top: 0;
+ position: absolute;
+ right: 0;
+ background: url('../../images/spinelz/window_top_right.gif') no-repeat;
+}
+
+.window_buttonHolder{
+ width: 60px;
+ height: 16px;
+ position: absolute;
+ top: 0;
+ right: 32px;
+ margin-top: 10px;
+}
+
+.window_closeButton{
+ float: right;
+ overflow: hidden;
+ font-size: 5px;
+ width: 16px;
+ height: 16px;
+ background: url('../../images/spinelz/window_close.gif') no-repeat;
+ cursor:pointer;
+}
+
+.window_maxButton{
+ float: right;
+ overflow: hidden;
+ cursor: pointer;
+ width: 16px;
+ height: 16px;
+ background: url('../../images/spinelz/window_max.gif') no-repeat;
+}
+
+.window_minButton{
+ float: right;
+ overflow: hidden;
+ cursor: pointer;
+ width: 16px;
+ height: 16px;
+ background: url('../../images/spinelz/window_min.gif') no-repeat;
+}
+
+.window_body{
+ width: 100%;
+ background: transparent;
+ color: #000000;
+ position: relative;
+}
+
+.window_bodyLeft{
+ top: 0;
+ width: 30px;
+ position: absolute;
+ left: 0;
+ background: url('../../images/spinelz/window_middle_left.gif') repeat-y;
+}
+
+.window_bodyMiddle{
+ top: 0;
+ position: relative;
+ margin: 0 30px;
+ background: #fff;
+ color: #000000;
+ overflow: auto;
+}
+
+.window_bodyRight{
+ top: 0;
+ width: 30px;
+ position: absolute;
+ right: 0;
+ background: url('../../images/spinelz/window_middle_right.gif') repeat-y;
+}
+
+.window_bottom{
+ width: 100%;
+ height: 35px;
+ position: relative;
+}
+
+.window_bottomLeft{
+ width: 30px;
+ height: 35px;
+ position: absolute;
+ left: 0;
+ background: url('../../images/spinelz/window_bottom_left.gif') no-repeat;
+}
+
+.window_bottomMiddle{
+ height: 35px;
+ margin: 0 30px;
+ background: url('../../images/spinelz/window_bottom_middle.gif') repeat-x;
+}
+
+.window_bottomRight{
+ width: 30px;
+ height: 35px;
+ position: absolute;
+ top: 0;
+ right: 0;
+ background: url('../../images/spinelz/window_bottom_right.gif') no-repeat;
+}
--- /dev/null
+body { background-color: #fff; color: #333; }
+
+body, p, ol, ul, td {
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px;
+}
+
+pre {
+ background-color: #eee;
+ padding: 10px;
+ font-size: 11px;
+}
+
+a { color: #000; }
+a:visited { color: #666; }
+a:hover { color: #fff; background-color:#000; }
+
+ul.menu {
+ list-style-type: none;
+}
+
+ul.menu li {
+ float: left;
+ background-color: white;
+ margin-left: 10px;
+ border: 1px solid black;
+ padding: 2px;
+}
+
+div.tabpanel div.tab-row li {
+ margin: 0;
+ padding: 0;
+ display: inline;
+ list-style-type: none;
+}
+
+div.tabpanel div.tab-row a:link,
+ div.tabpanel div.tab-row a:visited {
+ float: left;
+ background: #f3f3f3;
+ font-size: 12px;
+ line-height: 14px;
+ font-weight: bold;
+ padding: 2px 10px 2px 10px;
+ margin-right: 4px;
+ border: 1px solid #ccc;
+ text-decoration: none;
+ color: #666;
+}
+
+div.tabpanel div.tab-row li.selected a:link,
+ div.tabpanel div.tab-row a:visited.active {
+ border-bottom: 1px solid #fff;
+ background: #fff;
+ color: #000;
+}
+
+div.tabpanel div.tab-row a:hover {
+ background: #fff;
+}
\ No newline at end of file