cobweb 0.0.55 → 0.0.57

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. data/README.textile +2 -1
  2. data/lib/cobweb.rb +4 -1
  3. data/lib/cobweb_crawler.rb +1 -4
  4. data/lib/cobweb_version.rb +1 -1
  5. data/lib/content_link_parser.rb +1 -0
  6. data/lib/crawl_job.rb +4 -3
  7. data/lib/server.rb +2 -2
  8. data/lib/stats.rb +6 -1
  9. data/spec/cobweb/cobweb_job_spec.rb +162 -24
  10. data/spec/samples/sample_server.rb +21 -0
  11. data/spec/samples/sample_site/boxgrid.html +258 -0
  12. data/spec/samples/sample_site/css/accordion.css +45 -0
  13. data/spec/samples/sample_site/css/datatable.css +189 -0
  14. data/spec/samples/sample_site/css/datepicker.css +171 -0
  15. data/spec/samples/sample_site/css/form-buttons.css +180 -0
  16. data/spec/samples/sample_site/css/forms.css +489 -0
  17. data/spec/samples/sample_site/css/jquery.fancybox-1.3.4.css +282 -0
  18. data/spec/samples/sample_site/css/jquery.treeview.css +103 -0
  19. data/spec/samples/sample_site/css/link-buttons.css +187 -0
  20. data/spec/samples/sample_site/css/login.css +110 -0
  21. data/spec/samples/sample_site/css/menu.css +156 -0
  22. data/spec/samples/sample_site/css/messages.css +58 -0
  23. data/spec/samples/sample_site/css/modalbox.css +63 -0
  24. data/spec/samples/sample_site/css/statics.css +57 -0
  25. data/spec/samples/sample_site/css/style.css +497 -0
  26. data/spec/samples/sample_site/css/style_text.css +128 -0
  27. data/spec/samples/sample_site/css/tabs.css +58 -0
  28. data/spec/samples/sample_site/css/wysiwyg-editor.css +18 -0
  29. data/spec/samples/sample_site/css/wysiwyg.css +149 -0
  30. data/spec/samples/sample_site/css/wysiwyg.modal.css +69 -0
  31. data/spec/samples/sample_site/dashboard.html +852 -0
  32. data/spec/samples/sample_site/forms.html +329 -0
  33. data/spec/samples/sample_site/gallery.html +263 -0
  34. data/spec/samples/sample_site/gfx/back-menu.gif +0 -0
  35. data/spec/samples/sample_site/gfx/back-submenu.gif +0 -0
  36. data/spec/samples/sample_site/gfx/background.gif +0 -0
  37. data/spec/samples/sample_site/gfx/box-hide.png +0 -0
  38. data/spec/samples/sample_site/gfx/box-search.png +0 -0
  39. data/spec/samples/sample_site/gfx/box-title.gif +0 -0
  40. data/spec/samples/sample_site/gfx/code.gif +0 -0
  41. data/spec/samples/sample_site/gfx/datepicker-arrows.gif +0 -0
  42. data/spec/samples/sample_site/gfx/fancybox/blank.gif +0 -0
  43. data/spec/samples/sample_site/gfx/fancybox/fancy_close.png +0 -0
  44. data/spec/samples/sample_site/gfx/fancybox/fancy_loading.png +0 -0
  45. data/spec/samples/sample_site/gfx/fancybox/fancy_nav_left.png +0 -0
  46. data/spec/samples/sample_site/gfx/fancybox/fancy_nav_right.png +0 -0
  47. data/spec/samples/sample_site/gfx/fancybox/fancy_title_left.png +0 -0
  48. data/spec/samples/sample_site/gfx/fancybox/fancy_title_main.png +0 -0
  49. data/spec/samples/sample_site/gfx/fancybox/fancy_title_over.png +0 -0
  50. data/spec/samples/sample_site/gfx/fancybox/fancy_title_right.png +0 -0
  51. data/spec/samples/sample_site/gfx/fancybox/fancybox-x.png +0 -0
  52. data/spec/samples/sample_site/gfx/fancybox/fancybox.png +0 -0
  53. data/spec/samples/sample_site/gfx/forms/date-next.gif +0 -0
  54. data/spec/samples/sample_site/gfx/forms/date-prev.gif +0 -0
  55. data/spec/samples/sample_site/gfx/forms/forms-checkbox.gif +0 -0
  56. data/spec/samples/sample_site/gfx/forms/forms-date.gif +0 -0
  57. data/spec/samples/sample_site/gfx/forms/forms-file.gif +0 -0
  58. data/spec/samples/sample_site/gfx/forms/forms-input-big.gif +0 -0
  59. data/spec/samples/sample_site/gfx/forms/forms-input-medium.gif +0 -0
  60. data/spec/samples/sample_site/gfx/forms/forms-input-small.gif +0 -0
  61. data/spec/samples/sample_site/gfx/forms/forms-input-xl.gif +0 -0
  62. data/spec/samples/sample_site/gfx/forms/forms-radio.gif +0 -0
  63. data/spec/samples/sample_site/gfx/forms/forms-selectbox-small.gif +0 -0
  64. data/spec/samples/sample_site/gfx/forms/forms-selectbox.gif +0 -0
  65. data/spec/samples/sample_site/gfx/forms/forms-textarea-big.gif +0 -0
  66. data/spec/samples/sample_site/gfx/forms/forms-textarea-medium.gif +0 -0
  67. data/spec/samples/sample_site/gfx/forms/forms-textarea-small.gif +0 -0
  68. data/spec/samples/sample_site/gfx/forms/forms-textarea-xl.gif +0 -0
  69. data/spec/samples/sample_site/gfx/icon-delete.png +0 -0
  70. data/spec/samples/sample_site/gfx/icon-edit.png +0 -0
  71. data/spec/samples/sample_site/gfx/icon-home.gif +0 -0
  72. data/spec/samples/sample_site/gfx/img-delete.png +0 -0
  73. data/spec/samples/sample_site/gfx/img-hover.png +0 -0
  74. data/spec/samples/sample_site/gfx/img-zoom.png +0 -0
  75. data/spec/samples/sample_site/gfx/jquery.wysiwyg.gif +0 -0
  76. data/spec/samples/sample_site/gfx/label-icons.gif +0 -0
  77. data/spec/samples/sample_site/gfx/label.gif +0 -0
  78. data/spec/samples/sample_site/gfx/li-down.gif +0 -0
  79. data/spec/samples/sample_site/gfx/li.gif +0 -0
  80. data/spec/samples/sample_site/gfx/link-button-big.gif +0 -0
  81. data/spec/samples/sample_site/gfx/link-button-medium.gif +0 -0
  82. data/spec/samples/sample_site/gfx/link-button.gif +0 -0
  83. data/spec/samples/sample_site/gfx/loading-2.gif +0 -0
  84. data/spec/samples/sample_site/gfx/loading.gif +0 -0
  85. data/spec/samples/sample_site/gfx/logo.png +0 -0
  86. data/spec/samples/sample_site/gfx/modal-title.gif +0 -0
  87. data/spec/samples/sample_site/gfx/photos/00.jpg +0 -0
  88. data/spec/samples/sample_site/gfx/photos/01.jpg +0 -0
  89. data/spec/samples/sample_site/gfx/photos/01xl.jpg +0 -0
  90. data/spec/samples/sample_site/gfx/photos/02.jpg +0 -0
  91. data/spec/samples/sample_site/gfx/photos/02xl.jpg +0 -0
  92. data/spec/samples/sample_site/gfx/photos/03.jpg +0 -0
  93. data/spec/samples/sample_site/gfx/photos/03xl.jpg +0 -0
  94. data/spec/samples/sample_site/gfx/photos/04.jpg +0 -0
  95. data/spec/samples/sample_site/gfx/photos/04xl.jpg +0 -0
  96. data/spec/samples/sample_site/gfx/photos/05.jpg +0 -0
  97. data/spec/samples/sample_site/gfx/photos/05xl.jpg +0 -0
  98. data/spec/samples/sample_site/gfx/photos/06.jpg +0 -0
  99. data/spec/samples/sample_site/gfx/photos/06xl.jpg +0 -0
  100. data/spec/samples/sample_site/gfx/photos/07.jpg +0 -0
  101. data/spec/samples/sample_site/gfx/photos/07xl.jpg +0 -0
  102. data/spec/samples/sample_site/gfx/photos/08.jpg +0 -0
  103. data/spec/samples/sample_site/gfx/photos/08xl.jpg +0 -0
  104. data/spec/samples/sample_site/gfx/photos/09.jpg +0 -0
  105. data/spec/samples/sample_site/gfx/photos/09xl.jpg +0 -0
  106. data/spec/samples/sample_site/gfx/photos/10.jpg +0 -0
  107. data/spec/samples/sample_site/gfx/photos/10xl.jpg +0 -0
  108. data/spec/samples/sample_site/gfx/photos/11.jpg +0 -0
  109. data/spec/samples/sample_site/gfx/photos/11xl.jpg +0 -0
  110. data/spec/samples/sample_site/gfx/photos/12.jpg +0 -0
  111. data/spec/samples/sample_site/gfx/photos/12xl.jpg +0 -0
  112. data/spec/samples/sample_site/gfx/photos/13.jpg +0 -0
  113. data/spec/samples/sample_site/gfx/photos/13xl.jpg +0 -0
  114. data/spec/samples/sample_site/gfx/photos/14.jpg +0 -0
  115. data/spec/samples/sample_site/gfx/photos/14xl.jpg +0 -0
  116. data/spec/samples/sample_site/gfx/photos/15.jpg +0 -0
  117. data/spec/samples/sample_site/gfx/photos/15xl.jpg +0 -0
  118. data/spec/samples/sample_site/gfx/search-button.gif +0 -0
  119. data/spec/samples/sample_site/gfx/search-input.gif +0 -0
  120. data/spec/samples/sample_site/gfx/slider-button.gif +0 -0
  121. data/spec/samples/sample_site/gfx/system-messages.gif +0 -0
  122. data/spec/samples/sample_site/gfx/table-asc-arrow.gif +0 -0
  123. data/spec/samples/sample_site/gfx/table-desc-arrow.gif +0 -0
  124. data/spec/samples/sample_site/gfx/table-first.gif +0 -0
  125. data/spec/samples/sample_site/gfx/table-last.gif +0 -0
  126. data/spec/samples/sample_site/gfx/table-next.gif +0 -0
  127. data/spec/samples/sample_site/gfx/table-number.gif +0 -0
  128. data/spec/samples/sample_site/gfx/table-prev.gif +0 -0
  129. data/spec/samples/sample_site/gfx/table-rows.gif +0 -0
  130. data/spec/samples/sample_site/gfx/table-search.gif +0 -0
  131. data/spec/samples/sample_site/gfx/table-thead.gif +0 -0
  132. data/spec/samples/sample_site/gfx/tooltip.gif +0 -0
  133. data/spec/samples/sample_site/gfx/treeview/ajax-loader.gif +0 -0
  134. data/spec/samples/sample_site/gfx/treeview/file.gif +0 -0
  135. data/spec/samples/sample_site/gfx/treeview/folder-closed.gif +0 -0
  136. data/spec/samples/sample_site/gfx/treeview/folder.gif +0 -0
  137. data/spec/samples/sample_site/gfx/treeview/minus.gif +0 -0
  138. data/spec/samples/sample_site/gfx/treeview/plus.gif +0 -0
  139. data/spec/samples/sample_site/gfx/treeview/treeview-default-line.gif +0 -0
  140. data/spec/samples/sample_site/gfx/treeview/treeview-default.gif +0 -0
  141. data/spec/samples/sample_site/index.html +852 -0
  142. data/spec/samples/sample_site/js/controls/wysiwyg.image.js +284 -0
  143. data/spec/samples/sample_site/js/controls/wysiwyg.link.js +210 -0
  144. data/spec/samples/sample_site/js/controls/wysiwyg.table.js +151 -0
  145. data/spec/samples/sample_site/js/customInput.jquery.js +68 -0
  146. data/spec/samples/sample_site/js/excanvas.min.js +1 -0
  147. data/spec/samples/sample_site/js/hoverIntent.js +84 -0
  148. data/spec/samples/sample_site/js/inline.js +392 -0
  149. data/spec/samples/sample_site/js/jquery-1.7.1.min.js +4 -0
  150. data/spec/samples/sample_site/js/jquery-ui-select.js +522 -0
  151. data/spec/samples/sample_site/js/jquery-ui-timepicker-addon.js +1299 -0
  152. data/spec/samples/sample_site/js/jquery-ui.js +791 -0
  153. data/spec/samples/sample_site/js/jquery.dataTables.js +7440 -0
  154. data/spec/samples/sample_site/js/jquery.fancybox-1.3.4.js +1156 -0
  155. data/spec/samples/sample_site/js/jquery.filestyle.mini.js +2 -0
  156. data/spec/samples/sample_site/js/jquery.flot.js +2600 -0
  157. data/spec/samples/sample_site/js/jquery.flot.resize.min.js +60 -0
  158. data/spec/samples/sample_site/js/jquery.graphtable-0.2.js +179 -0
  159. data/spec/samples/sample_site/js/jquery.tipsy.js +104 -0
  160. data/spec/samples/sample_site/js/jquery.treeview.js +256 -0
  161. data/spec/samples/sample_site/js/jquery.wysiwyg.js +2454 -0
  162. data/spec/samples/sample_site/js/plugins/wysiwyg.rmFormat.js +348 -0
  163. data/spec/samples/sample_site/js/superfish.js +121 -0
  164. data/spec/samples/sample_site/js/supersubs.js +90 -0
  165. data/spec/samples/sample_site/more.html +503 -0
  166. data/spec/samples/sample_site/tables.html +845 -0
  167. data/spec/samples/sample_site/text/museosans-webfont.eot +0 -0
  168. data/spec/samples/sample_site/text/museosans-webfont.svg +231 -0
  169. data/spec/samples/sample_site/text/museosans-webfont.ttf +0 -0
  170. data/spec/samples/sample_site/text/museosans-webfont.woff +0 -0
  171. data/spec/samples/sample_site/text/museosans_bold-webfont.eot +0 -0
  172. data/spec/samples/sample_site/text/museosans_bold-webfont.svg +231 -0
  173. data/spec/samples/sample_site/text/museosans_bold-webfont.ttf +0 -0
  174. data/spec/samples/sample_site/text/museosans_bold-webfont.woff +0 -0
  175. data/spec/samples/sample_site/typography.html +192 -0
  176. data/spec/spec_helper.rb +10 -2
  177. metadata +196 -26
