playmo 0.0.6 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. data/.rspec +2 -0
  2. data/Gemfile +1 -1
  3. data/README.md +9 -45
  4. data/TODO.md +65 -9
  5. data/bin/playmo +6 -0
  6. data/lib/generators/rails/controller_generator.rb +5 -0
  7. data/lib/generators/rails/layout_generator.rb +26 -0
  8. data/lib/generators/rails/scaffold_controller_generator.rb +13 -0
  9. data/lib/generators/rails/templates/controller.rb +11 -0
  10. data/lib/generators/rails/templates/layout.html.erb +46 -0
  11. data/lib/generators/rails/templates/layout.html.haml +26 -0
  12. data/lib/generators/rails/templates/layout.html.slim +26 -0
  13. data/lib/generators/rails/templates/scaffold_controller.rb +56 -0
  14. data/lib/playmo.rb +45 -7
  15. data/lib/playmo/answer.rb +18 -0
  16. data/lib/playmo/choice.rb +52 -0
  17. data/lib/playmo/cli.rb +25 -0
  18. data/lib/playmo/cookbook.rb +83 -0
  19. data/lib/playmo/event.rb +7 -0
  20. data/lib/playmo/options.rb +17 -0
  21. data/lib/playmo/question.rb +59 -0
  22. data/lib/playmo/recipe.rb +50 -0
  23. data/lib/playmo/recipes/_/sample_recipe.rb +46 -0
  24. data/lib/playmo/recipes/application_controller_recipe.rb +24 -0
  25. data/lib/playmo/recipes/application_helper_recipe.rb +18 -0
  26. data/lib/playmo/recipes/assets_recipe.rb +19 -0
  27. data/lib/playmo/recipes/can_can_recipe.rb +0 -0
  28. data/lib/playmo/recipes/capistrano_recipe.rb +25 -0
  29. data/lib/playmo/recipes/compass_recipe.rb +19 -0
  30. data/lib/playmo/recipes/congrats_recipe.rb +20 -0
  31. data/lib/playmo/recipes/devise_recipe.rb +172 -0
  32. data/lib/playmo/recipes/forms_recipe.rb +42 -0
  33. data/lib/playmo/recipes/git_recipe.rb +31 -0
  34. data/lib/playmo/recipes/home_controller_recipe.rb +86 -0
  35. data/lib/playmo/recipes/javascript_framework_recipe.rb +69 -0
  36. data/lib/playmo/recipes/layout_recipe.rb +21 -0
  37. data/lib/playmo/recipes/markup_recipe.rb +34 -0
  38. data/lib/playmo/recipes/rspec_recipe.rb +25 -0
  39. data/lib/playmo/recipes/rvm_recipe.rb +17 -0
  40. data/lib/playmo/recipes/setup_database_recipe.rb +21 -0
  41. data/lib/playmo/recipes/templates/application_controller_recipe/application_controller.rb +54 -0
  42. data/lib/playmo/recipes/templates/application_controller_recipe/internal_error.html.erb +5 -0
  43. data/lib/playmo/recipes/templates/application_controller_recipe/not_found.html.erb +5 -0
  44. data/lib/playmo/recipes/templates/application_helper_recipe/application_helper.rb +118 -0
  45. data/lib/playmo/recipes/templates/assets_recipe/images/bg.jpg +0 -0
  46. data/lib/playmo/recipes/templates/assets_recipe/images/input-bg.gif +0 -0
  47. data/lib/playmo/recipes/templates/assets_recipe/stylesheets/application.css.scss +29 -0
  48. data/lib/playmo/recipes/templates/assets_recipe/stylesheets/media.css.scss +0 -0
  49. data/lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/_constants.css.scss +11 -0
  50. data/lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/_forms.css.scss +134 -0
  51. data/{stylesheets/_playmo_rails.sass → lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/_html5-boilerplate.css.scss} +1 -1
  52. data/lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/_layout.css.scss +264 -0
  53. data/{templates/project/playmo/playmo.scss → lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/_overrides.css.scss} +14 -23
  54. data/lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/_simple_form.css.scss +7 -0
  55. data/{stylesheets/playmo-rails/_fonts.scss → lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/html5-boilerplate/_fonts.css.scss} +5 -6
  56. data/{stylesheets/playmo-rails/_helpers.scss → lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/html5-boilerplate/_helpers.css.scss} +6 -1
  57. data/{stylesheets/playmo-rails/_media.scss → lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/html5-boilerplate/_media.css.scss} +10 -9
  58. data/lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/html5-boilerplate/_reset.css.scss +47 -0
  59. data/{stylesheets/playmo-rails/_styles.scss → lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/html5-boilerplate/_styles.css.scss} +24 -24
  60. data/lib/playmo/recipes/templates/capistrano_recipe/.gitkeep +0 -0
  61. data/lib/playmo/recipes/templates/devise_recipe/.gitkeep +0 -0
  62. data/lib/playmo/recipes/templates/forms_recipe/.gitkeep +0 -0
  63. data/lib/playmo/recipes/templates/home_controller_recipe/_sidebar.html.erb +3 -0
  64. data/lib/playmo/recipes/templates/layout_recipe/application.html.erb +40 -0
  65. data/lib/playmo/recipes/templates/rspec_recipe/.gitkeep +0 -0
  66. data/lib/playmo/recipes/templates/rvm_recipe/.gitkeep +0 -0
  67. data/lib/playmo/silent.rb +17 -0
  68. data/playmo.gemspec +6 -2
  69. data/spec/cookbook_spec.rb +23 -0
  70. data/spec/recipes/home_controller_recipe_spec.rb +13 -0
  71. data/spec/spec_helper.rb +16 -0
  72. data/spec/support/.gitkeep +0 -0
  73. metadata +144 -79
  74. data/lib/app/helpers/playmo_helper.rb +0 -54
  75. data/lib/generators/playmo/USAGE +0 -8
  76. data/lib/generators/playmo/install_generator.rb +0 -166
  77. data/lib/generators/playmo/templates/application.html.erb +0 -56
  78. data/lib/generators/playmo/templates/application_controller.rb +0 -9
  79. data/lib/generators/playmo/templates/application_helper.rb +0 -21
  80. data/lib/generators/playmo/templates/assets.yml +0 -32
  81. data/lib/generators/playmo/templates/deploy.rb +0 -50
  82. data/lib/generators/playmo/templates/jquery/jquery-1.5.2.min.js +0 -16
  83. data/lib/generators/playmo/templates/jquery/rails.js +0 -157
  84. data/lib/generators/playmo/templates/mootools/mootools-core-1.3.1.js +0 -485
  85. data/lib/generators/playmo/templates/mootools/mootools-more-1.3.1.1.js +0 -741
  86. data/lib/generators/playmo/templates/mootools/rails.js +0 -161
  87. data/lib/generators/playmo/templates/tasks/assets.rake +0 -10
  88. data/lib/generators/playmo/templates/tasks/sass.rake +0 -8
  89. data/stylesheets/playmo-rails/_handheld.scss +0 -8
  90. data/stylesheets/playmo-rails/_reset.scss +0 -56
  91. data/templates/project/boilerplate/css/handheld.scss +0 -7
  92. data/templates/project/boilerplate/css/style.scss +0 -141
  93. data/templates/project/boilerplate/files/apple-touch-icon.png +0 -0
  94. data/templates/project/boilerplate/files/crossdomain.xml +0 -25
  95. data/templates/project/boilerplate/files/favicon.ico +0 -0
  96. data/templates/project/boilerplate/files/robots.txt +0 -5
  97. data/templates/project/boilerplate/js/libs/dd_belatedpng.js +0 -13
  98. data/templates/project/boilerplate/js/libs/modernizr-1.7.min.js +0 -2
  99. data/templates/project/google/google.yml +0 -22
  100. data/templates/project/manifest.rb +0 -34
  101. data/templates/project/playmo/article.scss +0 -69
  102. data/templates/project/playmo/icons/outgoing.png +0 -0
  103. data/templates/project/rails/public/stylesheets/layout.scss +0 -20
  104. data/templates/project/rails/public/stylesheets/print.scss +0 -11
  105. data/templates/project/rails/public/stylesheets/screen.scss +0 -14
  106. data/templates/project/rails/public/stylesheets/wysiwyg.scss +0 -19
