transit 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/Gemfile +19 -11
  2. data/app/assets/images/transit/icon24x24.png +0 -0
  3. data/app/assets/images/transit/icon24x24_files.png +0 -0
  4. data/app/assets/images/transit/jplayer.swf +0 -0
  5. data/app/assets/images/transit/uploadify.swf +0 -0
  6. data/app/assets/images/transit/video_player.swf +0 -0
  7. data/app/assets/javascripts/jqtools/expose.js +224 -0
  8. data/app/assets/javascripts/jqtools/flashembed.js +300 -0
  9. data/app/assets/javascripts/jqtools/overlay.js +294 -0
  10. data/app/assets/javascripts/jqtools/scrollable.js +3 -0
  11. data/app/assets/javascripts/jqtools/scrollable/autoscroll.js +81 -0
  12. data/app/assets/javascripts/jqtools/scrollable/base.js +335 -0
  13. data/app/assets/javascripts/jqtools/scrollable/navigator.js +139 -0
  14. data/app/assets/javascripts/jqtools/validator.js +590 -0
  15. data/app/assets/javascripts/jqueryui/accordion.js +611 -0
  16. data/app/assets/javascripts/jqueryui/autocomplete.js +612 -0
  17. data/app/assets/javascripts/jqueryui/button.js +388 -0
  18. data/app/assets/javascripts/jqueryui/core.js +312 -0
  19. data/app/assets/javascripts/jqueryui/datepicker.js +1791 -0
  20. data/app/assets/javascripts/jqueryui/dialog.js +878 -0
  21. data/app/assets/javascripts/jqueryui/draggable.js +815 -0
  22. data/app/assets/javascripts/jqueryui/droppable.js +285 -0
  23. data/app/assets/javascripts/jqueryui/effects/blind.js +49 -0
  24. data/app/assets/javascripts/jqueryui/effects/bounce.js +78 -0
  25. data/app/assets/javascripts/jqueryui/effects/clip.js +54 -0
  26. data/app/assets/javascripts/jqueryui/effects/core.js +746 -0
  27. data/app/assets/javascripts/jqueryui/effects/drop.js +50 -0
  28. data/app/assets/javascripts/jqueryui/effects/explode.js +79 -0
  29. data/app/assets/javascripts/jqueryui/effects/fade.js +32 -0
  30. data/app/assets/javascripts/jqueryui/effects/fold.js +56 -0
  31. data/app/assets/javascripts/jqueryui/effects/highlight.js +50 -0
  32. data/app/assets/javascripts/jqueryui/effects/pulsate.js +51 -0
  33. data/app/assets/javascripts/jqueryui/effects/scale.js +178 -0
  34. data/app/assets/javascripts/jqueryui/effects/shake.js +57 -0
  35. data/app/assets/javascripts/jqueryui/effects/slide.js +50 -0
  36. data/app/assets/javascripts/jqueryui/effects/transfer.js +45 -0
  37. data/app/assets/javascripts/jqueryui/mouse.js +160 -0
  38. data/app/assets/javascripts/jqueryui/position.js +252 -0
  39. data/app/assets/javascripts/jqueryui/progressbar.js +109 -0
  40. data/app/assets/javascripts/jqueryui/resizable.js +814 -0
  41. data/app/assets/javascripts/jqueryui/selectable.js +266 -0
  42. data/app/assets/javascripts/jqueryui/slider.js +666 -0
  43. data/app/assets/javascripts/jqueryui/sortable.js +1077 -0
  44. data/app/assets/javascripts/jqueryui/tabs.js +758 -0
  45. data/app/assets/javascripts/jqueryui/widget.js +262 -0
  46. data/app/assets/javascripts/libs/backbone.js +1152 -0
  47. data/app/assets/javascripts/libs/cookie.js +89 -0
  48. data/app/assets/javascripts/libs/fileinput.js +130 -0
  49. data/app/assets/javascripts/libs/jplayer.js +1768 -0
  50. data/app/assets/javascripts/libs/proper.js +541 -0
  51. data/app/assets/javascripts/libs/sanitize.js +282 -0
  52. data/app/assets/javascripts/libs/selecttolist.js +75 -0
  53. data/app/assets/javascripts/libs/underscore.js +807 -0
  54. data/app/assets/javascripts/libs/uploadify.js +677 -0
  55. data/app/assets/javascripts/libs/wymeditor.js +9538 -0
  56. data/app/assets/javascripts/transit.js +4 -0
  57. data/app/assets/javascripts/transit/admin.js +22 -0
  58. data/app/assets/javascripts/transit/admin/contexts.js +52 -0
  59. data/app/assets/javascripts/transit/admin/fields.js +36 -0
  60. data/app/assets/javascripts/transit/admin/upload.js +109 -0
  61. data/app/assets/javascripts/transit/config.js.erb +101 -0
  62. data/app/assets/javascripts/transit/contexts/audio.js +39 -0
  63. data/app/assets/javascripts/transit/contexts/video.js +79 -0
  64. data/app/assets/javascripts/transit/core.js +171 -0
  65. data/app/assets/javascripts/transit/frontend.js +3 -0
  66. data/app/assets/javascripts/transit/lib/base64.js +120 -0
  67. data/app/assets/javascripts/transit/lib/editor.js +177 -0
  68. data/app/assets/javascripts/transit/views/audio_player.jst +22 -0
  69. data/app/assets/javascripts/transit/views/editor_toolbar.jst +12 -0
  70. data/app/assets/javascripts/transit/views/file_upload.jst +5 -0
  71. data/app/assets/javascripts/transit/views/video_player.jst +20 -0
  72. data/app/assets/javascripts/transit/views/wym_box.jst +4 -0
  73. data/app/assets/javascripts/transit/views/wym_iframe.jst +3 -0
  74. data/app/assets/stylesheets/transit.css.scss.erb +42 -0
  75. data/app/assets/stylesheets/transit/forms.css.scss +66 -0
  76. data/app/assets/stylesheets/transit/media/audio.css.scss +65 -0
  77. data/app/assets/stylesheets/transit/media/video.css.scss +30 -0
  78. data/app/assets/stylesheets/transit/panel.css.scss +100 -0
  79. data/app/assets/stylesheets/transit/ui.css.scss +507 -0
  80. data/app/controllers/pages_controller.rb +3 -0
  81. data/app/controllers/posts_controller.rb +3 -0
  82. data/app/controllers/transit/assets_controller.rb +38 -0
  83. data/app/controllers/transit/contexts_controller.rb +12 -9
  84. data/app/controllers/transit/pages_controller.rb +26 -0
  85. data/app/controllers/transit/posts_controller.rb +31 -0
  86. data/app/controllers/transit/topics_controller.rb +5 -0
  87. data/app/controllers/transit_controller.rb +16 -0
  88. data/app/helpers/transit/admin_helper.rb +43 -0
  89. data/app/helpers/transit/form_helper.rb +17 -0
  90. data/app/helpers/transit/package_helper.rb +41 -0
  91. data/app/helpers/transit/pagination_helper.rb +58 -0
  92. data/app/helpers/transit_helper.rb +42 -0
  93. data/app/models/comment.rb +37 -0
  94. data/app/models/contexts/audio.rb +12 -0
  95. data/app/models/{text.rb → contexts/text.rb} +0 -0
  96. data/app/models/contexts/video.rb +24 -0
  97. data/app/models/topic.rb +19 -0
  98. data/app/models/transit/asset.rb +68 -0
  99. data/{lib → app/models}/transit/context.rb +29 -0
  100. data/app/views/contexts/_text.html.erb +1 -1
  101. data/app/views/posts/index.rss.builder +18 -0
  102. data/app/views/transit/assets/_file.html.erb +4 -0
  103. data/app/views/transit/assets/_image.html.erb +13 -0
  104. data/app/views/transit/assets/create.js.erb +8 -0
  105. data/app/views/transit/assets/destroy.js.erb +3 -0
  106. data/app/views/transit/assets/manage.html.erb +20 -0
  107. data/app/views/transit/contexts/_audio.html.erb +18 -0
  108. data/app/views/transit/contexts/_text.html.erb +6 -0
  109. data/app/views/transit/contexts/_video.html.erb +13 -0
  110. data/app/views/transit/contexts/destroy.js.erb +1 -0
  111. data/app/views/transit/contexts/index.html.erb +5 -0
  112. data/app/views/transit/contexts/new.js.erb +7 -0
  113. data/app/views/transit/contexts/show.html.erb +8 -0
  114. data/app/views/transit/index.html.erb +26 -0
  115. data/app/views/transit/index.js.erb +1 -0
  116. data/app/views/transit/interface/post_panel.html.erb +96 -0
  117. data/app/views/transit/pages/_table.html.erb +7 -0
  118. data/app/views/transit/pages/edit.html.erb +17 -0
  119. data/app/views/transit/pages/index.html.erb +17 -0
  120. data/app/views/transit/pages/update.js.erb +1 -0
  121. data/app/views/transit/posts/_form.html.erb +49 -0
  122. data/app/views/transit/posts/edit.html.erb +14 -0
  123. data/app/views/transit/posts/new.html.erb +21 -0
  124. data/app/views/transit/table.html.erb +13 -0
  125. data/app/views/transit/table.js.erb +8 -0
  126. data/app/views/transit/topics/manage.html.erb +28 -0
  127. data/config/locales/en.yml +22 -0
  128. data/config/routes.rb +3 -3
  129. data/lib/transit.rb +51 -17
  130. data/lib/transit/admin.rb +85 -0
  131. data/lib/transit/builders/form_builder.rb +319 -0
  132. data/lib/transit/builders/jst_builder.rb +38 -0
  133. data/lib/transit/builders/package_builder.rb +45 -0
  134. data/lib/transit/config.rb +20 -0
  135. data/lib/transit/controller/generator.rb +42 -0
  136. data/lib/transit/controller/responder.rb +34 -0
  137. data/lib/transit/core_ext.rb +18 -0
  138. data/lib/transit/errors/resource_not_found.rb +6 -0
  139. data/lib/transit/model/assets.rb +14 -0
  140. data/lib/transit/model/attachments.rb +55 -0
  141. data/lib/transit/model/auto_increment.rb +22 -0
  142. data/lib/transit/model/base.rb +56 -0
  143. data/lib/transit/model/comments.rb +19 -0
  144. data/lib/transit/model/hooks.rb +38 -0
  145. data/lib/transit/model/owners.rb +14 -0
  146. data/lib/transit/model/paginator.rb +92 -0
  147. data/lib/transit/model/topics.rb +14 -0
  148. data/lib/transit/package/page.rb +20 -12
  149. data/lib/transit/package/post.rb +87 -33
  150. data/lib/transit/package/post/validations.rb +14 -0
  151. data/lib/transit/rails/engine.rb +29 -13
  152. data/lib/transit/rails/railtie.rb +31 -0
  153. data/lib/transit/rails/routing.rb +11 -6
  154. data/lib/transit/services.rb +13 -0
  155. data/lib/transit/services/base.rb +14 -0
  156. data/lib/transit/services/facebook.rb +13 -0
  157. data/lib/transit/services/ted.rb +10 -0
  158. data/lib/transit/services/twitter.rb +13 -0
  159. data/lib/transit/services/vimeo.rb +10 -0
  160. data/lib/transit/services/you_tube.rb +12 -0
  161. data/lib/transit/version.rb +1 -1
  162. metadata +178 -31
  163. data/app/assets/stylesheets/includes/_compat.scss +0 -24
  164. data/app/assets/stylesheets/includes/_defaults.scss +0 -99
  165. data/app/assets/stylesheets/includes/_global.scss +0 -16
  166. data/app/assets/stylesheets/includes/_imports.scss +0 -27
  167. data/app/assets/stylesheets/includes/_mixins.scss +0 -38
  168. data/app/assets/stylesheets/includes/_setup.scss +0 -85
  169. data/app/assets/stylesheets/layout.css.scss +0 -29
  170. data/app/assets/stylesheets/transit.css +0 -3
  171. data/app/controllers/application_controller.rb +0 -5
  172. data/app/controllers/transit/index_controller.rb +0 -7
  173. data/app/controllers/transit/packages_controller.rb +0 -64
  174. data/app/controllers/transit/transit_controller.rb +0 -4
  175. data/app/helpers/routing_helpers.rb +0 -7
  176. data/app/models/audio.rb +0 -4
  177. data/app/models/package_asset.rb +0 -11
  178. data/app/models/video.rb +0 -8
  179. data/app/views/contexts/_audio.html.erb +0 -1
  180. data/app/views/contexts/_video.html.erb +0 -1
  181. data/app/views/layouts/transit.html.erb +0 -31
  182. data/app/views/transit/index/index.html.erb +0 -0
  183. data/lib/transit/helpers/controller_helpers.rb +0 -40
  184. data/lib/transit/helpers/model_helpers.rb +0 -26
  185. data/lib/transit/package.rb +0 -25
  186. data/lib/transit/package/base.rb +0 -49