@@ -0,0 +1,284 @@
1
+ /**
2
+ * Controls: Image plugin
3
+ *
4
+ * Depends on jWYSIWYG
5
+ */
6
+ (function ($) {
7
+ "use strict";
8
+
9
+ if (undefined === $.wysiwyg) {
10
+ throw "wysiwyg.image.js depends on $.wysiwyg";
11
+ }
12
+
13
+ if (!$.wysiwyg.controls) {
14
+ $.wysiwyg.controls = {};
15
+ }
16
+
17
+ /*
18
+ * Wysiwyg namespace: public properties and methods
19
+ */
20
+ $.wysiwyg.controls.image = {
21
+ groupIndex: 6,
22
+ visible: true,
23
+ exec: function () {
24
+ $.wysiwyg.controls.image.init(this);
25
+ },
26
+ tags: ["img"],
27
+ tooltip: "Insert image",
28
+ init: function (Wysiwyg) {
29
+ var self = this, elements, adialog, dialog, formImageHtml, regexp, dialogReplacements, key, translation,
30
+ img = {
31
+ alt: "",
32
+ self: Wysiwyg.dom ? Wysiwyg.dom.getElement("img") : null, // link to element node
33
+ src: "http://",
34
+ title: ""
35
+ };
36
+
37
+ dialogReplacements = {
38
+ legend : "Insert Image",
39
+ preview : "Preview",
40
+ url : "URL",
41
+ title : "Title",
42
+ description : "Description",
43
+ width : "Width",
44
+ height : "Height",
45
+ original : "Original W x H",
46
+ "float" : "Float",
47
+ floatNone : "None",
48
+ floatLeft : "Left",
49
+ floatRight : "Right",
50
+ submit : "Insert Image",
51
+ reset : "Cancel",
52
+ fileManagerIcon : "Select file from server"
53
+ };
54
+
55
+ formImageHtml = '<form class="wysiwyg" id="wysiwyg-addImage"><fieldset>' +
56
+ //'<div class="form-row"><label>{preview}:</label><div class="form-row-value"><img src="gfx/wysiwyg-preview.gif" alt="{preview}" style="max-width: 180px; overflow:hidden; max-height: 135px;"/></div></div>' +
57
+ '<div class="form-row"><label for="name">{url}:</label><div class="form-row-value"><input type="text" name="src" value=""/>';
58
+
59
+ if ($.wysiwyg.fileManager && $.wysiwyg.fileManager.ready) {
60
+ // Add the File Manager icon:
61
+ formImageHtml += '<div class="wysiwyg-fileManager" title="{fileManagerIcon}"/>';
62
+ }
63
+
64
+ formImageHtml += '</div></div>' +
65
+ '<div class="form-row"><label for="name">{title}:</label><div class="form-row-value"><input type="text" name="imgtitle" value=""/></div></div>' +
66
+ '<div class="form-row"><label for="name">{description}:</label><div class="form-row-value"><input type="text" name="description" value=""/></div></div>' +
67
+ '<div class="form-row"><label for="name">{width} x {height}:</label><div class="form-row-value"><input type="text" class="tiny" name="width" value="" /> x <input type="text" class="tiny" name="height" value="" class="width-small"/></div></div>' +
68
+ '<div class="form-row"><label for="name">{original}:</label><div class="form-row-value"><input type="text" class="tiny" name="naturalWidth" value="" disabled="disabled"/> x ' +
69
+ '<input type="text" class="tiny" name="naturalHeight" value="" disabled="disabled"/></div></div>' +
70
+ '<div class="form-row"><label for="name">{float}:</label><div class="form-row-value"><select name="float">' +
71
+ '<option value="">{floatNone}</option>' +
72
+ '<option value="left">{floatLeft}</option>' +
73
+ '<option value="right">{floatRight}</option></select></div></div>' +
74
+ '<div class="form-row form-row-last"><label for="name"></label><div class="form-row-value"><button type="submit" class="green medium" value="{submit}"><span>Sumbit</span></button>&nbsp' +
75
+ '<button type="submit" class="red medium" value="{reset}"><span>Reset</span></button></div></div></fieldset></form>';
76
+
77
+ for (key in dialogReplacements) {
78
+ if ($.wysiwyg.i18n) {
79
+ translation = $.wysiwyg.i18n.t(dialogReplacements[key], "dialogs.image");
80
+
81
+ if (translation === dialogReplacements[key]) { // if not translated search in dialogs
82
+ translation = $.wysiwyg.i18n.t(dialogReplacements[key], "dialogs");
83
+ }
84
+
85
+ dialogReplacements[key] = translation;
86
+ }
87
+
88
+ regexp = new RegExp("{" + key + "}", "g");
89
+ formImageHtml = formImageHtml.replace(regexp, dialogReplacements[key]);
90
+ }
91
+
92
+ if (img.self) {
93
+ img.src = img.self.src ? img.self.src : "";
94
+ img.alt = img.self.alt ? img.self.alt : "";
95
+ img.title = img.self.title ? img.self.title : "";
96
+ img.width = img.self.width ? img.self.width : "";
97
+ img.height = img.self.height ? img.self.height : "";
98
+ img.styleFloat = $(img.self).css("float");
99
+ }
100
+
101
+ adialog = new $.wysiwyg.dialog(Wysiwyg, {
102
+ "title" : dialogReplacements.legend,
103
+ "content" : formImageHtml
104
+ });
105
+
106
+ $(adialog).bind("afterOpen", function (e, dialog) {
107
+ dialog.find("form#wysiwyg-addImage").submit(function (e) {
108
+ e.preventDefault();
109
+ self.processInsert(dialog.container, Wysiwyg, img);
110
+
111
+ adialog.close();
112
+ return false;
113
+ });
114
+
115
+ // File Manager (select file):
116
+ if ($.wysiwyg.fileManager) {
117
+ $("div.wysiwyg-fileManager").bind("click", function () {
118
+ $.wysiwyg.fileManager.init(function (selected) {
119
+ dialog.find("input[name=src]").val(selected);
120
+ dialog.find("input[name=src]").trigger("change");
121
+ });
122
+ });
123
+ }
124
+
125
+ $("input:reset", dialog).click(function (e) {
126
+ adialog.close();
127
+
128
+ return false;
129
+ });
130
+
131
+ $("fieldset", dialog).click(function (e) {
132
+ e.stopPropagation();
133
+ });
134
+
135
+ self.makeForm(dialog, img);
136
+ });
137
+
138
+ adialog.open();
139
+
140
+ $(Wysiwyg.editorDoc).trigger("editorRefresh.wysiwyg");
141
+ },
142
+
143
+ processInsert: function (context, Wysiwyg, img) {
144
+ var image,
145
+ url = $('input[name="src"]', context).val(),
146
+ title = $('input[name="imgtitle"]', context).val(),
147
+ description = $('input[name="description"]', context).val(),
148
+ width = $('input[name="width"]', context).val(),
149
+ height = $('input[name="height"]', context).val(),
150
+ styleFloat = $('select[name="float"]', context).val(),
151
+ styles = [],
152
+ style = "",
153
+ found,
154
+ baseUrl;
155
+
156
+ if (Wysiwyg.options.controlImage && Wysiwyg.options.controlImage.forceRelativeUrls) {
157
+ baseUrl = window.location.protocol + "//" + window.location.hostname;
158
+ if (0 === url.indexOf(baseUrl)) {
159
+ url = url.substr(baseUrl.length);
160
+ }
161
+ }
162
+
163
+ if (img.self) {
164
+ // to preserve all img attributes
165
+ $(img.self).attr("src", url)
166
+ .attr("title", title)
167
+ .attr("alt", description)
168
+ .css("float", styleFloat);
169
+
170
+ if (width.toString().match(/^[0-9]+(px|%)?$/)) {
171
+ $(img.self).css("width", width);
172
+ } else {
173
+ $(img.self).css("width", "");
174
+ }
175
+
176
+ if (height.toString().match(/^[0-9]+(px|%)?$/)) {
177
+ $(img.self).css("height", height);
178
+ } else {
179
+ $(img.self).css("height", "");
180
+ }
181
+
182
+ Wysiwyg.saveContent();
183
+ } else {
184
+ found = width.toString().match(/^[0-9]+(px|%)?$/);
185
+ if (found) {
186
+ if (found[1]) {
187
+ styles.push("width: " + width + ";");
188
+ } else {
189
+ styles.push("width: " + width + "px;");
190
+ }
191
+ }
192
+
193
+ found = height.toString().match(/^[0-9]+(px|%)?$/);
194
+ if (found) {
195
+ if (found[1]) {
196
+ styles.push("height: " + height + ";");
197
+ } else {
198
+ styles.push("height: " + height + "px;");
199
+ }
200
+ }
201
+
202
+ if (styleFloat.length > 0) {
203
+ styles.push("float: " + styleFloat + ";");
204
+ }
205
+
206
+ if (styles.length > 0) {
207
+ style = ' style="' + styles.join(" ") + '"';
208
+ }
209
+
210
+ image = "<img src='" + url + "' title='" + title + "' alt='" + description + "'" + style + "/>";
211
+ Wysiwyg.insertHtml(image);
212
+ }
213
+ },
214
+
215
+ makeForm: function (form, img) {
216
+ form.find("input[name=src]").val(img.src);
217
+ form.find("input[name=imgtitle]").val(img.title);
218
+ form.find("input[name=description]").val(img.alt);
219
+ form.find('input[name="width"]').val(img.width);
220
+ form.find('input[name="height"]').val(img.height);
221
+ form.find('select[name="float"]').val(img.styleFloat);
222
+ form.find('img').attr("src", img.src);
223
+
224
+ form.find('img').bind("load", function () {
225
+ if (form.find('img').get(0).naturalWidth) {
226
+ form.find('input[name="naturalWidth"]').val(form.find('img').get(0).naturalWidth);
227
+ form.find('input[name="naturalHeight"]').val(form.find('img').get(0).naturalHeight);
228
+ } else if (form.find('img').attr("naturalWidth")) {
229
+ form.find('input[name="naturalWidth"]').val(form.find('img').attr("naturalWidth"));
230
+ form.find('input[name="naturalHeight"]').val(form.find('img').attr("naturalHeight"));
231
+ }
232
+ });
233
+
234
+ form.find("input[name=src]").bind("change", function () {
235
+ form.find('img').attr("src", this.value);
236
+ });
237
+
238
+ return form;
239
+ }
240
+ };
241
+
242
+ $.wysiwyg.insertImage = function (object, url, attributes) {
243
+ return object.each(function () {
244
+ var Wysiwyg = $(this).data("wysiwyg"),
245
+ image,
246
+ attribute;
247
+
248
+ if (!Wysiwyg) {
249
+ return this;
250
+ }
251
+
252
+ if (!url || url.length === 0) {
253
+ return this;
254
+ }
255
+
256
+ if ($.browser.msie) {
257
+ Wysiwyg.ui.focus();
258
+ }
259
+
260
+ if (attributes) {
261
+ Wysiwyg.editorDoc.execCommand("insertImage", false, "#jwysiwyg#");
262
+ image = Wysiwyg.getElementByAttributeValue("img", "src", "#jwysiwyg#");
263
+
264
+ if (image) {
265
+ image.src = url;
266
+
267
+ for (attribute in attributes) {
268
+ if (attributes.hasOwnProperty(attribute)) {
269
+ image.setAttribute(attribute, attributes[attribute]);
270
+ }
271
+ }
272
+ }
273
+ } else {
274
+ Wysiwyg.editorDoc.execCommand("insertImage", false, url);
275
+ }
276
+
277
+ Wysiwyg.saveContent();
278
+
279
+ $(Wysiwyg.editorDoc).trigger("editorRefresh.wysiwyg");
280
+
281
+ return this;
282
+ });
283
+ };
284
+ })(jQuery);
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Controls: Link plugin
3
+ *
4
+ * Depends on jWYSIWYG
5
+ *
6
+ * By: Esteban Beltran (academo) <sergies@gmail.com>
7
+ */
8
+ (function ($) {
9
+ if (undefined === $.wysiwyg) {
10
+ throw "wysiwyg.image.js depends on $.wysiwyg";
11
+ }
12
+
13
+ if (!$.wysiwyg.controls) {
14
+ $.wysiwyg.controls = {};
15
+ }
16
+
17
+ /*
18
+ * Wysiwyg namespace: public properties and methods
19
+ */
20
+ $.wysiwyg.controls.link = {
21
+ init: function (Wysiwyg) {
22
+ var self = this, elements, dialog, szURL, a, selection,
23
+ formLinkHtml, formTextLegend, formTextUrl, formTextTitle, formTextTarget,
24
+ formTextSubmit, formTextReset;
25
+
26
+ formTextLegend = "Insert Link";
27
+ formTextUrl = "Link URL";
28
+ formTextTitle = "Link Title";
29
+ formTextTarget = "Link Target";
30
+ formTextSubmit = "Insert Link";
31
+ formTextReset = "Cancel";
32
+
33
+ if ($.wysiwyg.i18n) {
34
+ formTextLegend = $.wysiwyg.i18n.t(formTextLegend, "dialogs.link");
35
+ formTextUrl = $.wysiwyg.i18n.t(formTextUrl, "dialogs.link");
36
+ formTextTitle = $.wysiwyg.i18n.t(formTextTitle, "dialogs.link");
37
+ formTextTarget = $.wysiwyg.i18n.t(formTextTarget, "dialogs.link");
38
+ formTextSubmit = $.wysiwyg.i18n.t(formTextSubmit, "dialogs.link");
39
+ formTextReset = $.wysiwyg.i18n.t(formTextReset, "dialogs");
40
+ }
41
+
42
+ formLinkHtml = '<form class="wysiwyg"><fieldset><legend>' + formTextLegend + '</legend>' +
43
+ '<label>' + formTextUrl + ': <input type="text" name="linkhref" value=""/></label>' +
44
+ '<label>' + formTextTitle + ': <input type="text" name="linktitle" value=""/></label>' +
45
+ '<label>' + formTextTarget + ': <input type="text" name="linktarget" value=""/></label>' +
46
+ '<input type="submit" class="button" value="' + formTextSubmit + '"/> ' +
47
+ '<input type="reset" value="' + formTextReset + '"/></fieldset></form>';
48
+
49
+ a = {
50
+ self: Wysiwyg.dom.getElement("a"), // link to element node
51
+ href: "http://",
52
+ title: "",
53
+ target: ""
54
+ };
55
+
56
+ if (a.self) {
57
+ a.href = a.self.href ? a.self.href : a.href;
58
+ a.title = a.self.title ? a.self.title : "";
59
+ a.target = a.self.target ? a.self.target : "";
60
+ }
61
+
62
+ if ($.fn.dialog) {
63
+ elements = $(formLinkHtml);
64
+ elements.find("input[name=linkhref]").val(a.href);
65
+ elements.find("input[name=linktitle]").val(a.title);
66
+ elements.find("input[name=linktarget]").val(a.target);
67
+
68
+ if ($.browser.msie) {
69
+ dialog = elements.appendTo(Wysiwyg.editorDoc.body);
70
+ } else {
71
+ dialog = elements.appendTo("body");
72
+ }
73
+
74
+ dialog.dialog({
75
+ modal: true,
76
+ width: Wysiwyg.defaults.formWidth,
77
+ height: Wysiwyg.defaults.formHeight,
78
+ open: function (ev, ui) {
79
+ $("input:submit", dialog).click(function (e) {
80
+ e.preventDefault();
81
+
82
+ var szURL = $('input[name="linkhref"]', dialog).val(),
83
+ title = $('input[name="linktitle"]', dialog).val(),
84
+ target = $('input[name="linktarget"]', dialog).val();
85
+
86
+ if (a.self) {
87
+ if ("string" === typeof (szURL)) {
88
+ if (szURL.length > 0) {
89
+ // to preserve all link attributes
90
+ $(a.self).attr("href", szURL).attr("title", title).attr("target", target);
91
+ } else {
92
+ $(a.self).replaceWith(a.self.innerHTML);
93
+ }
94
+ }
95
+ } else {
96
+
97
+ if ($.browser.msie) {
98
+ Wysiwyg.ui.returnRange();
99
+ }
100
+
101
+ //Do new link element
102
+ selection = Wysiwyg.getRangeText();
103
+ img = Wysiwyg.dom.getElement("img");
104
+
105
+ if ((selection && selection.length > 0) || img) {
106
+ if ($.browser.msie) {
107
+ Wysiwyg.ui.focus();
108
+ }
109
+
110
+ if ("string" === typeof (szURL)) {
111
+ if (szURL.length > 0) {
112
+ Wysiwyg.editorDoc.execCommand("createLink", false, szURL);
113
+ } else {
114
+ Wysiwyg.editorDoc.execCommand("unlink", false, null);
115
+ }
116
+ }
117
+
118
+ a = Wysiwyg.dom.getElement("a");
119
+ $(a).attr("href", szURL).attr("title", title).attr("target", target);
120
+ } else if (Wysiwyg.options.messages.nonSelection) {
121
+ window.alert(Wysiwyg.options.messages.nonSelection);
122
+ }
123
+ }
124
+ $(dialog).dialog("close");
125
+ });
126
+ $("input:reset", dialog).click(function (e) {
127
+ e.preventDefault();
128
+ $(dialog).dialog("close");
129
+ });
130
+ },
131
+ close: function (ev, ui) {
132
+ dialog.dialog("destroy");
133
+ }
134
+ });
135
+ } else {
136
+ if (a.self) {
137
+ szURL = window.prompt("URL", a.href);
138
+
139
+ if ("string" === typeof (szURL)) {
140
+ if (szURL.length > 0) {
141
+ $(a.self).attr("href", szURL);
142
+ } else {
143
+ $(a.self).replaceWith(a.self.innerHTML);
144
+ }
145
+ }
146
+ } else {
147
+ //Do new link element
148
+ selection = Wysiwyg.getRangeText();
149
+ img = Wysiwyg.dom.getElement("img");
150
+
151
+ if ((selection && selection.length > 0) || img) {
152
+ if ($.browser.msie) {
153
+ Wysiwyg.ui.focus();
154
+ Wysiwyg.editorDoc.execCommand("createLink", true, null);
155
+ } else {
156
+ szURL = window.prompt(formTextUrl, a.href);
157
+
158
+ if ("string" === typeof (szURL)) {
159
+ if (szURL.length > 0) {
160
+ Wysiwyg.editorDoc.execCommand("createLink", false, szURL);
161
+ } else {
162
+ Wysiwyg.editorDoc.execCommand("unlink", false, null);
163
+ }
164
+ }
165
+ }
166
+ } else if (Wysiwyg.options.messages.nonSelection) {
167
+ window.alert(Wysiwyg.options.messages.nonSelection);
168
+ }
169
+ }
170
+ }
171
+
172
+ $(Wysiwyg.editorDoc).trigger("wysiwyg:refresh");
173
+ }
174
+ };
175
+
176
+ $.wysiwyg.createLink = function (object, szURL) {
177
+ if ("object" !== typeof (object) || !object.context) {
178
+ object = this;
179
+ }
180
+
181
+ if (!object.each) {
182
+ console.error("Something goes wrong, check object");
183
+ }
184
+
185
+ return object.each(function () {
186
+ var oWysiwyg = $(this).data("wysiwyg"),
187
+ selection;
188
+
189
+ if (!oWysiwyg) {
190
+ return this;
191
+ }
192
+
193
+ if (!szURL || szURL.length === 0) {
194
+ return this;
195
+ }
196
+
197
+ selection = oWysiwyg.getRangeText();
198
+
199
+ if (selection && selection.length > 0) {
200
+ if ($.browser.msie) {
201
+ oWysiwyg.ui.focus();
202
+ }
203
+ oWysiwyg.editorDoc.execCommand("unlink", false, null);
204
+ oWysiwyg.editorDoc.execCommand("createLink", false, szURL);
205
+ } else if (oWysiwyg.options.messages.nonSelection) {
206
+ window.alert(oWysiwyg.options.messages.nonSelection);
207
+ }
208
+ });
209
+ };
210
+ })(jQuery);