├── .gitignore
├── ruby_libs
├── base.rb
├── init.rb
├── options.rb
├── config.rb
├── compiler.rb
└── installer.rb
├── src
├── style
│ ├── table_ruler.js
│ └── color.js
├── azuki.js
├── helpers
│ ├── compatibility_helper.js
│ ├── forms_helper.js
│ ├── keyboard_helper.js
│ └── window_helper.js
├── storage
│ └── cookie.js
├── windowing
│ ├── busybox.js
│ ├── popinfo.js
│ ├── contextual_help.js
│ ├── fader.js
│ └── lightbox.js
├── forms
│ ├── select_search.js
│ ├── textarea_extensions.js
│ └── remote.js
└── controller.js
├── images
├── add.gif
├── add.png
├── job.png
├── new.png
├── no.gif
├── ok.gif
├── yes.gif
├── back.png
├── close.gif
├── close.png
├── error.gif
├── export.gif
├── feed.gif
├── file.png
├── help.gif
├── info.gif
├── locked.gif
├── logo.gif
├── modify.png
├── open.png
├── remove.png
├── saving.gif
├── saving.png
├── search.gif
├── trash.gif
├── contact.png
├── loading.gif
├── loading.png
├── options.gif
├── reminder.png
├── trash_16.gif
├── triangle.gif
├── close_small.png
├── export_16.gif
├── small_file.png
├── small_job.png
├── small_contact.png
└── small_reminder.png
├── config.yml.example
├── Rakefile
├── tests
├── test.css
└── unit
│ ├── style
│ ├── table_ruler_test.html
│ └── color_test.html
│ ├── windowing
│ ├── contextual_help_test.html
│ ├── fader_test.html
│ ├── busybox_test.html
│ ├── lightbox_test.html
│ └── popinfo_test.html
│ ├── forms
│ ├── textarea_extensions_test.html
│ ├── remote_form_test.html
│ └── select_search_test.html
│ ├── controller_test.html
│ ├── helpers
│ ├── keyboard_helper_test.html
│ ├── forms_helper_test.html
│ └── window_helper_test.html
│ ├── index.html
│ └── storage
│ └── cookie_test.html
├── css
└── azuki.css
├── lib
├── sound.js
├── scriptaculous.js
├── builder.js
├── slider.js
├── unittest.js
└── dragdrop.js
├── README.textile
└── azukilib.js
/.gitignore:
--------------------------------------------------------------------------------
1 | *.swp
2 |
--------------------------------------------------------------------------------
/ruby_libs/base.rb:
--------------------------------------------------------------------------------
1 | module AzukiLib
2 | end
--------------------------------------------------------------------------------
/src/style/table_ruler.js:
--------------------------------------------------------------------------------
1 | /* Not implemented yet */
--------------------------------------------------------------------------------
/images/add.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/add.gif
--------------------------------------------------------------------------------
/images/add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/add.png
--------------------------------------------------------------------------------
/images/job.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/job.png
--------------------------------------------------------------------------------
/images/new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/new.png
--------------------------------------------------------------------------------
/images/no.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/no.gif
--------------------------------------------------------------------------------
/images/ok.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/ok.gif
--------------------------------------------------------------------------------
/images/yes.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/yes.gif
--------------------------------------------------------------------------------
/images/back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/back.png
--------------------------------------------------------------------------------
/images/close.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/close.gif
--------------------------------------------------------------------------------
/images/close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/close.png
--------------------------------------------------------------------------------
/images/error.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/error.gif
--------------------------------------------------------------------------------
/images/export.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/export.gif
--------------------------------------------------------------------------------
/images/feed.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/feed.gif
--------------------------------------------------------------------------------
/images/file.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/file.png
--------------------------------------------------------------------------------
/images/help.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/help.gif
--------------------------------------------------------------------------------
/images/info.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/info.gif
--------------------------------------------------------------------------------
/images/locked.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/locked.gif
--------------------------------------------------------------------------------
/images/logo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/logo.gif
--------------------------------------------------------------------------------
/images/modify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/modify.png
--------------------------------------------------------------------------------
/images/open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/open.png
--------------------------------------------------------------------------------
/images/remove.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/remove.png
--------------------------------------------------------------------------------
/images/saving.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/saving.gif
--------------------------------------------------------------------------------
/images/saving.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/saving.png
--------------------------------------------------------------------------------
/images/search.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/search.gif
--------------------------------------------------------------------------------
/images/trash.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/trash.gif
--------------------------------------------------------------------------------
/images/contact.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/contact.png
--------------------------------------------------------------------------------
/images/loading.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/loading.gif
--------------------------------------------------------------------------------
/images/loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/loading.png
--------------------------------------------------------------------------------
/images/options.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/options.gif
--------------------------------------------------------------------------------
/images/reminder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/reminder.png
--------------------------------------------------------------------------------
/images/trash_16.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/trash_16.gif
--------------------------------------------------------------------------------
/images/triangle.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/triangle.gif
--------------------------------------------------------------------------------
/images/close_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/close_small.png
--------------------------------------------------------------------------------
/images/export_16.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/export_16.gif
--------------------------------------------------------------------------------
/images/small_file.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/small_file.png
--------------------------------------------------------------------------------
/images/small_job.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/small_job.png
--------------------------------------------------------------------------------
/images/small_contact.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/small_contact.png
--------------------------------------------------------------------------------
/images/small_reminder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexyoung/Azukilib/HEAD/images/small_reminder.png
--------------------------------------------------------------------------------
/src/azuki.js:
--------------------------------------------------------------------------------
1 | var Azuki = {
2 | Version: '0.0.1',
3 | Forms: { },
4 | Helpers: { },
5 | Storage: { },
6 | Style: { },
7 | Windowing: { }
8 | };
9 |
10 |
--------------------------------------------------------------------------------
/ruby_libs/init.rb:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 | require 'find'
3 | require 'yaml'
4 | require 'ftools'
5 |
6 | [:options, :base, :compiler, :installer, :config].each do |name|
7 | require File.expand_path(File.dirname(__FILE__) + "/#{name}")
8 | end
9 |
--------------------------------------------------------------------------------
/ruby_libs/options.rb:
--------------------------------------------------------------------------------
1 | module AzukiLib
2 | class Options
3 | @@project_name = nil
4 |
5 | class << self
6 | def image_path ; '/images/azuki/' ; end
7 |
8 | def project_name ; @@project_name ; end
9 | def project_name=(value)
10 | raise "Please specify a project with project=project_name" if value.nil? or value.empty?
11 | @@project_name = value
12 | end
13 | end
14 | end
15 | end
--------------------------------------------------------------------------------
/config.yml.example:
--------------------------------------------------------------------------------
1 | project_1:
2 | project_path: ../project_1/trunk/
3 | css_target: public/stylesheets/screen.css
4 | insert_css: true
5 | javascript_target: public/javascripts/lib/
6 | image_target: public/images/azuki/
7 | image_relative: /images/azuki/
8 | project_2:
9 | project_path: ../project_2/trunk/
10 | css_target: public/stylesheets/screen.css
11 | insert_css: true
12 | javascript_target: public/javascripts/lib/
13 | image_target: public/images/azuki/
14 | image_relative: /images/azuki/
--------------------------------------------------------------------------------
/src/helpers/compatibility_helper.js:
--------------------------------------------------------------------------------
1 | Azuki.Helpers.Compatibility = {
2 | /* Rather than hacking IE's png transparency, we currently use this to switch between gif and png. */
3 | suitable_image_format: function()
4 | {
5 | if (!navigator.appVersion.match(/MSIE/)) return 'png';
6 |
7 | try {
8 | var version = parseFloat(navigator.appVersion.split('MSIE')[1]);
9 | return (version < 7.0) ? 'gif' : 'png';
10 | }
11 | catch (exception) {
12 | return 'png';
13 | }
14 | }
15 | };
16 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | require 'ruby_libs/init'
2 |
3 | include AzukiLib
4 |
5 | namespace :azukilib do
6 | desc "Compiles all of the source files into azukilib.js, removing any extraneous boilerplate comments."
7 | task :compile do
8 | Compiler.generate 'azukilib.js'
9 | end
10 |
11 | desc "Installs the JavaScript, CSS and images into your project"
12 | task :install do
13 | Options.project_name = ENV['project']
14 |
15 | Compiler.generate 'azukilib.js'
16 | Installer.install
17 | end
18 |
19 | desc "Runs the tests"
20 | task :test do
21 | end
22 | end
--------------------------------------------------------------------------------
/ruby_libs/config.rb:
--------------------------------------------------------------------------------
1 | module AzukiLib
2 | class Config
3 | class << self
4 | def [](key)
5 | load_config
6 | @@config[key]
7 | end
8 |
9 | def []=(key, value)
10 | load_config
11 | @@config[key] = value
12 | end
13 |
14 | private
15 |
16 | def load_config
17 | if Options.project_name
18 | @@config ||= YAML.load(File.open('config.yml'))[Options.project_name]
19 | else
20 | @@config = {}
21 | end
22 | rescue Errno::ENOENT
23 | raise Errno::ENOENT, "Please create a config.yml file"
24 | end
25 | end
26 | end
27 | end
--------------------------------------------------------------------------------
/src/storage/cookie.js:
--------------------------------------------------------------------------------
1 | Azuki.Storage.Cookie = {
2 | create: function(name, value, days, path) {
3 | var expires = '';
4 | path = typeof path == 'undefined' ? '/' : path;
5 |
6 | if (days) {
7 | var date = new Date();
8 | date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
9 | expires = "; expires=" + date.toGMTString();
10 | }
11 |
12 | if (name && value) {
13 | document.cookie = name + '=' + escape(value) + expires + '; path=' + path;
14 | }
15 | },
16 |
17 | find: function(name) {
18 | var matches = document.cookie.match(name + '=([^;]*)');
19 | if (matches && matches.length == 2) {
20 | return unescape(matches[1]);
21 | }
22 | },
23 |
24 | destroy: function(name) {
25 | this.create(name, ' ', -1);
26 | }
27 | };
28 |
--------------------------------------------------------------------------------
/tests/test.css:
--------------------------------------------------------------------------------
1 | body { background-color: white; font-family: "Helvetica Neue", Helvetica, sans-serif; padding: 0 4em 2em 4em; margin: 0; font-size: 14px; }
2 |
3 | h1 { font-family: "Helvetica Neue", Helvetica, sans-serif; font-weight: bold; color: #411; }
4 | h2 { color: #292; font-family: "Trebuchet MS", Helvetica, sans-serif; font-size: 2em; margin: 0; padding: 5px 0; letter-spacing: -2px; }
5 | h3 { color: #141; margin: 10px 0 4px 0; padding: 0; font-size: normal}
6 | p { margin: 10px 0 0 0; padding: 0; }
7 | h1 img { margin: 0 0 0 0; padding: 0 0 0 20px; clear: none;}
8 | a { color: #333; text-decoration: none; background-color: #ffc; }
9 | a:hover { background-color: #333; color: white; text-decoration: none; }
10 |
11 | h2.page_title { color: #ff3092; text-align: left;}
12 |
13 | #Busybox { background-color: #000; color: #fff; }
14 | #HelpContainer { background-color: #000; color: #fff; }
15 |
16 | #Logo { float: right; }
--------------------------------------------------------------------------------
/src/windowing/busybox.js:
--------------------------------------------------------------------------------
1 | /* :boilerplate:
2 | Displays a Loading message when control needs to be taken away from the user.
3 | */
4 | Azuki.Windowing.Busybox = {
5 | /* operation can be 'loading', 'saving', etc. depending on the images you've got. */
6 | busy: function(operation) {
7 | this.remove();
8 | var image_format = Azuki.Helpers.Compatibility.suitable_image_format();
9 |
10 | new Insertion.Top(document.body, '
');
11 | Azuki.Helpers.Window.center('Busybox');
12 | $('Busybox').show();
13 | },
14 |
15 | remove: function() {
16 | if ($('Busybox')) $('Busybox').remove();
17 | },
18 |
19 | done: function() {
20 | new Effect.Fade($('Busybox'), { afterFinish: function() { Azuki.Windowing.Busybox.remove(); }});
21 | },
22 |
23 | active: function() {
24 | return $('Busybox') ? true : false;
25 | }
26 | };
27 |
--------------------------------------------------------------------------------
/src/windowing/popinfo.js:
--------------------------------------------------------------------------------
1 | /* :boilerplate:
2 | Tooltip help.
3 |
4 | Examples:
5 |
6 | Azuki.Windowing.PopInfo.display(element, 'Saved')
7 | */
8 |
9 | Azuki.Windowing.PopInfo = {
10 | display: function(element, info, callback) {
11 | var delay = 2000;
12 | var popup_element_id = element.id + '_popup';
13 |
14 | this.remove(popup_element_id);
15 | new Insertion.Before(element, '');
16 |
17 | if (callback) callback(element);
18 |
19 | new Effect.Appear(popup_element_id, { duration: 0.2 });
20 | setTimeout((function() { this.fade_popup(popup_element_id); }.bind(this)), delay);
21 | },
22 |
23 | fade_popup: function(popup_element_id) {
24 | try {
25 | new Effect.Fade(popup_element_id);
26 | setTimeout((function() { this.remove(popup_element_id); }).bind(this), 1000);
27 | }
28 | catch (exception) {
29 | }
30 | },
31 |
32 | remove: function(popup_element_id) {
33 | try {
34 | if ($(popup_element_id)) Element.remove(popup_element_id);
35 | }
36 | catch (exception) {
37 |
38 | }
39 | }
40 | };
41 |
--------------------------------------------------------------------------------
/tests/unit/style/table_ruler_test.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 | AzukiLib test file
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | AzukiLib test file
17 |
18 | Tests for style/table_ruler.js
19 |
20 |
21 |
22 |
23 |
24 |
25 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/forms/select_search.js:
--------------------------------------------------------------------------------
1 | /* :boilerplate:
2 | This class allows a select box to be dynamically searched.
3 | */
4 | Azuki.Forms.SelectSearch = Class.create();
5 | Azuki.Forms.SelectSearch.prototype = {
6 | initialize: function(search_input, search_results) {
7 | this.search_input = $(search_input);
8 | this.search_results = $(search_results);
9 | this.items = this.read_values();
10 |
11 | new Event.observe(this.search_input, 'click', this.clear_search_field.bindAsEventListener(this));
12 | new Event.observe(this.search_input, 'keydown', this.search.bindAsEventListener(this));
13 | },
14 |
15 | clear_search_field: function() {
16 | this.search_input.value = '';
17 | this.items.each(function(option, i) {
18 | this.search_results.options[i] = new Option(option.text, option.value);
19 | }.bind(this));
20 | },
21 |
22 | read_values: function() {
23 | return $A(this.search_results.options).collect(function(option) {
24 | return {value: option.value, text: option.innerHTML};
25 | });
26 | },
27 |
28 | search: function() {
29 | var query = this.search_input.value;
30 | var results = this.items.findAll(function(value) {
31 | return value.text.toLowerCase().match(query.toLowerCase());
32 | });
33 |
34 | this.search_results.options.length = 0;
35 |
36 | results.each(function(option, i) {
37 | this.search_results.options[i] = new Option(option.text, option.value);
38 | }.bind(this));
39 | }
40 | };
41 |
--------------------------------------------------------------------------------
/tests/unit/windowing/contextual_help_test.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 | AzukiLib test file
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | AzukiLib test file
16 |
17 | Tests for windowing/contextual_help.js
18 |
19 |
20 |
21 |
22 |
23 | help
24 |
25 |
26 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/tests/unit/windowing/fader_test.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 | AzukiLib test file
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | AzukiLib test file
16 |
17 | Tests for windowing/fader.js
18 |
19 |
20 |
21 |
22 |
23 |
24 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/tests/unit/forms/textarea_extensions_test.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 | AzukiLib test file
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | AzukiLib test file
15 |
16 | Tests for forms/textarea_extensions.js
17 |
18 |
19 |
20 |
21 |
22 |
23 |
26 |
27 |
28 |
29 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/tests/unit/controller_test.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 | AzukiLib test file
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | AzukiLib test file
15 |
16 | Tests for controller.js
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/css/azuki.css:
--------------------------------------------------------------------------------
1 | /* Busybox */
2 | #Busybox { position: absolute; z-index: 1000; padding: 1em !important; left: 0; top: 0; margin: 0 0 0 0 !important; width: 138px; height: 81px; position: absolute; }
3 |
4 | /* Contextual help */
5 | a.help { margin-left: 1px; padding-left: 16px; background: url('/images/azuki/help.gif') no-repeat left; font-size: 86% !important; background-position: 0; white-space: nowrap; cursor: pointer }
6 | #HelpContainer { width: 500px; z-index: 1001;}
7 | #HelpContent { margin: 4px; padding: 10px; text-align: left; line-height: 1.2; z-index: 101; background-color: #fff; }
8 | #HelpContent h3 { text-align: center; font-size: 120% !important; border-bottom: 1px solid #ccc; margin-top: 0; margin-bottom: 10px; }
9 |
10 | /* Virtual windows */
11 | .popinfo_container { position: absolute; z-index: 1000; padding: 1em !important; left: 0; top: 0; margin: 0 0 0 0 !important; border: 2px solid #999 !important; background-color: #ccc; text-align: center;}
12 | .popinfo_frame { display: block; position: absolute; margin: -3em 0 0 0; width: 10em; z-index: 1; font-size: 12px; }
13 | .popinfo_inner { display: block; position: absolute; z-index: 1; border: solid 1px #999; background-color: #ff8; text-align: center; margin: 0; padding: 4px; color: #000 }
14 | .popinfo_image { display: block; position: absolute; top: 23px; z-index: 1; width: 28px; height: 11px; padding: 0; margin: 0; background: transparent url('/images/azuki/triangle.gif') no-repeat; }
15 |
16 | /* Keyboard shortcuts */
17 | div.accesskey { text-decoration: underline; display: inline; margin: 0; padding: 0;}
18 | span.accesskey { text-decoration: underline; }
19 |
20 | /* Textarea extensions */
21 | .bigger, .smaller { cursor: pointer }
22 |
--------------------------------------------------------------------------------
/tests/unit/windowing/busybox_test.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 | AzukiLib test file
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | AzukiLib test file
17 |
18 | Tests for windowing/busybox.js
19 |
20 |
21 |
22 |
23 |
24 |
25 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/tests/unit/forms/remote_form_test.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 | AzukiLib test file
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | AzukiLib test file
15 |
16 | Tests for forms/remote_form.js
17 |
18 |
19 |
20 |
21 |
22 |
25 |
26 |
27 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/tests/unit/windowing/lightbox_test.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 | AzukiLib test file
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | AzukiLib test file
17 |
18 | Tests for windowing/lightbox.js
19 |
20 |
21 |
22 |
23 |
24 | Link to an image
25 |
26 |
27 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/src/forms/textarea_extensions.js:
--------------------------------------------------------------------------------
1 | /* :boilerplate:
2 | This class provides tools for making textareas more friendly.
3 | */
4 | Azuki.Forms.TextAreaExtensions = Class.create();
5 | Azuki.Forms.TextAreaExtensions.prototype = {
6 | initialize: function() {
7 | this._add_images();
8 |
9 | this.bigger = $$('.bigger');
10 | this.smaller = $$('.smaller');
11 |
12 | // Add event observer to all more buttons
13 | this.bigger.each(function(item) {
14 | Event.observe(item, 'click', this.increase_rows.bindAsEventListener(this));
15 | }.bind(this));
16 |
17 | // Add event observer to all less buttons
18 | this.smaller.each(function(item) {
19 | Event.observe(item, 'click', this.decrease_rows.bindAsEventListener(this));
20 | }.bind(this));
21 | },
22 |
23 | increase_rows: function(e) {
24 | var element = $(Event.element(e));
25 | var textarea = this._get_next_textarea(element);
26 | textarea.rows += 5;
27 | },
28 |
29 | decrease_rows: function(e) {
30 | var element = $(Event.element(e));
31 | var textarea = this._get_next_textarea(element);
32 |
33 | if (textarea.rows >= 5) {
34 | textarea.rows -= 4;
35 | }
36 | },
37 |
38 | /** Private methods **/
39 | _get_next_textarea: function(element) {
40 | var children = $A(element.parentNode.parentNode.childNodes);
41 |
42 | return children.find(function(child) { return child.nodeName == 'TEXTAREA'; });
43 | },
44 |
45 | _add_images: function() {
46 | $$('textarea').each(function(textarea) {
47 | new Insertion.Before(textarea, ' ');
48 | });
49 | }
50 | };
51 |
--------------------------------------------------------------------------------
/ruby_libs/compiler.rb:
--------------------------------------------------------------------------------
1 | module AzukiLib
2 | class Compiler
3 | class << self
4 | def generate(file_name, options = {})
5 | compiler = Compiler.new file_name, options
6 | compiler.read 'src/'
7 | compiler.parse
8 | compiler.save
9 | end
10 | end
11 |
12 | attr_accessor :source
13 |
14 | def initialize(file_name = nil, options = {})
15 | @file_name = file_name
16 | @options = options
17 | end
18 |
19 | def read(directory)
20 | @source = File.open(directory + '/azuki.js').read
21 |
22 | Find.find(directory) do |path|
23 | # Ignore dot files
24 | if path == ?.
25 | Find.prune
26 | elsif File.basename(path) != 'azuki.js' and path.match /\.js$/
27 | @source << "\n/* START #{File.basename(path)} */\n"
28 | @source << File.open(path, 'r').read
29 | @source << "\n/* END #{File.basename(path)} */\n"
30 | end
31 | end
32 | end
33 |
34 | def save
35 | file = File.open(@file_name, 'w')
36 | file << @source
37 | file.close
38 | end
39 |
40 | def parse
41 | remove_boilerplates
42 | replace_image_urls
43 | end
44 |
45 | def remove_boilerplates
46 | # Remove /* :boilerplate: */
47 | inside_boilerplate = false
48 | source = ''
49 |
50 | @source.split("\n").each do |line|
51 | inside_boilerplate = true if line.match %r{/\*} and line.match /:boilerplate:/
52 | source << line + "\n" unless inside_boilerplate
53 | inside_boilerplate = false if line.match %r{\*/}
54 | end
55 |
56 | @source = source
57 | end
58 |
59 | def replace_image_urls
60 | return unless Config['image_relative']
61 | @source.gsub! Options.image_path, Config['image_relative']
62 | end
63 | end
64 | end
--------------------------------------------------------------------------------
/tests/unit/helpers/keyboard_helper_test.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 | AzukiLib test file
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | AzukiLib test file
16 |
17 | Tests for helpers/keyboard_helper.js
18 |
19 |
20 |
21 |
22 |
23 |
24 |
Save
25 |
26 |
27 | Disable
28 | Logo button
29 |
30 |
31 |
32 |
33 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/src/windowing/contextual_help.js:
--------------------------------------------------------------------------------
1 | /* :boilerplate:
2 | Sets up an event that waits for clicks on links with a particular class ('help' is the default.)
3 |
4 | Windows are displayed containing help information using Ajax to load a remote page,
5 | derived from the URL in the link.
6 | */
7 | Azuki.Windowing.ContextualHelp = Class.create();
8 | Azuki.Windowing.ContextualHelp.prototype = {
9 | initialize: function(help_class) {
10 | this.help_class = help_class ? help_class : 'help';
11 |
12 | Event.observe(document, 'click', function(e) {
13 | var element = $(Event.element(e));
14 | if (!element.hasClassName(this.help_class)) return true;
15 | if (element.nodeName != 'A') return true;
16 |
17 | this.display_help(element.href);
18 |
19 | Event.stop(e);
20 | return false;
21 | }.bind(this));
22 | },
23 |
24 | display_help: function(url) {
25 | var image_format = Azuki.Helpers.Compatibility.suitable_image_format();
26 | var faded = Azuki.Windowing.Fader.active();
27 |
28 | if (Azuki.Windowing.Busybox.active()) return;
29 | if ($('HelpContainer')) $('HelpContainer').remove();
30 |
31 | Azuki.Windowing.Busybox.busy('loading');
32 | new Insertion.Top(document.body, '');
33 |
34 | Event.observe($('HelpClose'), 'click', function() { $('HelpContainer').remove(); if (!faded) { Azuki.Windowing.Fader.remove(); } });
35 |
36 | new Ajax.Updater('HelpContent', url, { insertion: Insertion.Bottom, onComplete: function() {
37 | Azuki.Windowing.Busybox.done();
38 | Azuki.Helpers.Window.center('HelpContainer');
39 | if (!faded) Azuki.Windowing.Fader.fade();
40 | new Effect.Appear($('HelpContainer'), {duration: 0.3});
41 | }});
42 | }
43 | };
44 |
--------------------------------------------------------------------------------
/tests/unit/helpers/forms_helper_test.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 | AzukiLib test file
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | AzukiLib test file
15 |
16 | Tests for helpers/forms_helper.js
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | This is a textarea
26 |
27 |
28 |
29 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/lib/sound.js:
--------------------------------------------------------------------------------
1 | // script.aculo.us sound.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007
2 |
3 | // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
4 | //
5 | // Based on code created by Jules Gravinese (http://www.webveteran.com/)
6 | //
7 | // script.aculo.us is freely distributable under the terms of an MIT-style license.
8 | // For details, see the script.aculo.us web site: http://script.aculo.us/
9 |
10 | Sound = {
11 | tracks: {},
12 | _enabled: true,
13 | template:
14 | new Template(' '),
15 | enable: function(){
16 | Sound._enabled = true;
17 | },
18 | disable: function(){
19 | Sound._enabled = false;
20 | },
21 | play: function(url){
22 | if(!Sound._enabled) return;
23 | var options = Object.extend({
24 | track: 'global', url: url, replace: false
25 | }, arguments[1] || {});
26 |
27 | if(options.replace && this.tracks[options.track]) {
28 | $R(0, this.tracks[options.track].id).each(function(id){
29 | var sound = $('sound_'+options.track+'_'+id);
30 | sound.Stop && sound.Stop();
31 | sound.remove();
32 | })
33 | this.tracks[options.track] = null;
34 | }
35 |
36 | if(!this.tracks[options.track])
37 | this.tracks[options.track] = { id: 0 }
38 | else
39 | this.tracks[options.track].id++;
40 |
41 | options.id = this.tracks[options.track].id;
42 | $$('body')[0].insert(
43 | Prototype.Browser.IE ? new Element('bgsound',{
44 | id: 'sound_'+options.track+'_'+options.id,
45 | src: options.url, loop: 1, autostart: true
46 | }) : Sound.template.evaluate(options));
47 | }
48 | };
49 |
50 | if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){
51 | if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('QuickTime') != -1 }))
52 | Sound.template = new Template(' ')
53 | else
54 | Sound.play = function(){}
55 | }
56 |
--------------------------------------------------------------------------------
/src/windowing/fader.js:
--------------------------------------------------------------------------------
1 | /* :boilerplate:
2 | This class provides tools for fading out the page. Use Azuki.Windowing.Fader.fade() to fade out, and
3 | Azuki.Windowing.Fader.remove() to remote it. Azuki.Windowing.Fader.active() returns true when currently faded.
4 |
5 | This is usually used when a dialog box requires the current context.
6 | */
7 | Azuki.Windowing.Fader = {
8 | active: function() {
9 | return $('Fader') ? true : false;
10 | },
11 |
12 | set_height: function() {
13 | $('Fader').setStyle({height: Azuki.Helpers.Window.page_size().height + 'px'});
14 | },
15 |
16 | fade: function() {
17 | new Insertion.Top(document.body, '
');
18 | Position.prepare();
19 | Azuki.Windowing.Fader.set_height();
20 | $('Fader').setOpacity(0);
21 | $('Fader').show(0);
22 | Azuki.Windowing.Fader.alter_selects('hidden');
23 | Azuki.Windowing.Fader.alter_overflows('hidden');
24 | new Effect.Opacity('Fader', {duration: 0, from: 0.7, to: 0.7});
25 | },
26 |
27 | alter_selects: function(visible, selector) {
28 | if (!(/MSIE/.test(navigator.userAgent) && !window.opera)) return;
29 | if (!selector) selector = 'select';
30 |
31 | $$(selector).each(function(element) {
32 | element.setStyle({ visibility: visible });
33 | });
34 | },
35 |
36 | alter_overflows: function(overflow_setting) {
37 | $$('.overflow').each(function(element) {
38 | element.setStyle({ overflow: overflow_setting });
39 | });
40 | },
41 |
42 | remove: function()
43 | {
44 | if (!$('Fader')) return;
45 |
46 | new Effect.Opacity('Fader', {duration: 0.2, from: 0.7, to: 0.0, afterFinish: function() {
47 | if ($('Fader')) $('Fader').remove();
48 | Azuki.Windowing.Fader.alter_selects('visible');
49 | Azuki.Windowing.Fader.alter_overflows('auto');
50 | }});
51 | }
52 | };
53 |
54 | Event.observe(window, 'resize', function() {
55 | if (!$('Fader')) return;
56 | Azuki.Windowing.Fader.set_height();
57 | });
58 |
--------------------------------------------------------------------------------
/tests/unit/index.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 | AzukiLib test file
6 |
7 |
8 |
9 |
10 |
11 |
12 | AzukiLib test suite
13 |
14 | Controller test
15 |
16 |
17 | Forms
18 |
19 |
20 | Remote form test
21 | Select search
22 | Textarea extensions
23 |
24 |
25 | Helpers
26 |
27 |
28 | Forms helper test
29 | Keyboard helper test
30 | Window helper test
31 |
32 |
33 | Style
34 |
35 |
36 | Color test
37 | Table ruler test
38 |
39 |
40 | Windowing
41 |
42 |
43 | Busybox test
44 | Contextual help test
45 | Fader test
46 | Lightbox test
47 | Popinfo test
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/src/helpers/forms_helper.js:
--------------------------------------------------------------------------------
1 | /* :boilerplate:
2 | Disables and activates form controls.
3 | Form controls can be set as disbled in your HTML, then enabled when the DOM is ready here
4 | This prevents people from accessing forms that require JavaScript that aren't ready yet.
5 | */
6 | Azuki.Helpers.Forms = {
7 | /* Text helpers */
8 | set_caret_position: function(element, pos) {
9 | if (element.setSelectionRange) {
10 | element.focus();
11 | element.setSelectionRange(pos, pos);
12 | } else if (element.createTextRange) {
13 | var range = element.createTextRange();
14 |
15 | range.collapse(true);
16 | range.moveEnd('character', pos);
17 | range.moveStart('character', pos);
18 | range.select();
19 | }
20 | },
21 |
22 | get_caret_position: function(element) {
23 | if (element.setSelectionRange) {
24 | return element.selectionStart;
25 | } else if (element.createTextRange) {
26 | // The current selection
27 | var range = document.selection.createRange();
28 | // We'll use this as a 'dummy'
29 | var stored_range = range.duplicate();
30 | // Select all text
31 | stored_range.moveToElementText(element);
32 | // Now move 'dummy' end point to end point of original range
33 | stored_range.setEndPoint('EndToEnd', range);
34 |
35 | return stored_range.text.length - range.text.length;
36 | }
37 | },
38 |
39 | activate_controls: function(names) {
40 | $A(document.getElementsByTagName('input')).each(function(element) {
41 | $A(names).each(function(name) {
42 | if (element.name == name) {
43 | element.disabled = false;
44 | }
45 | });
46 | });
47 | },
48 |
49 | disable_on_submit: function() {
50 | $$('form').each(function(form) {
51 | var submit = $A(form.getElementsByTagName('input')).find(function(input) { return input.type == 'submit'; } );
52 | if (!submit) return;
53 |
54 | Event.observe(form, 'submit', function(e) {
55 | submit = $(submit);
56 | if (submit && !submit.hasClassName('nodisable')) submit.disable();
57 | });
58 | });
59 | }
60 | };
61 |
--------------------------------------------------------------------------------
/tests/unit/forms/select_search_test.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 | AzukiLib test file
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | AzukiLib test file
15 |
16 | Tests for forms/select_search.js
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | One
27 | Two
28 | Three
29 | Four
30 | Five
31 | Six
32 | Seven
33 | Eight
34 |
35 |
36 |
37 |
38 |
39 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/tests/unit/helpers/window_helper_test.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 | AzukiLib test file
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | AzukiLib test file
16 |
17 | Tests for helpers/window_helper.js
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/src/controller.js:
--------------------------------------------------------------------------------
1 | /* :boilerplate:
2 | This class provides tools for treating sections within your site as "Controllers".
3 |
4 | 1. For each section, set a body ID. For example, Account for the account management pages.
5 | Then define a JavaScript class called AccountController. AccountController.run will
6 | automatically be called when people visit that page, OR a class will be instantiated.
7 |
8 | 2. Define a controller called ApplicationController. This gets run before the current
9 | controller, a good place to run anything you need on every page.
10 | */
11 | Azuki.Controller = {
12 | run: function() {
13 | if (document.body.id) Azuki.Controller.run_controller(document.body.id);
14 | Azuki.Controller.run_controller('Application');
15 | },
16 |
17 | run_controller: function(id) {
18 | var controller_class = id + 'Controller';
19 | if (!window[controller_class]) return;
20 |
21 | if (eval(controller_class + '.run')) {
22 | eval(controller_class + '.run()');
23 | } else {
24 | controller = new window[controller_class];
25 | }
26 | }
27 | };
28 |
29 | function init() {
30 | // quit if this function has already been called
31 | if (arguments.callee.done) return;
32 |
33 | // flag this function so we don't do the same thing twice
34 | arguments.callee.done = true;
35 |
36 | // kill the timer
37 | if (_timer) clearInterval(_timer);
38 |
39 | // do stuff
40 | Azuki.Controller.run();
41 | }
42 |
43 | /* for Mozilla/Opera9 */
44 | if (document.addEventListener) {
45 | document.addEventListener("DOMContentLoaded", init, false);
46 | }
47 |
48 | /* for Internet Explorer */
49 | /*@cc_on @*/
50 | /*@if (@_win32)
51 | document.write("
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | AzukiLib test file
17 |
18 | Tests for windowing/popinfo.js
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
73 |
74 |