1var App = App || {}; 2 3App.Website = function (){ 4 var lang = App.Localization.getLang(); 5 6 function completeSlugFromTitle($title, $slug){ 7 function f(){ 8 $slug.val($title.val().toSlug()); 9 } 10 11 $title.on("focus", function(){ 12 if ($slug.val() == ""){ 13 $title.on("keypress, input", f); 14 } 15 }); 16 17 $title.on("blur", function(){ 18 if ($slug.val() != ""){ 19 $title.off("keypress input", f); 20 } 21 }); 22 } 23 24 function setupPageEditorDailog(dialog){ 25 var width = $(".page-url", dialog.body).width() + 5; 26 var $subdomain = $(".page", dialog.body) 27 .css("padding-left", width + "px"); 28 completeSlugFromTitle($("input[name=name]", dialog.body), $subdomain); 29 } 30 31 function setupWebsiteRow($ws){ 32 $ws.on("click", onWebSiteClick); 33 34 var $option = $(".img-option-file-off", $ws) 35 .on("click", function(){ 36 $menu.show(); 37 }); 38 39 var $menu = $(".contextual-menu", $option.parent()); 40 41 /*$(".edit", $menu).on("click", function(ev){ 42 var $this = $(this); 43 var href = $this.attr("href"); 44 45 var dialog = App.Dialogs.ajaxFormDialog({ 46 title: lang.editWebSite, 47 url: href, 48 ajaxForm: { 49 success: function(response){ 50 if (response.error){ 51 dialog.$saving.hide(); 52 dialog.$submit.show(); 53 dialog.validator.showErrors({ 54 "slug": lang.urlIsInUse 55 }); 56 } 57 else 58 { 59 $(".folder", $this.closest(".folder-row")).html($("input[name=title]", dialog.body).val()); 60 App.Dialogs.closeCurrent(); 61 } 62 } 63 } 64 }); 65 66 return false; 67 });*/ 68 69 $(".remove", $menu).on("click", function(ev){ 70 var $this = $(this); 71 App.Dialogs.confirmDialog({ 72 message: lang.removeWebsiteWarning, 73 ok: function(){ 74 $.ajax({
75 type: "POST", 76 url: $this.attr("href") 77 }); 78 79 $(".file-list").fadeOut("slow", function(){ 80 $(this).html(""); 81 $(this).show(); 82 }); 83 84 $this.closest(".folder-row").fadeOut("slow", function(){ 85 $(this).attr("data-selected", "false"); 86 var $next = $(this).next(); 87 if ($next.length) 88 $next.trigger("click"); 89 else{ 90 $next = $(this).prev(); 91 if ($next.length) 92 $next.trigger("click"); 93 } 94 }); 95 } 96 }); 97 98 return false; 99 }); 100 } 101 102 function setupFileRow($f){ 103 var $option = $(".img-option-file-off", $f) 104 .on("click", function(){ 105 $menu.show(); 106 }); 107 108 var $menu = $(".contextual-menu", $option.parent()); 109 110 $(".remove-page", $menu).on("click", function(){ 111 var $this = $(this); 112 var $row = $(this).closest(".file-row"); 113 App.Dialogs.confirmDialog({ 114 message: lang.removePageWarning, 115 ok: function(){ 116 $.ajax({ 117 type: "POST", 118 url: $this.attr("href") 119 }); 120 $row.fadeOut("slow", function () { $(this.remove()); }); 121 } 122 }); 123 124 return false; 125 }); 126 127 $(".edit-page", $menu).on("click", function(){ 128 var $this = $(this); 129 var $row = $(this).closest(".file-row"); 130 131 var dialog = App.Dialogs.ajaxFormDialog({ 132 title: lang.editPage, 133 url : $this.attr("href"), 134 afterLoad: function(){ 135 setupPageEditorDailog(dialog); 136 }, 137 ajaxForm: { 138 success: function(response){ 139 if (response.error){ 140 dialog.$saving.hide(); 141 dialog.$submit.show(); 142 dialog.validator.showErrors({ 143 "slug": lang.pageUrlExists 144 }); 145 } 146 else 147 { 148 $(".nom-file", $row).html($("input[name=name]", dialog.body).val()); 149 App.Dialogs.closeCurrent(); 150 } 151 } 152 } 153 }); 154 155 return false; 156 }); 157 158 $(".edit-webres", $menu).on("click", function(){ 159 var $this = $(this); 160 var $row = $(this).closest(".file-row"); 161 162 var dialog = App.Dialogs.ajaxFormDialog({ 163 title: lang.renameResource, 164 url : $this.attr("href"), 165 ajaxForm: { 166 success: function(response){ 167 if (response.error){ 168 dialog.$saving.hide(); 169 dialog.$submit.show(); 170 dialog.validator.showErrors({ 171 "name": response.error.msg 172 }); 173 } 174 else 175 { 176 $(".nom-file", $row).html($("input[name=name]", dialog.body).val()); 177 App.Dialogs.closeCurrent(); 178 } 179 } 180 } 181 }); 182 183 return false; 184 }); 185 186 $(".remove-webres", $menu).on("click", function(){ 187 var $this = $(this); 188 var $row = $(this).closest(".file-row"); 189 App.Dialogs.confirmDialog({ 190 message: lang.removePageWarning, 191 ok: function(){ 192 $.ajax({
193 type: "POST", 194 url: $this.attr("href") 195 }); 196 $row.fadeOut("slow", function () { $(this.remove()); }); 197 } 198 }); 199 200 return false; 201 }); 202 203 $(".edit-webres-content", $menu).click(function(){ 204 var $this = $(this); 205 var $row = $this.closest(".file-row"); 206 var htmlDialog = App.Dialogs.ajaxFormDialog({ 207 popupClass: "html-widget-editor", 208 title: $(".nom-file", $row).html(), 209 url: $this.attr("href"), 210 ajaxForm: { 211 success: function(response){ 212 if (response.ok){ 213 //App.Dialogs.closeCurrent(); 214 if (htmlDialog.$saving) 215 htmlDialog.$saving.hide(); 216 217 if (htmlDialog.$submit) 218 htmlDialog.$submit.show(); 219 220 App.Dialogs.toast(lang.theWidgetHaveBeenUpdated); 221 } 222 else 223 { 224 App.Dialogs.closeCurrent(); 225 App.Dialogs.alertDialog({ 226 title: "Ooops!", 227 type: App.Dialogs.AlertType.ERROR, 228 header: lang.somethingWasWrong, 229 message: response.error.msg 230 }); 231 } 232 } 233 } 234 }); 235 return false; 236 }); 237 } 238 239 function onNewPageClick(){ 240 var webSiteId = $(this).data("wsid"); 241 var dialog = App.Dialogs.ajaxFormDialog({ 242 title: lang.addWebPage, 243 url: "/add-page?webSiteId=" + webSiteId, 244 ajaxForm: { 245 success: function(response){ 246 if (response.error){ 247 dialog.$saving.hide(); 248 dialog.$submit.show(); 249 dialog.validator.showErrors({ 250 "slug": lang.pageUrlExists 251 }); 252 } 253 else 254 { 255 var $response = $(response); 256 $(".file-list").append($response); 257 App.Dialogs.closeCurrent(); 258 setupFileRow($response); 259 } 260 261 } 262 }, 263 afterLoad: function(){ 264 setupPageEditorDailog(dialog); 265 } 266 }); 267 } 268 269 function addWebRes(webSiteId, type) 270 { 271 var dialog = App.Dialogs.ajaxFormDialog({ 272 title: lang.addFragment, 273 url: "/add-web-res/" + webSiteId + "?type=" + type, 274 ajaxForm: { 275 success: function(response){ 276 if (response.error){ 277 dialog.$saving.hide(); 278 dialog.$submit.show(); 279 dialog.validator.showErrors({ 280 "name": response.error.msg 281 }); 282 } 283 else 284 { 285 var $response = $(response); 286 $(".file-list").append($response); 287 App.Dialogs.closeCurrent(); 288 setupFileRow($response); 289 } 290 291 } 292 }, 293 afterLoad: function(){ 294 setupPageEditorDailog(dialog); 295 } 296 }); 297 } 298 299 function onNewCssClick(){ 300 addWebRes($(this).data("wsid"), 1); 301 } 302 303 function onNewFragmentClick(){ 304 addWebRes($(this).data("wsid"), 3); 305 } 306 307 function onNewJsClick(){ 308 addWebRes($(this).data("wsid"), 2); 309 } 310 311 function onNewWebSiteClick(){ 312 var dialog = App.Dialogs.ajaxFormDialog({ 313 title: lang.addWebSite, 314 url: "/add-website", 315 ajaxForm: { 316 success: function(response){ 317 //dialog.success(response); 318 if (response.error){ 319 dialog.$saving.hide(); 320 dialog.$submit.show(); 321 dialog.validator.showErrors({ 322 "slug": lang.websiteUrlExists 323 }); 324 } 325 else 326 { 327 var $response = $(response); 328 $(".folders-list").append($response); 329 App.Dialogs.closeCurrent(); 330 setupWebsiteRow($response); 331 $response.trigger("click"); 332 } 333 } 334 }, 335 afterLoad: function(){ 336 completeSlugFromTitle($("input[name=title]", dialog.body), $(".web-url", dialog.body)); 337 }, 338 }); 339 } 340 341 function onWebSiteClick(){ 342 $(".folder-row").attr("data-selected", false); 343 $(".websites-adding").hide(); 344 var $row = $(this).attr("data-selected", true); 345 var id = $row.data("id"); 346 $(".add-file").attr("data-wsid", id); 347 $(".add-css").attr("data-wsid", id); 348 $(".add-js").attr("data-wsid", id); 349 $(".add-fragment").attr("data-wsid", id); 350 351 $files = $(".file-list").html(""); 352 var $loading = $("<p></p>") 353 .html(lang.loadingPleaseWait) 354 .addClass("loading-txt") 355 .appendTo($(".stored-list-view")); 356 357 $.ajax({ 358 url: "/website-files/" + id, 359 success: function(response){ 360 $loading.remove(); 361 $files.html(response); 362 $(".file-list .file-row").each(function(){ 363 setupFileRow($(this)); 364 }); 365 366 $(".file-list > li").hover(function () { }, 367 function () { 368 $(".contextual-menu", $(this)).hide(); 369 } 370 ); 371 } 372 }); 373 } 374 375 function setupManagerView(){ 376 var $sitesMenu = $(".folders-list"); 377 var $webSitePages = $(".file-list"); 378 379 $(".add-website").on("click", onNewWebSiteClick); 380 381 $(".folders-list .folder-row").each(function(){ 382 setupWebsiteRow($(this)); 383 }); 384 385 $(".folders-list > li").hover(function() { }, 386 function() { 387 $(".contextual-menu", $(this)).hide(); 388 } 389 ); 390 391 $(".file-list .file-row").each(function(){ 392 setupFileRow($(this)); 393 }); 394 395 $(".file-list > li").hover(function () { }, 396 function () { 397 $(".contextual-menu", $(this)).hide(); 398 } 399 ); 400 401 $(".add-file").on("click", onNewPageClick); 402 $(".add-css").on("click", onNewCssClick); 403 $(".add-js").on("click", onNewJsClick); 404 $(".add-fragment").on("click", onNewFragmentClick); 405 } 406 407 function setupProfileView(){
408 App.Followers.setupButton(); 409 } 410 411 return { 412 setupManagerView: setupManagerView, 413 setupProfileView: setupProfileView 414 } 415}(); 416 417$('.add-to-website').on('click',function (){ 418 $('ul.websites-adding').slideToggle(); 419});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.