@@ -1,161 +0,0 @@
1
- /*
2
- ---
3
- description: A MooTools driver for the Ruby on Rails 3 unobtrusive JavaScript API.
4
-
5
- license: MIT-style
6
-
7
- authors:
8
- - Kevin Valdek
9
-
10
- requires:
11
- core/1.3: '*'
12
-
13
- provides:
14
- - Rails 3 MooTools driver
15
-
16
- ...
17
- */
18
-
19
- window.addEvent('domready', function() {
20
-
21
- rails.csrf = {
22
- token: rails.getCsrf('token'),
23
- param: rails.getCsrf('param')
24
- };
25
-
26
- rails.applyEvents();
27
- });
28
-
29
- (function($) {
30
-
31
- window.rails = {
32
- /**
33
- * If el is passed as argument, events will only be applied to
34
- * elements within el. Otherwise applied to document body.
35
- */
36
- applyEvents: function(el) {
37
- el = $(el || document.body);
38
- var apply = function(selector, action, callback) {
39
- el.getElements(selector).addEvent(action, callback);
40
- };
41
-
42
- apply('form[data-remote="true"]', 'submit', rails.handleRemote);
43
- apply('a[data-remote="true"], input[data-remote="true"]', 'click', rails.handleRemote);
44
- apply('a[data-method][data-remote!=true]', 'click', function(e) {
45
- e.preventDefault();
46
- if(rails.confirmed(this)) {
47
- var form = new Element('form', {
48
- method: 'post',
49
- action: this.get('href'),
50
- styles: { display: 'none' }
51
- }).inject(this, 'after');
52
-
53
- var methodInput = new Element('input', {
54
- type: 'hidden',
55
- name: '_method',
56
- value: this.get('data-method')
57
- });
58
-
59
- var csrfInput = new Element('input', {
60
- type: 'hidden',
61
- name: rails.csrf.param,
62
- value: rails.csrf.token
63
- });
64
-
65
- form.adopt(methodInput, csrfInput).submit();
66
- }
67
- });
68
- var noMethodNorRemoteConfirm = ':not([data-method]):not([data-remote=true])[data-confirm]';
69
- apply('a' + noMethodNorRemoteConfirm + ',' + 'input' + noMethodNorRemoteConfirm, 'click', function() {
70
- return rails.confirmed(this);
71
- });
72
- },
73
-
74
- getCsrf: function(name) {
75
- var meta = document.getElement('meta[name=csrf-' + name + ']');
76
- return (meta ? meta.get('content') : null);
77
- },
78
-
79
- confirmed: function(el) {
80
- var confirmMessage = el.get('data-confirm');
81
- if(confirmMessage && !confirm(confirmMessage)) {
82
- return false;
83
- }
84
- return true;
85
- },
86
-
87
- disable: function(el) {
88
- var button = el.get('data-disable-with') ? el : el.getElement('[data-disable-with]');
89
-
90
- if(button) {
91
- var enableWith = button.get('value');
92
- el.addEvent('ajax:complete', function() {
93
- button.set({
94
- value: enableWith,
95
- disabled: false
96
- });
97
- });
98
- button.set({
99
- value: button.get('data-disable-with'),
100
- disabled: true
101
- });
102
- }
103
- },
104
-
105
- handleRemote: function(e) {
106
- e.preventDefault();
107
-
108
- if(rails.confirmed(this)) {
109
- this.request = new Request.Rails(this);
110
- rails.disable(this);
111
- this.request.send();
112
- }
113
- }
114
- };
115
-
116
- Request.Rails = new Class({
117
-
118
- Extends: Request,
119
-
120
- initialize: function(element, options) {
121
- this.el = element;
122
- this.parent(Object.merge({
123
- method: this.el.get('method') || this.el.get('data-method') || 'get',
124
- url: this.el.get('action') || this.el.get('href')
125
- }, options));
126
-
127
- this.addRailsEvents();
128
- },
129
-
130
- send: function(options) {
131
- this.el.fireEvent('ajax:before');
132
- if(this.el.get('tag') == 'form') {
133
- this.options.data = this.el;
134
- }
135
- this.parent(options);
136
- this.el.fireEvent('ajax:after', this.xhr);
137
- },
138
-
139
- addRailsEvents: function() {
140
- this.addEvent('request', function() {
141
- this.el.fireEvent('ajax:loading', this.xhr);
142
- });
143
-
144
- this.addEvent('success', function() {
145
- this.el.fireEvent('ajax:success', this.xhr);
146
- });
147
-
148
- this.addEvent('complete', function() {
149
- this.el.fireEvent('ajax:complete', this.xhr);
150
- this.el.fireEvent('ajax:loaded', this.xhr);
151
- });
152
-
153
- this.addEvent('failure', function() {
154
- this.el.fireEvent('ajax:failure', this.xhr);
155
- });
156
- }
157
-
158
- });
159
-
160
- })(document.id);
161
-
@@ -1,10 +0,0 @@
1
- namespace :compile do
2
- desc 'Compile ans compress application javascripts and stylesheets.'
3
- task :update => :environment do
4
- # Update stylesheets
5
- Rake::Task['sass:update'].execute
6
-
7
- # Pack all assets!
8
- Jammit.package!
9
- end
10
- end
@@ -1,8 +0,0 @@
1
- namespace :sass do
2
- desc 'Updates stylesheets if necessary from their Sass templates.'
3
- task :update => :environment do
4
- sh "rm -rf public/assets/compiled/stylesheets tmp/sass-cache"
5
- Sass::Plugin.options[:never_update] = false
6
- Sass::Plugin.update_stylesheets
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- * {
2
- float: none; // Screens are not big enough to account for floats
3
- background: #fff; // As much contrast as possible */
4
- color: #000;
5
- }
6
-
7
- // Slightly reducing font size to reduce need to scroll
8
- body { font-size: 80%; }
@@ -1,56 +0,0 @@
1
- //
2
- // style.css contains a reset, font normalization and some base styles.
3
- //
4
- // credit is left where credit is due.
5
- // much inspiration was taken from these projects:
6
- // yui.yahooapis.com/2.8.1/build/base/base.css
7
- // camendesign.com/design/
8
- // praegnanz.de/weblog/htmlcssjs-kickstart
9
- //
10
- // html5doctor.com Reset Stylesheet (Eric Meyer's Reset Reloaded + HTML5 baseline)
11
- // v1.6.1 2010-09-17 | Authors: Eric Meyer & Richard Clark
12
- // html5doctor.com/html-5-reset-stylesheet/
13
- //
14
-
15
- @mixin html5-boilerplate-reset {
16
- html, body, div, span, object, iframe,
17
- h1, h2, h3, h4, h5, h6, p, blockquote, pre,
18
- abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp,
19
- small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li,
20
- fieldset, form, label, legend,
21
- table, caption, tbody, tfoot, thead, tr, th, td,
22
- article, aside, canvas, details, figcaption, figure,
23
- footer, header, hgroup, menu, nav, section, summary,
24
- time, mark, audio, video {
25
- margin:0;
26
- padding:0;
27
- border:0;
28
- font-size:100%;
29
- font: inherit;
30
- vertical-align:baseline;
31
- }
32
-
33
- article, aside, details, figcaption, figure,
34
- footer, header, hgroup, menu, nav, section {
35
- display: block;
36
- }
37
-
38
- blockquote, q { quotes: none; }
39
-
40
- blockquote:before, blockquote:after,
41
- q:before, q:after { content:''; content:none; }
42
-
43
- ins { background-color: #ff9; color: #000; text-decoration:none; }
44
-
45
- mark { background-color: #ff9; color: #000; font-style:italic; font-weight:bold; }
46
-
47
- del { text-decoration: line-through; }
48
-
49
- abbr[title], dfn[title] { border-bottom:1px dotted; cursor:help; }
50
-
51
- table { border-collapse:collapse; border-spacing:0; }
52
-
53
- hr { display: block; height:1px; border:0; border-top:1px solid #ccc; margin:1em 0; padding:0; }
54
-
55
- input, select { vertical-align:middle; }
56
- }
@@ -1,7 +0,0 @@
1
- * {
2
- float: none;
3
- background: #fff;
4
- color: #000;
5
- }
6
-
7
- body { font-size: 80%; }
@@ -1,141 +0,0 @@
1
-
2
- /* ==== Scroll down to find where to put your styles :) ==== */
3
-
4
- /* HTML5 ✰ Boilerplate */
5
-
6
- html, body, div, span, object, iframe,
7
- h1, h2, h3, h4, h5, h6, p, blockquote, pre,
8
- abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp,
9
- small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li,
10
- fieldset, form, label, legend,
11
- table, caption, tbody, tfoot, thead, tr, th, td,
12
- article, aside, canvas, details, figcaption, figure,
13
- footer, header, hgroup, menu, nav, section, summary,
14
- time, mark, audio, video {
15
- margin: 0;
16
- padding: 0;
17
- border: 0;
18
- font-size: 100%;
19
- font: inherit;
20
- vertical-align: baseline;
21
- }
22
-
23
- article, aside, details, figcaption, figure,
24
- footer, header, hgroup, menu, nav, section {
25
- display: block;
26
- }
27
-
28
- blockquote, q { quotes: none; }
29
- blockquote:before, blockquote:after,
30
- q:before, q:after { content: ''; content: none; }
31
- ins { background-color: #ff9; color: #000; text-decoration: none; }
32
- mark { background-color: #ff9; color: #000; font-style: italic; font-weight: bold; }
33
- del { text-decoration: line-through; }
34
- abbr[title], dfn[title] { border-bottom: 1px dotted; cursor: help; }
35
- table { border-collapse: collapse; border-spacing: 0; }
36
- hr { display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0; }
37
- input, select { vertical-align: middle; }
38
-
39
- body { font:13px/1.231 sans-serif; *font-size:small; }
40
- select, input, textarea, button { font:99% sans-serif; }
41
- pre, code, kbd, samp { font-family: monospace, sans-serif; }
42
-
43
- html { overflow-y: scroll; }
44
- a:hover, a:active { outline: none; }
45
- ul, ol { margin-left: 2em; }
46
- ol { list-style-type: decimal; }
47
- nav ul, nav li { margin: 0; list-style:none; list-style-image: none; }
48
- small { font-size: 85%; }
49
- strong, th { font-weight: bold; }
50
- td { vertical-align: top; }
51
-
52
- sub, sup { font-size: 75%; line-height: 0; position: relative; }
53
- sup { top: -0.5em; }
54
- sub { bottom: -0.25em; }
55
-
56
- pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; padding: 15px; }
57
- textarea { overflow: auto; }
58
- .ie6 legend, .ie7 legend { margin-left: -7px; }
59
- input[type="radio"] { vertical-align: text-bottom; }
60
- input[type="checkbox"] { vertical-align: bottom; }
61
- .ie7 input[type="checkbox"] { vertical-align: baseline; }
62
- .ie6 input { vertical-align: text-bottom; }
63
- label, input[type="button"], input[type="submit"], input[type="image"], button { cursor: pointer; }
64
- button, input, select, textarea { margin: 0; }
65
- input:valid, textarea:valid { }
66
- input:invalid, textarea:invalid { border-radius: 1px; -moz-box-shadow: 0px 0px 5px red; -webkit-box-shadow: 0px 0px 5px red; box-shadow: 0px 0px 5px red; }
67
- .no-boxshadow input:invalid, .no-boxshadow textarea:invalid { background-color: #f0dddd; }
68
-
69
- ::-moz-selection{ background: #FF5E99; color:#fff; text-shadow: none; }
70
- ::selection { background:#FF5E99; color:#fff; text-shadow: none; }
71
- a:link { -webkit-tap-highlight-color: #FF5E99; }
72
-
73
- button { width: auto; overflow: visible; }
74
- .ie7 img { -ms-interpolation-mode: bicubic; }
75
-
76
- body, select, input, textarea { color: #444; }
77
- h1, h2, h3, h4, h5, h6 { font-weight: bold; }
78
- a, a:active, a:visited { color: #607890; }
79
- a:hover { color: #036; }
80
-
81
- /*
82
- // ========================================== \\
83
- || ||
84
- || Your styles ! ||
85
- || ||
86
- \\ ========================================== //
87
- */
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
- .ir { display: block; text-indent: -999em; overflow: hidden; background-repeat: no-repeat; text-align: left; direction: ltr; }
104
- .hidden { display: none; visibility: hidden; }
105
- .visuallyhidden { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; }
106
- .visuallyhidden.focusable:active,
107
- .visuallyhidden.focusable:focus { clip: auto; height: auto; margin: 0; overflow: visible; position: static; width: auto; }
108
- .invisible { visibility: hidden; }
109
- .clearfix:before, .clearfix:after { content: "\0020"; display: block; height: 0; overflow: hidden; }
110
- .clearfix:after { clear: both; }
111
- .clearfix { zoom: 1; }
112
-
113
-
114
- @media all and (orientation:portrait) {
115
-
116
- }
117
-
118
- @media all and (orientation:landscape) {
119
-
120
- }
121
-
122
- @media screen and (max-device-width: 480px) {
123
-
124
- /* html { -webkit-text-size-adjust:none; -ms-text-size-adjust:none; } */
125
- }
126
-
127
-
128
- @media print {
129
- * { background: transparent !important; color: black !important; text-shadow: none !important; filter:none !important;
130
- -ms-filter: none !important; }
131
- a, a:visited { color: #444 !important; text-decoration: underline; }
132
- a[href]:after { content: " (" attr(href) ")"; }
133
- abbr[title]:after { content: " (" attr(title) ")"; }
134
- .ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after { content: ""; }
135
- pre, blockquote { border: 1px solid #999; page-break-inside: avoid; }
136
- thead { display: table-header-group; }
137
- tr, img { page-break-inside: avoid; }
138
- @page { margin: 0.5cm; }
139
- p, h2, h3 { orphans: 3; widows: 3; }
140
- h2, h3{ page-break-after: avoid; }
141
- }
@@ -1,25 +0,0 @@
1
- <?xml version="1.0"?>
2
- <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
3
- <cross-domain-policy>
4
-
5
-
6
- <!-- Read this: www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html -->
7
-
8
- <!-- Most restrictive policy: -->
9
- <site-control permitted-cross-domain-policies="none"/>
10
-
11
-
12
-
13
- <!-- Least restrictive policy: -->
14
- <!--
15
- <site-control permitted-cross-domain-policies="all"/>
16
- <allow-access-from domain="*" to-ports="*" secure="false"/>
17
- <allow-http-request-headers-from domain="*" headers="*" secure="false"/>
18
- -->
19
- <!--
20
- If you host a crossdomain.xml file with allow-access-from domain=“*”
21
- and don’t understand all of the points described here, you probably
22
- have a nasty security vulnerability. ~ simon willison
23
- -->
24
-
25
- </cross-domain-policy>
@@ -1,5 +0,0 @@
1
- # www.robotstxt.org/
2
- # www.google.com/support/webmasters/bin/answer.py?hl=en&answer=156449
3
-
4
- User-agent: *
5
-
@@ -1,13 +0,0 @@
1
- /**
2
- * DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML <IMG/>.
3
- * Author: Drew Diller
4
- * Email: drew.diller@gmail.com
5
- * URL: http://www.dillerdesign.com/experiment/DD_belatedPNG/
6
- * Version: 0.0.8a
7
- * Licensed under the MIT License: http://dillerdesign.com/experiment/DD_belatedPNG/#license
8
- *
9
- * Example usage:
10
- * DD_belatedPNG.fix('.png_bg'); // argument is a CSS selector
11
- * DD_belatedPNG.fixPng( someNode ); // argument is an HTMLDomElement
12
- **/
13
- var DD_belatedPNG={ns:"DD_belatedPNG",imgSize:{},delay:10,nodesFixed:0,createVmlNameSpace:function(){if(document.namespaces&&!document.namespaces[this.ns]){document.namespaces.add(this.ns,"urn:schemas-microsoft-com:vml")}},createVmlStyleSheet:function(){var b,a;b=document.createElement("style");b.setAttribute("media","screen");document.documentElement.firstChild.insertBefore(b,document.documentElement.firstChild.firstChild);if(b.styleSheet){b=b.styleSheet;b.addRule(this.ns+"\\:*","{behavior:url(#default#VML)}");b.addRule(this.ns+"\\:shape","position:absolute;");b.addRule("img."+this.ns+"_sizeFinder","behavior:none; border:none; position:absolute; z-index:-1; top:-10000px; visibility:hidden;");this.screenStyleSheet=b;a=document.createElement("style");a.setAttribute("media","print");document.documentElement.firstChild.insertBefore(a,document.documentElement.firstChild.firstChild);a=a.styleSheet;a.addRule(this.ns+"\\:*","{display: none !important;}");a.addRule("img."+this.ns+"_sizeFinder","{display: none !important;}")}},readPropertyChange:function(){var b,c,a;b=event.srcElement;if(!b.vmlInitiated){return}if(event.propertyName.search("background")!=-1||event.propertyName.search("border")!=-1){DD_belatedPNG.applyVML(b)}if(event.propertyName=="style.display"){c=(b.currentStyle.display=="none")?"none":"block";for(a in b.vml){if(b.vml.hasOwnProperty(a)){b.vml[a].shape.style.display=c}}}if(event.propertyName.search("filter")!=-1){DD_belatedPNG.vmlOpacity(b)}},vmlOpacity:function(b){if(b.currentStyle.filter.search("lpha")!=-1){var a=b.currentStyle.filter;a=parseInt(a.substring(a.lastIndexOf("=")+1,a.lastIndexOf(")")),10)/100;b.vml.color.shape.style.filter=b.currentStyle.filter;b.vml.image.fill.opacity=a}},handlePseudoHover:function(a){setTimeout(function(){DD_belatedPNG.applyVML(a)},1)},fix:function(a){if(this.screenStyleSheet){var c,b;c=a.split(",");for(b=0;b<c.length;b++){this.screenStyleSheet.addRule(c[b],"behavior:expression(DD_belatedPNG.fixPng(this))")}}},applyVML:function(a){a.runtimeStyle.cssText="";this.vmlFill(a);this.vmlOffsets(a);this.vmlOpacity(a);if(a.isImg){this.copyImageBorders(a)}},attachHandlers:function(i){var d,c,g,e,b,f;d=this;c={resize:"vmlOffsets",move:"vmlOffsets"};if(i.nodeName=="A"){e={mouseleave:"handlePseudoHover",mouseenter:"handlePseudoHover",focus:"handlePseudoHover",blur:"handlePseudoHover"};for(b in e){if(e.hasOwnProperty(b)){c[b]=e[b]}}}for(f in c){if(c.hasOwnProperty(f)){g=function(){d[c[f]](i)};i.attachEvent("on"+f,g)}}i.attachEvent("onpropertychange",this.readPropertyChange)},giveLayout:function(a){a.style.zoom=1;if(a.currentStyle.position=="static"){a.style.position="relative"}},copyImageBorders:function(b){var c,a;c={borderStyle:true,borderWidth:true,borderColor:true};for(a in c){if(c.hasOwnProperty(a)){b.vml.color.shape.style[a]=b.currentStyle[a]}}},vmlFill:function(e){if(!e.currentStyle){return}else{var d,f,g,b,a,c;d=e.currentStyle}for(b in e.vml){if(e.vml.hasOwnProperty(b)){e.vml[b].shape.style.zIndex=d.zIndex}}e.runtimeStyle.backgroundColor="";e.runtimeStyle.backgroundImage="";f=true;if(d.backgroundImage!="none"||e.isImg){if(!e.isImg){e.vmlBg=d.backgroundImage;e.vmlBg=e.vmlBg.substr(5,e.vmlBg.lastIndexOf('")')-5)}else{e.vmlBg=e.src}g=this;if(!g.imgSize[e.vmlBg]){a=document.createElement("img");g.imgSize[e.vmlBg]=a;a.className=g.ns+"_sizeFinder";a.runtimeStyle.cssText="behavior:none; position:absolute; left:-10000px; top:-10000px; border:none; margin:0; padding:0;";c=function(){this.width=this.offsetWidth;this.height=this.offsetHeight;g.vmlOffsets(e)};a.attachEvent("onload",c);a.src=e.vmlBg;a.removeAttribute("width");a.removeAttribute("height");document.body.insertBefore(a,document.body.firstChild)}e.vml.image.fill.src=e.vmlBg;f=false}e.vml.image.fill.on=!f;e.vml.image.fill.color="none";e.vml.color.shape.style.backgroundColor=d.backgroundColor;e.runtimeStyle.backgroundImage="none";e.runtimeStyle.backgroundColor="transparent"},vmlOffsets:function(d){var h,n,a,e,g,m,f,l,j,i,k;h=d.currentStyle;n={W:d.clientWidth+1,H:d.clientHeight+1,w:this.imgSize[d.vmlBg].width,h:this.imgSize[d.vmlBg].height,L:d.offsetLeft,T:d.offsetTop,bLW:d.clientLeft,bTW:d.clientTop};a=(n.L+n.bLW==1)?1:0;e=function(b,p,q,c,s,u){b.coordsize=c+","+s;b.coordorigin=u+","+u;b.path="m0,0l"+c+",0l"+c+","+s+"l0,"+s+" xe";b.style.width=c+"px";b.style.height=s+"px";b.style.left=p+"px";b.style.top=q+"px"};e(d.vml.color.shape,(n.L+(d.isImg?0:n.bLW)),(n.T+(d.isImg?0:n.bTW)),(n.W-1),(n.H-1),0);e(d.vml.image.shape,(n.L+n.bLW),(n.T+n.bTW),(n.W),(n.H),1);g={X:0,Y:0};if(d.isImg){g.X=parseInt(h.paddingLeft,10)+1;g.Y=parseInt(h.paddingTop,10)+1}else{for(j in g){if(g.hasOwnProperty(j)){this.figurePercentage(g,n,j,h["backgroundPosition"+j])}}}d.vml.image.fill.position=(g.X/n.W)+","+(g.Y/n.H);m=h.backgroundRepeat;f={T:1,R:n.W+a,B:n.H,L:1+a};l={X:{b1:"L",b2:"R",d:"W"},Y:{b1:"T",b2:"B",d:"H"}};if(m!="repeat"||d.isImg){i={T:(g.Y),R:(g.X+n.w),B:(g.Y+n.h),L:(g.X)};if(m.search("repeat-")!=-1){k=m.split("repeat-")[1].toUpperCase();i[l[k].b1]=1;i[l[k].b2]=n[l[k].d]}if(i.B>n.H){i.B=n.H}d.vml.image.shape.style.clip="rect("+i.T+"px "+(i.R+a)+"px "+i.B+"px "+(i.L+a)+"px)"}else{d.vml.image.shape.style.clip="rect("+f.T+"px "+f.R+"px "+f.B+"px "+f.L+"px)"}},figurePercentage:function(d,c,f,a){var b,e;e=true;b=(f=="X");switch(a){case"left":case"top":d[f]=0;break;case"center":d[f]=0.5;break;case"right":case"bottom":d[f]=1;break;default:if(a.search("%")!=-1){d[f]=parseInt(a,10)/100}else{e=false}}d[f]=Math.ceil(e?((c[b?"W":"H"]*d[f])-(c[b?"w":"h"]*d[f])):parseInt(a,10));if(d[f]%2===0){d[f]++}return d[f]},fixPng:function(c){c.style.behavior="none";var g,b,f,a,d;if(c.nodeName=="BODY"||c.nodeName=="TD"||c.nodeName=="TR"){return}c.isImg=false;if(c.nodeName=="IMG"){if(c.src.toLowerCase().search(/\.png$/)!=-1){c.isImg=true;c.style.visibility="hidden"}else{return}}else{if(c.currentStyle.backgroundImage.toLowerCase().search(".png")==-1){return}}g=DD_belatedPNG;c.vml={color:{},image:{}};b={shape:{},fill:{}};for(a in c.vml){if(c.vml.hasOwnProperty(a)){for(d in b){if(b.hasOwnProperty(d)){f=g.ns+":"+d;c.vml[a][d]=document.createElement(f)}}c.vml[a].shape.stroked=false;c.vml[a].shape.appendChild(c.vml[a].fill);c.parentNode.insertBefore(c.vml[a].shape,c)}}c.vml.image.shape.fillcolor="none";c.vml.image.fill.type="tile";c.vml.color.fill.on=false;g.attachHandlers(c);g.giveLayout(c);g.giveLayout(c.offsetParent);c.vmlInitiated=true;g.applyVML(c)}};try{document.execCommand("BackgroundImageCache",false,true)}catch(r){}DD_belatedPNG.createVmlNameSpace();DD_belatedPNG.createVmlStyleSheet();