@@ -0,0 +1,171 @@
1
+ /**
2
+ * transit.js
3
+ * Copyright (c) 2011 by Brent Kirby / kurb media llc
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the 'Software'), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all
13
+ * copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
23
+
24
+ //= require libs/underscore
25
+ //= require libs/backbone
26
+ //= require_self
27
+ //= require ./lib/base64
28
+
29
+ (function(){
30
+
31
+ var root = this,
32
+ transit = root.transit = {};
33
+
34
+ transit.VERSION = '0.0.1';
35
+ transit.config = {};
36
+
37
+ //
38
+ // Add configuration data
39
+ //
40
+ transit.configure = function( name, conf ){
41
+ var old_conf = this.config[name] || {};
42
+ this.config[name] = jQuery.extend(this.config[name], conf);
43
+ };
44
+
45
+ //
46
+ // Manage editable / viewable contexts.
47
+ //
48
+ transit.context = new function(){
49
+ var cache = [],
50
+ self = this;
51
+
52
+ jQuery.extend(self , {
53
+ // Add a new context
54
+ add: function( name, api ){
55
+ this[ name ] = api;
56
+ cache.push(name);
57
+ return api;
58
+ },
59
+
60
+ exists: function( name ){
61
+ return _.contains( cache, name );
62
+ },
63
+
64
+ // Parse the serialize json data within the
65
+ // element's data-context-options attribute.
66
+ data: function( dom, enc ){
67
+ var element = jQuery(dom),
68
+ cdata = element.data('context-attributes');
69
+
70
+ if( enc == true ) cdata = transit.util.base64.decode( cdata );
71
+ return (new Function("return " + cdata))();
72
+ }
73
+ });
74
+
75
+ };
76
+
77
+ //
78
+ // Shortcut method to jQuery.extend where
79
+ // options are to be updated not overwritten
80
+ //
81
+ transit.merge = function( oldconf, newconf ){
82
+ return jQuery.extend( {}, oldconf, newconf );
83
+ };
84
+
85
+ //
86
+ // The ui api includes various utility functions
87
+ // and functionality like form validation etc.
88
+ //
89
+ transit.ui = {};
90
+
91
+ //
92
+ // Wrapper / helper for underscore's template method.
93
+ // It allows caching of templates, and processing/reprocessing.
94
+ //
95
+ transit.template = (function(){
96
+
97
+ var cache = {},
98
+ parsed = {},
99
+ tpl = function(){
100
+
101
+ // Store a parsed template for later use
102
+ this.store = function( name, data ){
103
+ parsed[name] = this.parse( cache[name], data );
104
+ };
105
+
106
+ // Load a previously parsed template
107
+ this.load = function( name ){
108
+ if( parsed[name] ) return parsed[name];
109
+ else return false;
110
+ };
111
+
112
+ // Load a cached, un-rendered template.
113
+ this.fetch = function( name ){
114
+ if( cache[name] ) return cache[name];
115
+ else return false;
116
+ }
117
+
118
+ // Store a html template in the cache
119
+ // to be parsed later.
120
+ // Returns template object for immediate parsing
121
+ //
122
+ this.add = function( name, html ){
123
+ cache[name] = html;
124
+ return this;
125
+ };
126
+
127
+ // Parse a cached template with supplied data
128
+ this.parse = function( name, data ){
129
+ return _.template( cache[name], data );
130
+ };
131
+
132
+ // Render a template with data immediately, without
133
+ // having previously saved a template.
134
+ this.render = function( html, data ){
135
+ return _.template( html, data );
136
+ };
137
+
138
+ };
139
+
140
+ return new tpl();
141
+
142
+ })();
143
+
144
+ transit.util = {};
145
+
146
+ }).call(this);
147
+
148
+ (function( $, undefined){
149
+
150
+ jQuery.fn.transit = function( method, options ){
151
+
152
+ var exist = jQuery(this).data('transit.' + method );
153
+
154
+ if( exist ){
155
+ if( jQuery.type( options ) == 'string' && jQuery.isFunction( exist[ options ] )){
156
+ return exist[ options ]();
157
+ }else return jQuery(this).data('transit.' + method );
158
+ }
159
+
160
+ if( transit.context.exists( method ) ) {
161
+ jQuery.each(this, function(i, element) {
162
+ var instance = new transit.context[ method ]( jQuery(element), options );
163
+ jQuery(element).data('transit.' + method, instance);
164
+ });
165
+
166
+ return this;
167
+ }
168
+ };
169
+
170
+
171
+ })(jQuery);
@@ -0,0 +1,3 @@
1
+ //= require transit
2
+ //= require transit/lib/base64
3
+ //= require_tree ./contexts
@@ -0,0 +1,120 @@
1
+ (function(transit){
2
+
3
+ var key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
4
+
5
+ transit.util = transit.util || {};
6
+ transit.util.base64 = {};
7
+
8
+ transit.util.base64.encode = function( input ){
9
+ var output = "",
10
+ chr1, chr2, chr3,
11
+ enc1, enc2, enc3, enc4,
12
+ i = 0;
13
+
14
+ input = utf8_encode( input );
15
+
16
+ while (i < input.length) {
17
+ chr1 = input.charCodeAt(i++);
18
+ chr2 = input.charCodeAt(i++);
19
+ chr3 = input.charCodeAt(i++);
20
+ enc1 = chr1 >> 2;
21
+ enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
22
+ enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
23
+ enc4 = chr3 & 63;
24
+
25
+ if( isNaN( chr2 ) ) enc3 = enc4 = 64;
26
+ else if( isNaN( chr3 ) ) enc4 = 64;
27
+
28
+ output = output +
29
+ key.charAt(enc1) +
30
+ key.charAt(enc2) +
31
+ key.charAt(enc3) +
32
+ key.charAt(enc4);
33
+
34
+ }
35
+
36
+ function utf8_encode( string ){
37
+ var utftext = "", n, c;
38
+
39
+ string = string.replace(/\r\n/g,"\n");
40
+
41
+ for ( n = 0; n < string.length; n++ ){
42
+ c = string.charCodeAt(n);
43
+
44
+ if ( c < 128 ) utftext += String.fromCharCode(c);
45
+ else if( (c > 127) && (c < 2048) ){
46
+ utftext += String.fromCharCode((c >> 6) | 192);
47
+ utftext += String.fromCharCode((c & 63) | 128);
48
+ }else {
49
+ utftext += String.fromCharCode((c >> 12) | 224);
50
+ utftext += String.fromCharCode(((c >> 6) & 63) | 128);
51
+ utftext += String.fromCharCode((c & 63) | 128);
52
+ }
53
+ }
54
+ return utftext;
55
+ }
56
+
57
+ return output;
58
+
59
+ };
60
+
61
+ transit.util.base64.decode = function( input ){
62
+ var output = "",
63
+ chr1, chr2, chr3,
64
+ enc1, enc2, enc3, enc4,
65
+ i = 0;
66
+
67
+ input = input.replace( /[^A-Za-z0-9\+\/\=]/g, "" );
68
+
69
+ while( i < input.length ){
70
+ enc1 = key.indexOf(input.charAt(i++));
71
+ enc2 = key.indexOf(input.charAt(i++));
72
+ enc3 = key.indexOf(input.charAt(i++));
73
+ enc4 = key.indexOf(input.charAt(i++));
74
+
75
+ chr1 = (enc1 << 2) | (enc2 >> 4);
76
+ chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
77
+ chr3 = ((enc3 & 3) << 6) | enc4;
78
+
79
+ output = output + String.fromCharCode(chr1);
80
+
81
+ if( enc3 != 64 ) output = output + String.fromCharCode(chr2);
82
+ if( enc4 != 64 ) output = output + String.fromCharCode(chr3);
83
+
84
+ }
85
+
86
+ output = utf8_decode( output );
87
+
88
+ function utf8_decode( textstr ) {
89
+ var string = "",
90
+ i = 0,
91
+ c = c1 = c2 = 0;
92
+
93
+ while( i < textstr.length ){
94
+ c = textstr.charCodeAt(i);
95
+
96
+ if( c < 128 ) {
97
+ string += String.fromCharCode(c);
98
+ i++;
99
+
100
+ }else if( (c > 191) && (c < 224) ) {
101
+ c2 = textstr.charCodeAt(i+1);
102
+ string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
103
+ i += 2;
104
+
105
+ }else {
106
+ c2 = textstr.charCodeAt(i+1);
107
+ c3 = textstr.charCodeAt(i+2);
108
+ string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
109
+ i += 3;
110
+ }
111
+ }
112
+
113
+ return string;
114
+ }
115
+
116
+ return output;
117
+
118
+ };
119
+
120
+ })(transit);
@@ -0,0 +1,177 @@
1
+ //= require transit/views/wym_iframe
2
+ //= require transit/views/wym_box
3
+ //= require transit/views/editor_toolbar
4
+
5
+ (function(transit){
6
+
7
+ var editor, editor_toolbar, proper, active_editor, richtext_buttons;
8
+
9
+ editor = function( element, options ){
10
+ var self = this,
11
+ tag = jQuery(element)[0].tagName;
12
+
13
+ if( (/[h1|h2|h3|h4|h5|h6]/i).test(tag) ) return new editor.inline( jQuery(element), options );
14
+ else return new editor.richtext( jQuery(element), options );
15
+
16
+ return self;
17
+ };
18
+
19
+ proper = new Proper();
20
+ richtext_buttons = {
21
+ bold: { action:'Bold', title:'Bold' },
22
+ italic: { action:'Italic', title:'Italic' },
23
+ underline: { action:'Underline', title:'Underline' },
24
+ undo: { action:'Undo', title:'Undo' },
25
+ redo: { action:'Redo', title:'Redo' },
26
+ ordered_list: { action:'InsertOrderedList', title:'Insert Ordered List' },
27
+ unordered_list: { action:'InsertUnorderedList', title:'Insert Unordered List' },
28
+ insert_link: { title:'Insert Link' },
29
+ unlink: { title:'Unlink', action:'Unlink' },
30
+ insert_image: { title:'Insert Image' }
31
+ };
32
+
33
+ editor_toolbar = function(){
34
+ var content = jQuery(transit.template.parse('transit/views/editor_toolbar', { buttons: richtext_buttons })),
35
+ initialized = false,
36
+ self = this,
37
+ widget;
38
+
39
+ this.init = function( parent ){
40
+ if( initialized ) return true;
41
+ content.find('li a').bind('click', this.exec);
42
+ content.insertBefore( parent );
43
+ initialized = true;
44
+ return true;
45
+ };
46
+
47
+ this.exec = function( event ){
48
+ var btn = jQuery(this), button;
49
+ event.preventDefault();
50
+ if( event.isPropagationStopped() ) return true;
51
+ event.stopPropagation();
52
+
53
+ button = richtext_buttons[ btn.attr('rel') ];
54
+
55
+ if( button.action ) instance.exec( button.action );
56
+ else instance[ btn.attr('rel') ].call();
57
+ return true;
58
+
59
+ };
60
+ };
61
+
62
+
63
+ editor.richtext = function( element, options ){
64
+
65
+ var config = transit.merge(transit.config['richtext'], options),
66
+ editor, initialized = false,
67
+ self = this
68
+ toolbar;
69
+
70
+ config.postInit = setup_instance;
71
+ config.boxHtml = transit.template.parse('transit/views/wym_box', { iframe: WYMeditor.IFRAME });
72
+ config.iframeHtml = transit.template.parse('transit/views/wym_iframe', { frame_index: WYMeditor.INDEX });
73
+
74
+ jQuery(element)
75
+ .wymeditor(config)
76
+ .bind( "transit:update_richtext", update_callback );
77
+
78
+ editor = jQuery.wymeditors(jQuery(element).data('wym_index'));
79
+
80
+ this.exec = function( cmd ){
81
+ editor._exec( cmd );
82
+ return true;
83
+ };
84
+
85
+ this.save = function(){
86
+ editor.update();
87
+ };
88
+
89
+ this.insert_link = function( options ){
90
+ var href = prompt('Enter the URL to link to:'),
91
+ stamp = editor.uniqueStamp(),
92
+ link;
93
+
94
+ editor._exec(WYMeditor.CREATE_LINK, stamp);
95
+ link = jQuery("a[href=" + stamp + "]", editor._doc.body);
96
+ link.attr('href', href);
97
+ };
98
+
99
+ this.insert_image = function( options ){
100
+
101
+ };
102
+
103
+ function setup_instance( wym ){
104
+ if( initialized ) return false;
105
+
106
+ var parentbody = jQuery('body'),
107
+ editorbody = jQuery(wym._doc).find('body'),
108
+ docheight = jQuery(wym._doc).height(),
109
+ iframe = jQuery(wym._iframe),
110
+ box = jQuery(wym._box);
111
+
112
+ editordoc = jQuery(wym._doc);
113
+
114
+ editorbody.css({
115
+ 'font-family': parentbody.css('font-family'),
116
+ 'font-size': parentbody.css('font-size'),
117
+ 'color': parentbody.css('color'),
118
+ 'line-height': parentbody.css("line-height")
119
+ });
120
+
121
+ if( docheight > 400 ) docheight = 400;
122
+
123
+ box.css({ height:docheight });
124
+ iframe.css({ height:'100%' });
125
+
126
+ editordoc.find('body')
127
+ .bind('focus', function(e){
128
+ e.stopPropagation();
129
+ active_editor = self;
130
+ })
131
+ .bind('blur', function(e){
132
+ editor.update();
133
+ });
134
+
135
+ if( wym._index == 0 ) active_editor = self;
136
+
137
+ toolbar = new editor_toolbar();
138
+ toolbar.init( jQuery(wym._box) );
139
+
140
+ initialized = true;
141
+ return true;
142
+ }
143
+
144
+ function update_callback( event, method, options ){
145
+ if( active_editor != self || event.isPropagationStopped() ) return true;
146
+ self[ method ].call( options );
147
+ }
148
+
149
+ };
150
+
151
+ //
152
+ // The inline editor handles editing content within headings.
153
+ // Add the class .transit-editable to the heading, and set its rel attribute
154
+ // to match the form field that is to be updated on change.
155
+ //
156
+ editor.inline = function( element, options ){
157
+
158
+ var target = jQuery('#'+ element.attr('rel')),
159
+ conf = transit.merge({ markup: false, multiline: false }, options);
160
+
161
+ element
162
+ .bind('click', function( event ){
163
+ event.preventDefault();
164
+ proper.activate( element, conf );
165
+ })
166
+ .bind('blur', function( event ){
167
+ if( target.length > 0 ) target.val( proper.content() );
168
+ });
169
+
170
+ if( target.val() == "" ) target.val( element.text() );
171
+
172
+ };
173
+
174
+ transit.context.add('editor', editor);
175
+
176
+
177
+ })(transit);