common_interface 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. data/Rakefile +66 -0
  2. data/lib/common_interface.rb +39 -0
  3. data/lib/common_interface/README.md +51 -0
  4. data/lib/common_interface/demo/basic.rb +96 -0
  5. data/lib/common_interface/demo/site.rb +10 -0
  6. data/lib/common_interface/demo/view_helper.rb +17 -0
  7. data/lib/common_interface/public/common_interface/asset_packages.yml +89 -0
  8. data/lib/common_interface/public/common_interface/images/img1.jpg +0 -0
  9. data/lib/common_interface/public/common_interface/images/img1_200.jpg +0 -0
  10. data/lib/common_interface/public/common_interface/images/img1_icon.jpg +0 -0
  11. data/lib/common_interface/public/common_interface/images/img1_thumb.jpg +0 -0
  12. data/lib/common_interface/public/common_interface/images/img2.jpg +0 -0
  13. data/lib/common_interface/public/common_interface/images/img2_200.jpg +0 -0
  14. data/lib/common_interface/public/common_interface/images/img2_icon.jpg +0 -0
  15. data/lib/common_interface/public/common_interface/images/img2_thumb.jpg +0 -0
  16. data/lib/common_interface/public/common_interface/images/img3.jpg +0 -0
  17. data/lib/common_interface/public/common_interface/images/img3_200.jpg +0 -0
  18. data/lib/common_interface/public/common_interface/images/img3_icon.jpg +0 -0
  19. data/lib/common_interface/public/common_interface/images/img3_thumb.jpg +0 -0
  20. data/lib/common_interface/public/common_interface/images/video_icon.png +0 -0
  21. data/lib/common_interface/public/common_interface/js/aspects.js +0 -0
  22. data/lib/common_interface/public/common_interface/js/basic.js +229 -0
  23. data/lib/common_interface/public/common_interface/js/files_upload.js +115 -0
  24. data/lib/common_interface/public/common_interface/js/items.js +118 -0
  25. data/lib/common_interface/public/common_interface/js/style.js +50 -0
  26. data/lib/common_interface/public/common_interface/lib/jquery.elastic.js +117 -0
  27. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/blank.gif +0 -0
  28. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_close.png +0 -0
  29. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_loading.png +0 -0
  30. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_nav_left.png +0 -0
  31. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_nav_right.png +0 -0
  32. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_shadow_e.png +0 -0
  33. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_shadow_n.png +0 -0
  34. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_shadow_ne.png +0 -0
  35. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_shadow_nw.png +0 -0
  36. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_shadow_s.png +0 -0
  37. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_shadow_se.png +0 -0
  38. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_shadow_sw.png +0 -0
  39. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_shadow_w.png +0 -0
  40. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_title_left.png +0 -0
  41. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_title_main.png +0 -0
  42. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_title_over.png +0 -0
  43. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_title_right.png +0 -0
  44. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancybox-x.png +0 -0
  45. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancybox-y.png +0 -0
  46. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancybox.png +0 -0
  47. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/jquery.easing-1.3.pack.js +72 -0
  48. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/jquery.fancybox-1.3.1.js +1077 -0
  49. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/jquery.fancybox.css +363 -0
  50. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/jquery.fancybox.js +44 -0
  51. data/lib/common_interface/public/common_interface/lib/jquery.fancybox/jquery.mousewheel-3.0.2.pack.js +13 -0
  52. data/lib/common_interface/public/common_interface/lib/jquery.form.js +660 -0
  53. data/lib/common_interface/public/common_interface/lib/jquery.hoverIntent.js +111 -0
  54. data/lib/common_interface/public/common_interface/lib/jquery.jgrowl/jquery.jgrowl.css +128 -0
  55. data/lib/common_interface/public/common_interface/lib/jquery.jgrowl/jquery.jgrowl.js +307 -0
  56. data/lib/common_interface/public/common_interface/lib/jquery.js +4376 -0
  57. data/lib/common_interface/public/common_interface/lib/jquery.json.js +178 -0
  58. data/lib/common_interface/public/common_interface/lib/jquery.swfupload/cancel.png +0 -0
  59. data/lib/common_interface/public/common_interface/lib/jquery.swfupload/jquery.swfupload.js +64 -0
  60. data/lib/common_interface/public/common_interface/lib/jquery.swfupload/style.css +8 -0
  61. data/lib/common_interface/public/common_interface/lib/jquery.swfupload/swfupload/swfupload.js +980 -0
  62. data/lib/common_interface/public/common_interface/lib/jquery.swfupload/swfupload/swfupload.queue.js +98 -0
  63. data/lib/common_interface/public/common_interface/lib/jquery.swfupload/swfupload/swfupload.swf +0 -0
  64. data/lib/common_interface/public/common_interface/lib/jquery.swfupload/swfupload/wdp_buttons_upload_61x22.png +0 -0
  65. data/lib/common_interface/public/common_interface/lib/jquery.template.js +255 -0
  66. data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  67. data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  68. data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_flat_10_000000_40x100.png +0 -0
  69. data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  70. data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  71. data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  72. data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  73. data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  74. data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  75. data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-icons_222222_256x240.png +0 -0
  76. data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-icons_228ef1_256x240.png +0 -0
  77. data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-icons_ef8c08_256x240.png +0 -0
  78. data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-icons_ffd27a_256x240.png +0 -0
  79. data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-icons_ffffff_256x240.png +0 -0
  80. data/lib/common_interface/public/common_interface/lib/jquery.ui/jquery.ui.css +406 -0
  81. data/lib/common_interface/public/common_interface/lib/jquery.ui/jquery.ui.js +71 -0
  82. data/lib/common_interface/public/common_interface/themes/default/_aspects.scss +58 -0
  83. data/lib/common_interface/public/common_interface/themes/default/_basic.scss +228 -0
  84. data/lib/common_interface/public/common_interface/themes/default/_components.scss +151 -0
  85. data/lib/common_interface/public/common_interface/themes/default/_custom_reset.scss +12 -0
  86. data/lib/common_interface/public/common_interface/themes/default/_elastic.scss +72 -0
  87. data/lib/common_interface/public/common_interface/themes/default/_items.scss +88 -0
  88. data/lib/common_interface/public/common_interface/themes/default/_mixins.scss +39 -0
  89. data/lib/common_interface/public/common_interface/themes/default/_special.scss +34 -0
  90. data/lib/common_interface/public/common_interface/themes/default/_variables.scss +15 -0
  91. data/lib/common_interface/public/common_interface/themes/default/_yui_reset.scss +127 -0
  92. data/lib/common_interface/public/common_interface/themes/default/elastic.js +307 -0
  93. data/lib/common_interface/public/common_interface/themes/default/elastic.print.css +8 -0
  94. data/lib/common_interface/public/common_interface/themes/default/reset.css +157 -0
  95. data/lib/common_interface/public/common_interface/themes/default/reset.scss +5 -0
  96. data/lib/common_interface/public/common_interface/themes/default/style.css +580 -0
  97. data/lib/common_interface/public/common_interface/themes/default/style.js +84 -0
  98. data/lib/common_interface/public/common_interface/themes/default/style.scss +11 -0
  99. data/lib/common_interface/public/common_interface/themes/simple_organization/_fixes.scss +130 -0
  100. data/lib/common_interface/public/common_interface/themes/simple_organization/_original.scss +852 -0
  101. data/lib/common_interface/public/common_interface/themes/simple_organization/img/comment-arrow.gif +0 -0
  102. data/lib/common_interface/public/common_interface/themes/simple_organization/img/comment-gravatar.gif +0 -0
  103. data/lib/common_interface/public/common_interface/themes/simple_organization/img/comment-reply.gif +0 -0
  104. data/lib/common_interface/public/common_interface/themes/simple_organization/img/logo-small.gif +0 -0
  105. data/lib/common_interface/public/common_interface/themes/simple_organization/img/logo.gif +0 -0
  106. data/lib/common_interface/public/common_interface/themes/simple_organization/img/main-two-columns-left.gif +0 -0
  107. data/lib/common_interface/public/common_interface/themes/simple_organization/img/main-two-columns.gif +0 -0
  108. data/lib/common_interface/public/common_interface/themes/simple_organization/img/sample-event.jpg +0 -0
  109. data/lib/common_interface/public/common_interface/themes/simple_organization/img/sample-gravatar.gif +0 -0
  110. data/lib/common_interface/public/common_interface/themes/simple_organization/img/sample-image.jpg +0 -0
  111. data/lib/common_interface/public/common_interface/themes/simple_organization/img/sample-thumbnail.jpg +0 -0
  112. data/lib/common_interface/public/common_interface/themes/simple_organization/original/archives.html +389 -0
  113. data/lib/common_interface/public/common_interface/themes/simple_organization/original/comments.html +486 -0
  114. data/lib/common_interface/public/common_interface/themes/simple_organization/original/empty-page.html +107 -0
  115. data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/comment-arrow.gif +0 -0
  116. data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/comment-gravatar.gif +0 -0
  117. data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/comment-reply.gif +0 -0
  118. data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/logo-small.gif +0 -0
  119. data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/logo.gif +0 -0
  120. data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/main-two-columns-left.gif +0 -0
  121. data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/main-two-columns.gif +0 -0
  122. data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/sample-event.jpg +0 -0
  123. data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/sample-gravatar.gif +0 -0
  124. data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/sample-image.jpg +0 -0
  125. data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/sample-thumbnail.jpg +0 -0
  126. data/lib/common_interface/public/common_interface/themes/simple_organization/original/index.html +307 -0
  127. data/lib/common_interface/public/common_interface/themes/simple_organization/original/left-sidebar.html +307 -0
  128. data/lib/common_interface/public/common_interface/themes/simple_organization/original/no-subnavigation.html +290 -0
  129. data/lib/common_interface/public/common_interface/themes/simple_organization/original/single-column.html +209 -0
  130. data/lib/common_interface/public/common_interface/themes/simple_organization/original/style-demo.html +355 -0
  131. data/lib/common_interface/public/common_interface/themes/simple_organization/original/style.css +658 -0
  132. data/lib/common_interface/public/common_interface/themes/simple_organization/style.css +965 -0
  133. data/lib/common_interface/public/common_interface/themes/simple_organization/style.scss +2 -0
  134. data/lib/common_interface/public/common_interface/themes/simple_organization/tmp/comments.html +486 -0
  135. data/lib/common_interface/public/common_interface/themes/simple_organization/tmp/tmp.html +307 -0
  136. data/lib/common_interface/tmp/html.html +39 -0
  137. data/lib/common_interface/tmp/js.js +78 -0
  138. data/lib/common_interface/view_helper.rb +52 -0
  139. data/readme.md +49 -0
  140. data/spec/basic_spec.rb +63 -0
  141. data/spec/helper.rb +8 -0
  142. data/spec/spec.opts +4 -0
  143. metadata +221 -0
