はじめに
script.
Thomas Fuchs氏を中心に、
AppleやGucciといった、
script.
prototype.
この連載では、
script.
想定している読者は、
なお、
8つのライブラリ
script.
- controls.
js - Ajaxを活用した、
斬新なGUI部品のライブラリです。入力補完つきのテキスト入力ボックスや、 Webページを"その場で編集できる"機能を、 提供します。 - effects.
js - script.
aculo. usの代名詞ともいえる、 フェードアウトやズームインといった、 派手なエフェクトの数々を提供するライブラリです。 - dragdrop.
js - Webページ上でドラッグ&ドロップを実現するためのライブラリです。
- slider.
js - スライダーというGUI部品のライブラリです。
- builder.
js - 関数型言語のようににDOMを構築できるライブラリです。
- sound.
js - 音声を再生するためのライブラリです。
- unittest.
js - 単体テストを自動化するライブラリです。
- scriptaculous.
js - 上記のライブラリをロードするためのライブラリです。
ソースコードの入手
script.
パッケージのtestディレクトリ以下には、
scriptaculous.js
第1回は、
0001: // script.aculo.us scriptaculous.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008
0002:
0003: // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
0004: //
0005: // Permission is hereby granted, free of charge, to any person obtaining
0006: // a copy of this software and associated documentation files (the
0007: // "Software"), to deal in the Software without restriction, including
0008: // without limitation the rights to use, copy, modify, merge, publish,
0009: // distribute, sublicense, and/or sell copies of the Software, and to
0010: // permit persons to whom the Software is furnished to do so, subject to
0011: // the following conditions:
0012: //
0013: // The above copyright notice and this permission notice shall be
0014: // included in all copies or substantial portions of the Software.
0015: //
0016: // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0017: // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0018: // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0019: // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
0020: // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
0021: // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
0022: // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0023: //
0024: // For details, see the script.aculo.us web site: http://script.aculo.us/
0025:
Thomas Fuchsによる著作権表示です。MITライセンスなので、
0026: var Scriptaculous = {
0027: Version: '1.8.1' ,
0028: require: function(libraryName) {
0029: // inserting via DOM fails in Safari 2.0, so brute force approach
0030: document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>' );
0031: },
0032: REQUIRED_PROTOTYPE: '1.6.0' ,
28行目のScriptaculous.
Safari 2.
32行目で、
0033: load: function() {
0034: function convertVersionString(versionString){
0035: var r = versionString.split('.');
0036: return parseInt(r[0])*100000 + parseInt(r[1])*1000 + parseInt(r[2]);
0037: }
0038:
0039: if((typeof Prototype=='undefined') ||
0040: (typeof Element == 'undefined') ||
0041: (typeof Element.Methods=='undefined') ||
0042: (convertVersionString(Prototype.Version) <
0043: convertVersionString(Scriptaculous.REQUIRED_PROTOTYPE)))
0044: throw("script.aculo.us requires the Prototype JavaScript framework >= " +
0045: Scriptaculous.REQUIRED_PROTOTYPE);
0046:
0047: $A(document.getElementsByTagName("script")).findAll( function(s) {
0048: return (s.src && s.src.match(/scriptaculous\.js(\?.*)?$/))
0049: }).each( function(s) {
0050: var path = s.src.replace(/scriptaculous\.js(\?.*)?$/,'');
0051: var includes = s.src.match(/\?.*load=([a-z,]*)/);
0052: (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each(
0053: function(include) { Scriptaculous.require(path+include+'.js') });
0054: });
0055: }
0056: }
0057:
0058: Scriptaculous.load();
33行目のScriptaculous.
34~38行目のconvertVersionStringは、
39~46行目で、
47行目で、 48行目で、 9~51行目で、 52行目で、