@@ -0,0 +1,115 @@
1
+ // Files Upload
2
+ (function($){
3
+ FilesUpload = function(params, opt){
4
+ this.params = params;
5
+ this.opt = opt;
6
+
7
+ var _this = this;
8
+ $.callOnceAfterUpdate('file_upload', function(){_this.initialize()});
9
+ };
10
+ var _this = FilesUpload;
11
+
12
+ _this.prototype = {
13
+ initialize: function(){
14
+ var _this = this;
15
+
16
+ // Escape params
17
+ var params = $.extend({format: 'js', authenticity_token: $.authenticity_token}, this.params)
18
+
19
+ // Initialize flash
20
+ var content = $('._upload_dialog');
21
+ var flashHolder = content.find('._flash_holder');
22
+
23
+ var upload_url = decode_uri(this.opt.upload_url);
24
+ upload_url = (upload_url.indexOf('?') >= 0) ? (upload_url + '&'+$.param(params)) : (upload_url + '?'+$.param(params));
25
+
26
+ var flash_params = {
27
+ upload_url: upload_url,
28
+ file_post_name: 'file[file]',
29
+ // file_size_limit : "1024",
30
+ // file_types : "*.jpg;*.png;*.gif",
31
+ // file_types_description : "Image files",
32
+ file_upload_limit : 20,
33
+ flash_url : '/common_interface/lib/jquery.swfupload/swfupload/swfupload.swf',
34
+
35
+ button_text : this.opt.select_files,
36
+ // button_image_url : sm.serviceUrl('/plugins/jquery.swfupload/swfupload/wdp_buttons_upload_61x22.png'),
37
+
38
+ // button_text : '<span class="btnText">Select Files...</span>',
39
+ // button_text_style : ".btnText { font-size: 10; font-weight: bold; font-family: MS Shell Dlg; }",
40
+ // button_text_top_padding : 3,
41
+ // button_text_left_padding : 100,
42
+
43
+ button_width : 61,
44
+ button_height : 22,
45
+ button_placeholder : content.find('._flash_holder')[0],
46
+ prevent_swf_caching: false,
47
+ debug: false
48
+ };
49
+
50
+ var flash_wrapper = flashHolder.swfupload(flash_params);
51
+
52
+ flash_wrapper
53
+ .bind('fileQueued', function(event, file){
54
+ var params = $.extend({}, file, {
55
+ size_in_kb: Math.round(file.size/1024)
56
+ })
57
+
58
+ var t = $.template(content.find('._file_progress_template').val())
59
+ content.find('._queue').append(t, params);
60
+ var fileItem = content.find('._file_'+file.id)
61
+ fileItem.find('._cancel').bind('click', function(){
62
+ // var swfu = $.swfupload.getInstance(vp.wiget + ' ._flash_holder');
63
+ flashHolder.swfupload('cancelUpload', file.id);
64
+ fileItem.slideUp('fast');
65
+ });
66
+ // start the upload since it's queued
67
+ // $(this).swfupload('startUpload');
68
+ })
69
+ .bind('fileQueueError', function(event, file, errorCode, message){
70
+ alert('Size of the file '+file.name+' is greater than limit');
71
+ })
72
+ // .bind('fileDialogComplete', function(event, numFilesSelected, numFilesQueued){
73
+ // $('#queuestatus').text('Files Selected: '+numFilesSelected+' / Queued Files: '+numFilesQueued);
74
+ // })
75
+ .bind('uploadStart', function(event, file){
76
+ var fileItem = content.find('._queue ._file_' + file.id)
77
+ fileItem.find('._progressvalue').text('0%');
78
+ fileItem.find('._cancel').hide();
79
+ })
80
+ .bind('uploadProgress', function(event, file, bytesLoaded){
81
+ var percentage=Math.round((bytesLoaded/file.size)*100);
82
+ var fileItem = content.find('._queue ._file_' + file.id)
83
+ fileItem.find('._progress').css('width', percentage+'%');
84
+ fileItem.find('._progressvalue').text(percentage+'%');
85
+ })
86
+ .bind('uploadSuccess', function(event, file, data){
87
+ var fileItem = content.find('._queue ._file_' + file.id);
88
+ fileItem.find('._progress').css('width', '100%');
89
+ fileItem.find('._progressvalue').text('100%');
90
+ fileItem.slideUp('fast');
91
+
92
+ data = data.replace('<textarea>', '').replace('</textarea>', '');
93
+ eval(data.toString());
94
+ $.refresh_js_css();
95
+ })
96
+ // .bind('uploadComplete', function(event, file){
97
+ // })
98
+ .bind('queueComplete', function(){
99
+ // $.ajax({
100
+ // data: $.param({format: 'js'}),
101
+ // dataType: 'script',
102
+ // type: 'get',
103
+ // url: _this.opt.refresh_url
104
+ // });
105
+ $('._dialog').remove();
106
+ });
107
+
108
+ // 'Upload' button
109
+ content.find('._upload').click(function(){
110
+ flashHolder.swfupload('startUpload');
111
+ return false;
112
+ });
113
+ }
114
+ }
115
+ })(jQuery);
@@ -0,0 +1,118 @@
1
+ //
2
+ // List
3
+ //
4
+ $.callOnceForEvery('list', '._list', function(){
5
+ var maxFinishedTasks = 3;
6
+
7
+ var list = $(this);
8
+ var container = list.find('._container:first');
9
+ var show_more = list.find('._show_more');
10
+ var show_less = list.find('._show_less');
11
+ var hidden_tasks = list.find('._hidden_tasks');
12
+
13
+ // Hide Finished Tasks if ther's more than 3
14
+ var hide_tasks = function(){
15
+ var lastNotFinishedTask = container.find('> ._item:not(._finished):last');
16
+ if(!lastNotFinishedTask.blank()){
17
+ var tasks = container.find('> ._item');
18
+ var lastNotFinishedTaskIndex = tasks.index(lastNotFinishedTask);
19
+ var finishedTasks = tasks.slice(lastNotFinishedTaskIndex, -1);
20
+
21
+ if(finishedTasks.size() > maxFinishedTasks){
22
+ show_more.show();
23
+ var tasksToHide = tasks.slice(lastNotFinishedTaskIndex + maxFinishedTasks, -1);
24
+ tasksToHide.remove().appendTo(hidden_tasks);
25
+ }
26
+ }
27
+ };
28
+ hide_tasks();
29
+
30
+
31
+ // Initialize more/less buttons
32
+ show_more.click(function(){
33
+ hidden_tasks.find('._item').appendTo(list.find('._container'));
34
+ show_more.hide();
35
+ show_less.show();
36
+ return false;
37
+ });
38
+
39
+ show_less.click(function(){
40
+ hide_tasks();
41
+ show_less.hide();
42
+ return false;
43
+ });
44
+ });
45
+
46
+
47
+ //
48
+ // Sortable
49
+ //
50
+ $.callAfterUpdate('sortable', function(){
51
+ $('._sortable_container').each(function(){
52
+ var container = $(this);
53
+ var opt = {
54
+ item_class: container.dataAttr('item_class'),
55
+ update_order_url: container.dataAttr('update_order_url')
56
+ };
57
+
58
+ container = container.find('._container').not(container.find('._container ._container'));
59
+
60
+ container.sortable({
61
+ handle: '._handle',
62
+ items: '> .' + opt.item_class,
63
+ update: function(event, ui) {
64
+ var item = $(ui.item);
65
+ var index = container.find('.' + opt.item_class).index(item);
66
+ // var url = page.dataAttr('container_order_url')
67
+ if(opt.update_order_url){
68
+ $.post(opt.update_order_url, {index: index, item_id: item.attr('id')})
69
+ }else{
70
+ log("Item '" + item.identify() + "' moved to position '" + index + "'.")
71
+ };
72
+ }
73
+ });
74
+ });
75
+ });
76
+
77
+
78
+ //
79
+ // Folder
80
+ //
81
+ // Image View Box
82
+ $.callOnceForEvery('folder_image_box', '._folder', function(){
83
+ var folder = $(this);
84
+ var links = folder.find('a._image_box');
85
+ links.attr('rel', 'images');
86
+ links.fancybox();
87
+ });
88
+
89
+ //
90
+ // Page
91
+ //
92
+ // Toolbars
93
+ $.callAfterUpdate('page_toolbar', function(){
94
+ $('._page').each(function(){
95
+ var page = $(this);
96
+ var container = page.find('._container').first();
97
+
98
+ container.find('._toolbar').remove();
99
+
100
+ var toolbar_html = page.find('._toolbar_template').val();
101
+ container.find('> ._item:visible, > ._inplace').each(function(){
102
+ $(this).after(toolbar_html);
103
+ });
104
+ container.prepend(toolbar_html);
105
+ });
106
+ }, 1);
107
+
108
+
109
+ //
110
+ // Checkbox
111
+ //
112
+ // Onclick
113
+ $.callOnceForEvery('onclick_for_checkbox', '._onclick_checkbox', function(){
114
+ var checkbox = $(this);
115
+ checkbox.click(function(){
116
+ $.ajax({data: $.param({target: checkbox.identify()}), type: 'post', url: checkbox.dataAttr('url')});
117
+ });
118
+ });
@@ -0,0 +1,50 @@
1
+ //
2
+ // Images by default should be alligned to the left (wrapped inside .left div)
3
+ //
4
+ $.callOnceForEvery('left_img_allign', '._markup', function(){
5
+ var markup = $(this);
6
+ var imagesWithoutDiv = markup.find('img').not(markup.find('div img'));
7
+ imagesWithoutDiv.each(function(){
8
+ var e = $(this);
9
+ // image can be wrapped inside link
10
+ while(true){
11
+ var parent = e.parent();
12
+ if(parent.hasClass('_markup') || !(parent.is('a') || parent.is('div') || parent.is('span'))) break;
13
+ e = parent;
14
+ }
15
+ e.wrap($("<div class='left'></div>"));
16
+ });
17
+ });
18
+
19
+
20
+ //
21
+ // Image Box inside Markup
22
+ //
23
+ $.callOnceForEvery('markup_image_box', '._markup', function(){
24
+ var markup = $(this);
25
+
26
+ // Images
27
+ markup.find('a:has(img)').not('._video').not('._nobox').attr('rel', 'images').fancybox();
28
+
29
+ // Videos
30
+ markup.find('a._video').click(function() {
31
+ $.fancybox({
32
+ 'padding' : 0,
33
+ // 'autoScale' : false,
34
+ 'transitionIn': 'none',
35
+ 'transitionOut': 'none',
36
+ 'title': this.title,
37
+ // 'width' : 680,
38
+ // 'height' : 495,
39
+ 'href': this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
40
+ // 'href' : "http://www.youtube.com/watch?v=M-cIjPOJdFM&amp;fs=1".replace(new RegExp("watch\\?v=", "i"), 'v/'),
41
+ 'type': 'swf',
42
+ 'swf': {
43
+ 'wmode': 'transparent',
44
+ 'allowfullscreen' : 'true'
45
+ }
46
+ });
47
+
48
+ return false;
49
+ });
50
+ });
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @name Elastic
3
+ * @descripton Elastic is Jquery plugin that grow and shrink your textareas automaticliy
4
+ * @version 1.6.4
5
+ * @requires Jquery 1.2.6+
6
+ *
7
+ * @author Jan Jarfalk
8
+ * @author-email jan.jarfalk@unwrongest.com
9
+ * @author-website http://www.unwrongest.com
10
+ *
11
+ * @licens MIT License - http://www.opensource.org/licenses/mit-license.php
12
+ */
13
+
14
+ (function(jQuery){
15
+ jQuery.fn.extend({
16
+ elastic: function() {
17
+
18
+ // We will create a div clone of the textarea
19
+ // by copying these attributes from the textarea to the div.
20
+ var mimics = [
21
+ 'paddingTop',
22
+ 'paddingRight',
23
+ 'paddingBottom',
24
+ 'paddingLeft',
25
+ 'fontSize',
26
+ 'lineHeight',
27
+ 'fontFamily',
28
+ 'width',
29
+ 'fontWeight'];
30
+
31
+ return this.each( function() {
32
+
33
+ // Elastic only works on textareas
34
+ if ( this.type != 'textarea' ) {
35
+ return false;
36
+ }
37
+
38
+ var $textarea = jQuery(this),
39
+ $twin = jQuery('<div />').css({'position': 'absolute','display':'none','word-wrap':'break-word'}),
40
+ lineHeight = parseInt($textarea.css('line-height'),10) || parseInt($textarea.css('font-size'),'10'),
41
+ minheight = parseInt($textarea.css('height'),10) || lineHeight*3,
42
+ maxheight = parseInt($textarea.css('max-height'),10) || Number.MAX_VALUE,
43
+ goalheight = 0,
44
+ i = 0;
45
+
46
+ // Opera returns max-height of -1 if not set
47
+ if (maxheight < 0) { maxheight = Number.MAX_VALUE; }
48
+
49
+ // Append the twin to the DOM
50
+ // We are going to meassure the height of this, not the textarea.
51
+ $twin.appendTo($textarea.parent());
52
+
53
+ // Copy the essential styles (mimics) from the textarea to the twin
54
+ var i = mimics.length;
55
+ while(i--){
56
+ $twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString()));
57
+ }
58
+
59
+
60
+ // Sets a given height and overflow state on the textarea
61
+ function setHeightAndOverflow(height, overflow){
62
+ curratedHeight = Math.floor(parseInt(height,10));
63
+ if($textarea.height() != curratedHeight){
64
+ $textarea.css({'height': curratedHeight + 'px','overflow':overflow});
65
+
66
+ }
67
+ }
68
+
69
+
70
+ // This function will update the height of the textarea if necessary
71
+ function update() {
72
+
73
+ // Get curated content from the textarea.
74
+ var textareaContent = $textarea.val().replace(/&/g,'&amp;').replace(/ /g, '&nbsp;').replace(/<|>/g, '&gt;').replace(/\n/g, '<br />');
75
+
76
+ var twinContent = $twin.html();
77
+
78
+ if(textareaContent+'&nbsp;' != twinContent){
79
+
80
+ // Add an extra white space so new rows are added when you are at the end of a row.
81
+ $twin.html(textareaContent+'&nbsp;');
82
+
83
+ // Change textarea height if twin plus the height of one line differs more than 3 pixel from textarea height
84
+ if(Math.abs($twin.height()+lineHeight - $textarea.height()) > 3){
85
+
86
+ var goalheight = $twin.height()+lineHeight;
87
+ if(goalheight >= maxheight) {
88
+ setHeightAndOverflow(maxheight,'auto');
89
+ } else if(goalheight <= minheight) {
90
+ setHeightAndOverflow(minheight,'hidden');
91
+ } else {
92
+ setHeightAndOverflow(goalheight,'hidden');
93
+ }
94
+
95
+ }
96
+
97
+ }
98
+
99
+ }
100
+
101
+ // Hide scrollbars
102
+ $textarea.css({'overflow':'hidden'});
103
+
104
+ // Update textarea size on keyup
105
+ $textarea.keyup(function(){ update(); });
106
+
107
+ // And this line is to catch the browser paste event
108
+ $textarea.live('input paste',function(e){ setTimeout( update, 250); });
109
+
110
+ // Run update once when elastic is initialized
111
+ update();
112
+
113
+ });
114
+
115
+ }
116
+ });
117
+ })(jQuery);