Advertisement
Guest User

Untitled

a guest
Nov 1st, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 136.52 KB | None | 0 0
  1. // Build on Thu Oct 20 21:06:21 CEST 2011 for language "en"
  2. myHostname = window.location.Pinkpranlster;
  3. var myTLD = "." + myHostname.substring(myHostname.indexOf("wupload") + "wupload.".length).split(".")[0];
  4.  
  5. function afterLoad() {
  6. return
  7. }
  8. ieFixForFileSelectionOnChangeEventTimer = null;
  9.  
  10. function ieFixForFileSelectionOnChangeEvent(a) {
  11. $("#siteName").toggle();
  12. if ($("#inputFileSelection").val() == "") {
  13. ieFixForFileSelectionOnChangeEventTimer = setTimeout("ieFixForFileSelectionOnChangeEvent()", 200)
  14. } else {
  15. $("body")[0].focus()
  16. }
  17. }
  18. function urlencode(a) {
  19. return escape(a.toString().replace(/%/g, "%25").replace(/\+/g, "%2B")).replace(/%25/g, "%")
  20. }
  21. $(document).ajaxStart(function() {
  22. $("body").addClass("ajaxLoading")
  23. });
  24. $(document).ajaxStop(function() {
  25. $("body").removeClass("ajaxLoading")
  26. });
  27. $(document).ajaxError(function(d, c, a, b) {
  28. CMApplication.Widgets.Dialog.close();
  29. CMApplication.Widgets.Dialog.displayMessage(c.responseText, CMApplication.Widgets.Dialog.Types.exception)
  30. });
  31. jQuery.setCookie = function(b, c, a) {
  32. var d = new Date();
  33. d.setDate(d.getDate() + a);
  34. cookieDomain = ".wupload" + myTLD;
  35. document.cookie = b + "=" + escape(c) + ((a == null) ? "" : ";expires=" + d.toUTCString() + "; path=/;domain=" + cookieDomain + ";")
  36. };
  37. jQuery.getCookie = function(a) {
  38. if (document.cookie.length > 0) {
  39. c_start = document.cookie.indexOf(a + "=");
  40. if (c_start != -1) {
  41. c_start = c_start + a.length + 1;
  42. c_end = document.cookie.indexOf(";", c_start);
  43. if (c_end == -1) {
  44. c_end = document.cookie.length
  45. }
  46. return unescape(document.cookie.substring(c_start, c_end))
  47. }
  48. }
  49. return ""
  50. };
  51. jQuery.unparam = function(d) {
  52. var f = {},
  53. c = d.split("&"),
  54. e, b, a;
  55. for (b = 0, a = c.length; b < a; b++) {
  56. e = c[b].split("=", 2);
  57. f[decodeURIComponent(e[0])] = (e.length == 2 ? decodeURIComponent(e[1].replace(/\+/g, " ")) : true)
  58. }
  59. return f
  60. };
  61. CMApplication = {
  62. User: {
  63. RolesNames: ["anonymous", "free", "premium"],
  64. RolesValues: {
  65. ANONYMOUS: 0,
  66. FREE: 1,
  67. PREMIUM: 2
  68. }, sessId: "",
  69. email: "",
  70. isAffiliate: false,
  71. role: "anonymous"
  72. }, Bootstrap: {
  73. run: function() {
  74. for (var a in this) {
  75. if (a.indexOf("_init") === -1) {
  76. continue
  77. }
  78. this[a]()
  79. }
  80. CMApplication.Widgets.Ajax._init()
  81. }
  82. }, Dictionnary: {
  83. SEARCH_ALL_FOLDERS: "Search all folders:",
  84. SEARCH_THIS_FOLDERS: "Search this folders:",
  85. PLEASE_WAIT: "Please Wait...",
  86. SHARE: "Share",
  87. SHARE_FILES: "Share Files",
  88. EDIT: "Edit",
  89. TRASH: "Trash",
  90. DOWNLOAD_READY: "Download Ready",
  91. START_DOWNLOAD_NOW: "Start download now!",
  92. LEAVING_WILL_CANCEL_UPLOADS: "If you continue, your upload(s) will be cancelled.",
  93. YOUR_UPLOADS: "Your uploads",
  94. COMPLETED: "Completed",
  95. CLOSE: "Close",
  96. VIEW_LINKS: "View Links",
  97. UNEXPECTED_PROCESS_ERROR: "Unexpected error during process",
  98. LOGIN_UNEXPECTED_PROCESS_ERROR: "Unexpected error during login",
  99. SYSTEM_ERROR: "System Error",
  100. ERROR: "Error",
  101. NOTICE: "Notice",
  102. FILESYSTEM_MOVE_INSTRUCTION: "Select the file/folder you want to move on the right side of the file browser.",
  103. FILESYSTEM_COPY_INSTRUCTION: "Select the file/folder you want to copy on the right side of the file browser.",
  104. FILESYSTEM_TRASH_INSTRUCTION: "Select the file/folder you want to delete on the right side of the file browser.",
  105. FILESYSTEM_GENERATELINKS_INSTRUCTION: "Select the file(s) you want to generate link on the right side of the file browser.",
  106. FILESYSTEM_PREMIUM_INSTRUCTION: "Select the file(s) you want to set only for premium on the right side of the file browser.",
  107. FOLDER_ID_REQUIRED: "Folder ID should be specified",
  108. FILESYSTEM_MOVE_SOURCE_IDENTICAL_TO_DESTINATION: "Impossible to move: The source folder is identical then the destination",
  109. FILESYSTEM_MOVE_DESTINATION_SUBFOLDER_OF_SOURCE: "Impossible to move: The destination folder is a subfolder of the source.",
  110. FILESYSTEM_MOVE_UNABLE_TO_MOVE: "Unable to move selected file/folder",
  111. FILESYSTEM_COPY_UNABLE_TO_COPY: "Unable to copy selected file/folder",
  112. FILESYSTEM_TRASH_UNABLE_TO_TRASH: "Unable to trash selected file/folder",
  113. FILESYSTEM_PREMIUM_UNABLE_TO_PREMIUM: "Unable to set only for premium selected file(s)",
  114. COPY_FOLDER_NOT_YET_IMPLEMENTED: "Copy of folder not yet implemented",
  115. PAGE_SHOULD_BE_OPENED_IN_NEW_WINDOW: "For technical reasons, this page should be opened in a new window/tab when uploading a file.",
  116. USER_HAS_TO_WAIT: "User has to wait",
  117. VIEW_ALL_LINKS: "View all links",
  118. SELECT_A_DESTINATION: "Select a destination",
  119. MOVE: "Move",
  120. CANCEL: "Cancel",
  121. CANCEL_UPLOAD: "Cancel Upload",
  122. ARE_YOU_SURE_YOU_WANT_TO_DELETE_THESE_FILES: "Are you sure you want to delete these files / folder ?",
  123. ARE_YOU_SURE_YOU_WANT_TO_SET_THESE_FILES_ONLY_PREMIUM: "Are you sure you want to set these files only for premium?",
  124. ARE_YOU_SURE_YOU_WANT_TO_UNSET_THESE_FILES_ONLY_PREMIUM: "Are you sure you want to unset these files only for premium?",
  125. DESCRIPTION: "Description:",
  126. IS_PUBLIC: "Is Public:",
  127. LINK: "Link",
  128. LINKS: "Links:",
  129. DATE_CREATED: "Created On:",
  130. DATE_UPDATED: "Updated On:",
  131. MUST_BE_PUBLIC: "Must be public",
  132. COPY: "Copy",
  133. REMOTE_UPLOAD: "Remote Upload",
  134. WEB_UPLOAD: "Web Upload",
  135. UNKNOWN: "Unknown",
  136. SIZE: "Size",
  137. SOURCE: "Source",
  138. PASSWORD: "Password",
  139. PREMIUM_ONLY: "Premium Only",
  140. TOTAL_SIZE: "Total Size:",
  141. FOLLOWING_ERROR_DURING_UPLOAD: "The following errors happen during the upload:",
  142. RENAME: "Rename",
  143. UPLOADING: "Uploading",
  144. FILES: "Files",
  145. RESTORE: "Restore",
  146. SELECT: "Select",
  147. MINIMIZE: "Minimize",
  148. FILES_UPLOADED_TO: "Files uploaded to:",
  149. CHOOSE_FILES_TO_UPLOAD: "Choose files to upload",
  150. UPLOAD_NOW: "Upload Now",
  151. YOU_SUCCESSFULLY_UPLOADED: "You successfully uploaded",
  152. YOU_UPLOADED: "You uploaded",
  153. ERROR_DURING_THE_UPLOAD: "Error during the upload",
  154. SHARE_ALL_LINKS: "Share ALL Links",
  155. CHOOSE_FILES_AND_THEN_PRESS_UPLOAD_NOW: "Choose files to upload, then click &quot;Start Upload&quot;",
  156. TOTAL_FILES: "Total Files:",
  157. FILE_NAME: "File name",
  158. PROGRESS: "Progress",
  159. DOWNLOAD_LINK: "Download Link",
  160. FAIL: "Fail",
  161. VIEW_LINK: "View Link",
  162. START_UPLOAD: "Start Upload",
  163. SELECTABLE: "Selectable"
  164. }, URLs: {
  165. languageFilesystemExportFolderLinks: "/file-manager/export-all-links/:folderId",
  166. languageFilesystemCopy: "/file-manager/copy/:id",
  167. languageFilesystemMove: "/file-manager/move/:id",
  168. languageFilesystemEditMultiple: "/file-manager/edit-files/:id",
  169. languageFilesystemShare: "/file-manager/share/email/:ids",
  170. languageFilesystemEdit: "/file-manager/edit/:id",
  171. languageFilesystemCreate: "/file-manager/create/:parentId",
  172. languageFilesystemTrash: "/file-manager/delete/:id",
  173. languageFilesystemGenerateLink: "/file-manager/share/urls/:id",
  174. languageFilesystemBrowse: "/file-manager/list/:folderId/:page/:orderBy/:orderDirection/:globalSearch/:queryString",
  175. languageFilesystemRemoved: "/file-manager/removed",
  176. languageDownload: "/file/:id",
  177. uploadProgress: ":hostserver/nginxuploadprogress?unique=:unique&ID=:progress_key&X-Progress-ID=:progress_key",
  178. uploadCallback: "/upload/done/:uploadProgressId",
  179. domain: "http://" + window.location.host
  180. }, foward: function(a) {
  181. location.href = a
  182. }, Viewport: {
  183. width: null,
  184. height: null,
  185. adjust: function() {
  186. if (typeof window.innerWidth != "undefined") {
  187. this.width = window.innerWidth,
  188. this.height = window.innerHeight
  189. } else {
  190. if (typeof document.documentElement != "undefined" && typeof document.documentElement.clientWidth != "undefined" && document.documentElement.clientWidth != 0) {
  191. this.width = document.documentElement.clientWidth,
  192. this.height = document.documentElement.clientHeight
  193. } else {
  194. this.width = document.getElementsByTagName("body")[0].clientWidth,
  195. this.height = document.getElementsByTagName("body")[0].clientHeight
  196. }
  197. }
  198. var a = false;
  199. if (navigator.userAgent.indexOf("MSIE 6") != -1) {
  200. a = true
  201. }
  202. }
  203. }, Layout: {
  204. _init: function() {
  205. if (CMApplication.User.email != "") {
  206. $("body").addClass("loggedIn")
  207. } else {
  208. $("body").removeClass("loggedIn")
  209. }
  210. $("#lMainUsage a[href=" + window.location + "]").parent("li").addClass("active");
  211. $("#lMainUsage li.active").parent("li").addClass("active");
  212. $("#lMainUsage li.active").parent("ul").parent("li").addClass("active");
  213. $("ul.main li li.account").live("mouseenter", function(a) {
  214. $(this).addClass("hover");
  215. $("ul.lMore", this).show()
  216. });
  217. $("ul.main li li.account").live("mouseleave", function(a) {
  218. $(this).removeClass("hover");
  219. $("ul.lMore", this).hide()
  220. })
  221. }
  222. }, Widgets: {}, Pages: {}
  223. };
  224. sortFolders = function(d, c) {
  225. var g = $('#sortForm input[name="folder_field"]').val();
  226. if (g == "name") {
  227. var f = encodeURI($(d).text()).replace("%0A%20%20%20%20%20%20%20%20", "").replace("%0A%20%20%20%20", "");
  228. var e = encodeURI($(c).text()).replace("%0A%20%20%20%20%20%20%20%20", "").replace("%0A%20%20%20%20", "")
  229. } else {
  230. if (g == "date") {
  231. var f = $(d).attr("data-date");
  232. var e = $(c).attr("data-date")
  233. }
  234. }
  235. if ($('#sortForm input[name="folder_direction"]').val() == "desc") {
  236. return (f > e) ? -1 : (f < e) ? 1 : 0
  237. } else {
  238. return (f < e) ? -1 : (f > e) ? 1 : 0
  239. }
  240. };
  241. $(document).ready(function() {
  242. var counter = 0;
  243. $("#internationalization a.active").click(function() {
  244. return false
  245. });
  246. $("#internationalization").click(function() {
  247. $("#internationalization li").toggleClass("open").delay(800);
  248. $("div#internationalization ul").toggleClass("opened").delay(800);
  249. counter++
  250. });
  251. $("html").click(function() {
  252. if (counter % 2) {
  253. $("#internationalization li").toggleClass("open").delay(800);
  254. $("div#internationalization ul").toggleClass("opened").delay(800);
  255. counter++
  256. }
  257. });
  258. if (jQuery.getCookie("isJavascriptEnable") != 1) {
  259. jQuery.setCookie("isJavascriptEnable", 1, 30)
  260. }
  261. $("#DialogWidget #signupCompleted form").live("successCallback", function(event, data) {
  262. $(this).removeAttr("rel")
  263. });
  264. $("#free_download, #free_download2, #cancelDownload").live("click", function(event) {
  265. $("#freeDownload").hide();
  266. event.preventDefault();
  267. $.post(this.href, $("#downloadMode form").serialize(), function(data) {
  268. $("#premiumDownload").remove();
  269. $("#downloadMode").replaceWith(data);
  270. $("#downloadMode").slideDown("slow")
  271. })
  272. });
  273. $("#downloadMode form").live("submit", function(event) {
  274. event.preventDefault();
  275. $.post(this.action, $("#downloadMode form").serialize(), function(data) {
  276. $("#downloadMode").replaceWith(data);
  277. $("#downloadMode").slideDown("slow")
  278. })
  279. });
  280. $('#downloadMode form input[type="submit"], #downloadMode form button').live("click", function(event) {
  281. event.preventDefault();
  282. $.post($("#downloadMode form").attr("action"), $("#downloadMode form").serialize(), function(data) {
  283. $("#downloadMode").replaceWith(data);
  284. $("#downloadMode").slideDown("slow")
  285. })
  286. });
  287. isSearchResult = false;
  288. CMApplication.Widgets.Ajax = {
  289. Events: {
  290. click: function(e) {
  291. if (e.isDefaultPrevented()) {
  292. return
  293. }
  294. var internalLinkRegEx = /^(\#|\/|https?\:\/\/([^.]+\.)?wupload(\.[a-z]{2,3})+\/?)/i;
  295. destination = $(this).attr("href");
  296. isInternal = internalLinkRegEx.test(destination);
  297. var anchorRegEx = /(\#.*)$/i;
  298. isAnchor = anchorRegEx.test(destination);
  299. if (!isInternal) {
  300. return
  301. }
  302. e.preventDefault();
  303. localPath = CMApplication.Widgets.Ajax.getHash(destination).replace(anchorRegEx, "");
  304. if (localPath != "" && !(localPath == window.location.pathname && isAnchor)) {
  305. var intelligenceRegEx = /\/intelligence(\/.*)?$/i;
  306. isIntelligence = intelligenceRegEx.test(localPath);
  307. if (!isIntelligence) {
  308. $.history.load(localPath)
  309. } else {
  310. alert(CMApplication.Dictionnary.PAGE_SHOULD_BE_OPENED_IN_NEW_WINDOW);
  311. window.open(localPath)
  312. }
  313. }
  314. anchor = anchorRegEx.exec(destination);
  315. if (anchor !== null && $(anchor[0]).length == 1) {
  316. setTimeout("$('html,body').animate({scrollTop: " + $(anchor[0]).offset().top + "}, 800);", 1)
  317. }
  318. }, submit: function(e) {
  319. if (e.isDefaultPrevented()) {
  320. return
  321. }
  322. var internalLinkRegEx = /^(\#|\/|https?\:\/\/([^.]+\.)?wupload(\.[a-z]{2,3})+\/?)/i;
  323. destination = $(this).attr("action");
  324. isInternal = internalLinkRegEx.test(destination);
  325. if (!isInternal) {
  326. return
  327. }
  328. e.preventDefault();
  329. localPath = CMApplication.Widgets.Ajax.getHash(destination);
  330. jQuery.ajax({
  331. url: localPath,
  332. type: $(this).attr("method") || "get",
  333. data: $(this).serialize(),
  334. dataType: "html",
  335. complete: function(XMLHttpRequest, textStatus) {
  336. $("#mainContent").html(XMLHttpRequest.responseText)
  337. }
  338. })
  339. }
  340. }, start: function() {
  341. alert("Starting Ajax Browsing");
  342. $("form").live("submit", CMApplication.Widgets.Ajax.Events.submit);
  343. $("a").live("click", CMApplication.Widgets.Ajax.Events.click);
  344. $.history.init(function(hash) {
  345. if (hash == "") {
  346. url = CMApplication.Widgets.Ajax.getHash(location.href)
  347. } else {
  348. jQuery.ajax({
  349. url: hash,
  350. async: false,
  351. global: false,
  352. type: "get",
  353. dataType: "html",
  354. data: {
  355. isGlobalAjax: "1"
  356. }, complete: function(XMLHttpRequest, textStatus) {
  357. $("#mainContent").html(XMLHttpRequest.responseText)
  358. }
  359. });
  360. $("html,body").animate({
  361. scrollTop: 0
  362. }, 1)
  363. }
  364. }, {
  365. unescape: ",/"
  366. })
  367. }, stop: function() {
  368. alert("Stopping Ajax Browsing");
  369. $("form").die("submit", CMApplication.Widgets.Ajax.Events.submit);
  370. $("a").die("click", CMApplication.Widgets.Ajax.Events.click);
  371. $.history.init(function() {}, {
  372. unescape: ",/"
  373. })
  374. }, _init: function() {}, getHash: function(url) {
  375. hostnameRegEx = /^(https?\:\/\/[^\/]+)/i;
  376. return url.replace(hostnameRegEx, "")
  377. }
  378. };
  379. CMApplication.Widgets.Purchase = {
  380. Events: {
  381. submit: function(e) {
  382. e.preventDefault();
  383. CMApplication.Widgets.Dialog.displayUrl($(this).attr("action"));
  384. editForm = $("form", CMApplication.Widgets.Dialog.dialogContainer);
  385. editForm.bind("successCallback", function(event, data) {
  386. if (data.data.paymentSystem == 3) {
  387. $(event.target).attr("rel", "keep");
  388. $("#DialogWidgetContent").load(data.redirect)
  389. } else {
  390. location.href = data.redirect
  391. }
  392. });
  393. editForm.bind("failCallback", function(event, data) {
  394. $(event.target).attr("rel", "keep")
  395. })
  396. }
  397. }, _init: function() {
  398. $(".form_payment_system_3, .form_payment_system_8.premiumEmail, .form_payment_system_9.premiumEmail").live("submit", CMApplication.Widgets.Purchase.Events.submit)
  399. }
  400. };
  401. CMApplication.Widgets.Tools = {
  402. Events: {
  403. click: function(e) {
  404. e.preventDefault();
  405. $(this).addClass("active");
  406. $('#lUser li.lMore:not("#statsLinks") ul').show();
  407. $(document).bind("click", closeUserMenuMore);
  408.  
  409. function closeUserMenuMore(e) {
  410. clickedElement = $(e.target);
  411. if (!clickedElement.is('#lUser li.lMore:not("#statsLinks") ul') && clickedElement.parents('#lUser li.lMore:not("#statsLinks") ul').length < 1) {
  412. $('#lUser li.lMore:not("#statsLinks") a').removeClass("active");
  413. $('#lUser li.lMore:not("#statsLinks") ul').hide();
  414. $(document).unbind("click", closeUserMenuMore)
  415. }
  416. }
  417. }
  418. }, _init: function() {
  419. $('#lUser li.lMore:not("#statsLinks") > a:not(.active)').live("click", CMApplication.Widgets.Tools.Events.click)
  420. }
  421. };
  422. CMApplication.Widgets.Stats = {
  423. Events: {
  424. click: function(e) {
  425. e.preventDefault();
  426. $(this).addClass("active");
  427. $("#lUser li.lMore#statsLinks ul").show();
  428. $(document).bind("click", closeUserMenuMore);
  429.  
  430. function closeUserMenuMore(e) {
  431. clickedElement = $(e.target);
  432. if (!clickedElement.is("#lUser li.lMore#statsLinks ul") && clickedElement.parents("#lUser li.lMore#statsLinks ul").length < 1) {
  433. $("#lUser li.lMore#statsLinks a").removeClass("active");
  434. $("#lUser li.lMore#statsLinks ul").hide();
  435. $(document).unbind("click", closeUserMenuMore)
  436. }
  437. }
  438. }
  439. }, _init: function() {
  440. $("#lUser li.lMore#statsLinks > a:not(.active)").live("click", CMApplication.Widgets.Stats.Events.click)
  441. }
  442. };
  443. CMApplication.Pages.Download = {
  444. PasswordProtection: {
  445. formElement: $("body#Download_Index #passwordProtection form"),
  446. Events: {
  447. submit: function(event) {
  448. event.preventDefault();
  449. jQuery.ajax({
  450. url: $(this).attr("action"),
  451. type: $(this).attr("method"),
  452. dataType: "json",
  453. data: $(this).serialize(),
  454. success: function(data) {
  455. if (data.status == "success") {
  456. jQuery.ajax({
  457. url: data.redirect,
  458. type: "GET",
  459. dataType: "html",
  460. success: function(data) {
  461. $("#premiumMessages").html(data)
  462. }
  463. })
  464. } else {
  465. container = $("#password").parent();
  466. errorContainer = $("ul.errors", container);
  467. if (errorContainer.length === 0) {
  468. errorContainer = $('<ul class="errors" />').appendTo(container)
  469. }
  470. for (fieldName in data.messages) {
  471. errors = "";
  472. field = data.messages[fieldName];
  473. for (error in field) {
  474. errors += "<li>" + field[error] + "</li>"
  475. }
  476. errorContainer.html(errors)
  477. }
  478. }
  479. }
  480. })
  481. }
  482. }
  483. }, CountDown: {
  484. delay: 60,
  485. decrease: function() {
  486. if (this.delay > 0) {
  487. this.delay--;
  488. $("#countdown").text(this.getFormatedDelay());
  489. window.onPageTimeout = setTimeout("CMApplication.Pages.Download.CountDown.decrease();", 1050)
  490. } else {
  491. $.post("?start=1", $("#tm, #tm_hash").serialize(), function(data) {
  492. $("#downloadMode").replaceWith(data)
  493. })
  494. }
  495. },
  496. hack: function() {
  497. $.post("?start=1", $("#tm, #tm_hash").serialize(), function(data) {
  498. $("#downloadMode").replaceWith(data)
  499. })
  500. }
  501. , getFormatedDelay: function() {
  502. returnValue = this.delay / 60;
  503. returnValue = returnValue.toString().split(".");
  504. minutes = returnValue[0];
  505. seconds = this.delay - (minutes * 60);
  506. if (seconds.toString().length == 1) {
  507. seconds = "0" + seconds
  508. }
  509. if (minutes < 1) {
  510. rv = seconds + "s"
  511. } else {
  512. rv = minutes + " min."
  513. }
  514. return rv
  515. }
  516. }, _init: function() {
  517. CMApplication.Pages.Download.PasswordProtection.formElement.live("submit", CMApplication.Pages.Download.PasswordProtection.Events.submit);
  518. if (typeof(countDownDelay) !== "undefined") {
  519. CMApplication.Pages.Download.CountDown.delay = countDownDelay;
  520. CMApplication.Pages.Download.CountDown.decrease();
  521. try {
  522. pageTracker._trackEvent("download_delay", "wait_" + countDownDelay, CMApplication.Dictionnary.USER_HAS_TO_WAIT + countDownDelay)
  523. } catch(e) {}
  524. }
  525. }
  526. };
  527. CMApplication.Widgets.Dialog = {
  528. dialogContainer: null,
  529. Types: {
  530. exception: 1,
  531. error: 2,
  532. notice: 3
  533. }, Events: {
  534. close: function(event) {
  535. event.preventDefault();
  536. CMApplication.Widgets.Dialog.close()
  537. }, submit: function(event) {
  538. event.preventDefault();
  539. var formSubmitted = $(this);
  540. jQuery.ajax({
  541. url: formSubmitted.attr("action"),
  542. data: formSubmitted.serializeArray(),
  543. type: formSubmitted.attr("method"),
  544. dataType: "json",
  545. success: function(data, textStatus, XMLHttpResponse) {
  546. if (data.status == "success") {
  547. form = formSubmitted.trigger("successCallback", data)
  548. } else {
  549. form = formSubmitted.trigger("failCallback", data);
  550. if ($(form).attr("rel") == "keep") {
  551. for (var i in data.messages) {
  552. for (var j in data.messages[i]) {
  553. message = data.messages[i][j];
  554. if ($("#" + i).parent("div.elements").children(".errors").length == 0) {
  555. $("#" + i).parent("div.elements").append("<ul class='errors'><li>" + message + "</li></ul>")
  556. } else {
  557. $("#" + i).parent("div.elements").children(".errors").html("<li>" + message + "</li>")
  558. }
  559. }
  560. }
  561. }
  562. }
  563. if ($(form).attr("rel") != "keep") {
  564. CMApplication.Widgets.Dialog.close()
  565. }
  566. }
  567. })
  568. }
  569. }, displayMessage: function(message, type, className, positionTarget) {
  570. switch (type) {
  571. case CMApplication.Widgets.Dialog.Types.exception:
  572. title = CMApplication.Dictionnary.SYSTEM_ERROR;
  573. lclassName = "systemError";
  574. break;
  575. case CMApplication.Widgets.Dialog.Types.error:
  576. title = CMApplication.Dictionnary.ERROR;
  577. lclassName = "error";
  578. break;
  579. case CMApplication.Widgets.Dialog.Types.notice:
  580. title = CMApplication.Dictionnary.NOTICE;
  581. lclassName = "notice";
  582. break
  583. }
  584. html = '<div id="DialogWidgetMessage" class="' + lclassName + '"><h2><span>' + title + "</span></h2>" + message + "</div>";
  585. CMApplication.Widgets.Dialog.open(html, 400, className, positionTarget)
  586. }, displayUrl: function(url, width, className, positionTarget) {
  587. var width;
  588. ajaxUrl = url;
  589. jQuery.ajax({
  590. url: ajaxUrl,
  591. type: "get",
  592. dataType: "html",
  593. async: false,
  594. success: function(data, textStatus, XMLHttpResponse) {
  595. CMApplication.Widgets.Dialog.displayContent(data, width, className, positionTarget)
  596. }
  597. })
  598. }, displayContent: function(content, width, className, positionTarget) {
  599. CMApplication.Widgets.Dialog.open(content, width, className, positionTarget)
  600. }, open: function(content, size, className, positionTarget) {
  601. if (typeof(size) == "object") {
  602. if ("undefined" != typeof(size.width)) {
  603. width = size.width
  604. } else {
  605. width = undefined
  606. }
  607. if ("undefined" != typeof(size.height)) {
  608. height = size.height
  609. } else {
  610. height = undefined
  611. }
  612. } else {
  613. width = size;
  614. height = undefined
  615. }
  616. if ("undefined" == typeof(className)) {
  617. className = "defaultStyle"
  618. }
  619. dContainer = CMApplication.Widgets.Dialog.dialogContainer;
  620. if (dContainer == null) {
  621. CMApplication.Widgets.Dialog._init()
  622. }
  623. $("#DialogWidget").attr("class", className);
  624. $("#DialogWidgetContent").html(content);
  625. switch (className) {
  626. case "inlineStyle":
  627. if ("undefined" == typeof(width)) {
  628. width = "300"
  629. }
  630. if ("undefined" == typeof(height)) {
  631. height = "300"
  632. }
  633. scrolltopValue = $(positionTarget).offset().top;
  634. totalHeight = scrolltopValue + parseInt(height) + parseInt($("#DialogWidgetContainer").css("padding-top")) + parseInt($("#DialogWidgetContainer").css("padding-bottom"));
  635. if (totalHeight > $("body").height()) {
  636. scrolltopValue -= parseInt(height)
  637. }
  638. scrollleftValue = $(positionTarget).offset().left;
  639. totalWidth = scrollleftValue + parseInt(width) + parseInt($("#DialogWidgetContainer").css("padding-left")) + parseInt($("#DialogWidgetContainer").css("padding-right"));
  640. if (totalWidth > $("body").width()) {
  641. scrollleftValue -= parseInt(width)
  642. }
  643. break;
  644. default:
  645. if ("undefined" == typeof(width)) {
  646. width = "700"
  647. }
  648. if ($("body").scrollTop() > $("html").scrollTop()) {
  649. scrolltopValue = $("body").scrollTop()
  650. } else {
  651. scrolltopValue = $("html").scrollTop()
  652. }
  653. }
  654. dContainer.css("height", $("body").height());
  655. if ("undefined" != typeof(height)) {
  656. $("#DialogWidgetContent").css("height", height)
  657. }
  658. $("#DialogWidgetContainer, #DialogWidgetContent").css("width", width);
  659. if ("undefined" != typeof(scrolltopValue)) {
  660. $("#DialogWidgetContainer").css("top", scrolltopValue)
  661. }
  662. if ("undefined" != typeof(scrollleftValue)) {
  663. $("#DialogWidgetContainer").css("left", scrollleftValue)
  664. }
  665. $("body").addClass("displayDialog");
  666. if ("undefined" == typeof(height)) {
  667. if ($("body").scrollTop() > $("html").scrollTop()) {
  668. scrolltopValue = $("body").scrollTop()
  669. } else {
  670. scrolltopValue = $("html").scrollTop()
  671. }
  672. $("#DialogWidgetContainer").css("top", scrolltopValue + 25);
  673. heightDiff = CMApplication.Viewport.height - $("#DialogWidgetContainer").outerHeight();
  674. if (heightDiff < 0) {
  675. newHeight = $("#DialogWidgetContainer").height() - Math.abs(heightDiff) - 20;
  676. $("#DialogWidgetContainer").css("height", newHeight);
  677. $("#DialogWidgetContent").css("height", newHeight - 30);
  678. heightDiff = CMApplication.Viewport.height - $("#DialogWidgetContainer").outerHeight()
  679. }
  680. }
  681. }, close: function() {
  682. dContainer = CMApplication.Widgets.Dialog.dialogContainer;
  683. if (dContainer == null) {
  684. return
  685. }
  686. CMApplication.Widgets.Dialog.className = null;
  687. $("body").removeClass("displayDialog");
  688. $("#DialogWidget").attr("class", "");
  689. $("#DialogWidgetContent").html("");
  690. $("#DialogWidgetContainer").css("height", "auto");
  691. $("#DialogWidgetContent").css("height", "auto")
  692. }, _init: function() {
  693. markup = '<div id="DialogWidget"><div id="DialogWidgetBackground"></div><div id="DialogWidgetContainer"><div id="DialogWidgetClose"><span>close</span></div><div id="DialogWidgetContent"></div></div></div>';
  694. CMApplication.Widgets.Dialog.dialogContainer = $(markup).appendTo("body");
  695. dContainer = CMApplication.Widgets.Dialog.dialogContainer;
  696. $("#DialogWidgetBackground,#DialogWidgetClose").live("click", CMApplication.Widgets.Dialog.Events.close);
  697. $("#DialogWidgetContent form:not(.noDynamicSubmit form):not(#DialogWidgetContent #premiumPrices form)").live("submit", CMApplication.Widgets.Dialog.Events.submit)
  698. }
  699. };
  700. CMApplication.Widgets.AdvancedUpload = {
  701. _uploadServerHostname: null,
  702. getUploadServerHostname: function() {
  703. if (CMApplication.Widgets.AdvancedUpload._uploadServerHostname === null) {
  704. id = Math.floor(Math.random() * 50);
  705. CMApplication.Widgets.AdvancedUpload._uploadServerHostname = "s" + id + ".wupload" + myTLD
  706. }
  707. return CMApplication.Widgets.AdvancedUpload._uploadServerHostname
  708. }, Uploads: {}, Progress: {
  709. updateResponse: function(uploadIdentifier, data) {
  710. CMApplication.Widgets.AdvancedUpload.setUploadProgress(uploadIdentifier, data)
  711. }
  712. }, Events: {
  713. close: function(e) {
  714. e.preventDefault();
  715. CMApplication.Widgets.AdvancedUpload.close($(this).closest(".WebUploadWidget").attr("rel"))
  716. }, minimize: function(e) {
  717. e.preventDefault();
  718. $("body").removeClass("displayWebUpload");
  719. uploadContainer = $("#WebUploadWidget").hide().addClass("uploadMinimized").attr("id", "WebUploadWidget_" + $("#WebUploadWidget").attr("rel"));
  720. minimizer = $("#WebUploadMinimizer");
  721. if (minimizer.length == 0) {
  722. xhtml = "";
  723. xhtml += '<div id="WebUploadMinimizer">';
  724. xhtml += " <h3><span>" + CMApplication.Dictionnary.WEB_UPLOAD + "</span></h3>";
  725. xhtml += ' <ul class="actions">';
  726. xhtml += ' <li class="close"><a href="#"><span>' + CMApplication.Dictionnary.CLOSE + "</span></a></li>";
  727. xhtml += " </ul>";
  728. xhtml += "</div>";
  729. minimizer = $(xhtml).appendTo($("body"));
  730. $("#WebUploadMinimizer").css("left", $("#container").offset().left)
  731. }
  732. xhtml = "";
  733. xhtml += '<div class="WebUploadWidget" rel="' + uploadContainer.attr("rel") + '">';
  734. if (CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].files.length > 1) {
  735. heading = CMApplication.Dictionnary.UPLOADING + " " + CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].files.length + " " + CMApplication.Dictionnary.FILES
  736. } else {
  737. heading = CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].files[0].name
  738. }
  739. xhtml += " <h4><span>" + heading + "</span></h4>";
  740. xhtml += ' <ul class="actions">';
  741. xhtml += ' <li class="restore"><a href="#"><span>' + CMApplication.Dictionnary.RESTORE + "</span></a></li>";
  742. xhtml += ' <li class="close"><a href="#"><span>' + CMApplication.Dictionnary.CANCEL + "</span></a></li>";
  743. xhtml += " </ul>";
  744. xhtml += "</div>";
  745. uploadMinimized = $(xhtml).appendTo(minimizer);
  746. uploadMinimized.attr("class", uploadContainer.attr("class")).removeClass("uploadMinimized");
  747. uploadMinimized.append($(".progressbar", uploadContainer).clone());
  748. uploadMinimized.append($(".WebUploadWidgetResult", uploadContainer).clone());
  749. window.location.href = "#mainContent";
  750. $("#mainContent").animate({
  751. paddingTop: minimizer.height() + 48
  752. })
  753. }, restore: function(e) {
  754. e.preventDefault();
  755. $("body").addClass("displayWebUpload");
  756. minimizerContainer = $(this).closest(".WebUploadWidget");
  757. uploadIdentifier = minimizerContainer.attr("rel");
  758. minimizerContainer.remove();
  759. if ($("#WebUploadMinimizer .WebUploadWidget").length == 0) {
  760. $("#WebUploadMinimizer").remove()
  761. }
  762. $('.WebUploadWidget[rel="' + uploadIdentifier + '"]').removeClass("uploadMinimized").attr("id", "WebUploadWidget").show();
  763. if ($("body").scrollTop() > $("html").scrollTop()) {
  764. scrolltopValue = $("body").scrollTop()
  765. } else {
  766. scrolltopValue = $("html").scrollTop()
  767. }
  768. $("#WebUploadWidget").css("top", scrolltopValue)
  769. }, submit: function(e) {
  770. uploadIdentifier = $("#WebUploadWidget").attr("rel");
  771. CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step = "progress";
  772. CMApplication.Widgets.AdvancedUpload.open(uploadIdentifier);
  773. if ("undefined" == (typeof CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].originalAction)) {
  774. CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].originalAction = $(this).attr("action")
  775. }
  776. $(this).attr("action", CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].originalAction + "?callbackUrl=" + CMApplication.URLs.domain + CMApplication.URLs.uploadCallback + "&X-Progress-ID=" + uploadIdentifier);
  777. $("body").prepend('<iframe class="webUploadProxy" name="' + uploadIdentifier + '" src="#"></iframe>');
  778. $(this).attr("target", uploadIdentifier);
  779. $('input[type="file"]', this).each(function(key, elem) {
  780. if ($(elem).val() == "") {
  781. $(elem).remove()
  782. }
  783. });
  784. CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].upload.lastUpdate = new Date().getTime();
  785. CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].progressTimer = setTimeout("CMApplication.Widgets.AdvancedUpload.getUploadProgress('" + uploadIdentifier + "');", 1000);
  786. $(".buttons", this).append('<button type="button" class="webUploadCancel"><span>' + CMApplication.Dictionnary.CANCEL_UPLOAD + "</span></button>");
  787. setTimeout("$('#WebUploadWidget button[type=\"submit\"]').remove();", 100)
  788. }, addFilesFromInstructionStep: function(event) {
  789. uploadIdentifier = $("#WebUploadWidget").attr("rel");
  790. CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step = "fileSelection";
  791. CMApplication.Widgets.AdvancedUpload.open(uploadIdentifier)
  792. }, addFiles: function(event) {
  793. CMApplication.Widgets.AdvancedUpload._updateFiles();
  794. $('<input type="file" name="files[]" multiple="multiple" />').appendTo($("#WebUploadWidget form .files"))
  795. }
  796. }, start: function() {
  797. uploadIdentifier = "upload_" + new Date().getTime() + "_" + CMApplication.User.sessId + "_" + Math.floor(Math.random() * 90000);
  798. CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier] = {
  799. id: uploadIdentifier,
  800. files: [],
  801. step: "instructions",
  802. upload: {
  803. timerDelay: 1000,
  804. speed: 0,
  805. percent: 0,
  806. size: 0,
  807. lastSize: 0,
  808. total: 0
  809. }
  810. };
  811. eval("CMApplication.Widgets.AdvancedUpload.open" + CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step.charAt(0).toUpperCase() + CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step.slice(1) + '("' + uploadIdentifier + '")')
  812. }, close: function(uploadIdentifier) {
  813. confirmation = true;
  814. uploadContainer = $('.uploadMinimized.WebUploadWidget[rel="' + uploadIdentifier + '"]');
  815. if (uploadContainer.is(".progress")) {
  816. confirmation = confirm(CMApplication.Dictionnary.LEAVING_WILL_CANCEL_UPLOADS)
  817. }
  818. if (confirmation) {
  819. $('iframe.webUploadProxy[name="' + uploadIdentifier + '"]').remove();
  820. $('.WebUploadWidget[rel="' + uploadIdentifier + '"]').remove();
  821. if ($("#WebUploadMinimizer .WebUploadWidget").length == 0) {
  822. $("#WebUploadMinimizer").remove()
  823. }
  824. if ($("#WebUploadWidget").length == 0) {
  825. $("body").removeClass("displayWebUpload")
  826. }
  827. }
  828. }, open: function(uploadIdentifier) {
  829. eval("CMApplication.Widgets.AdvancedUpload.open" + CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step.charAt(0).toUpperCase() + CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step.slice(1) + '("' + uploadIdentifier + '")')
  830. }, _open: function(uploadIdentifier) {
  831. if ($("#WebUploadWidget").length > 0) {
  832. return
  833. }
  834. xhtml = "";
  835. xhtml += '<div id="WebUploadWidget" class="WebUploadWidget" rel="' + uploadIdentifier + '">';
  836. xhtml += ' <div class="WebUploadWidgetBackground"></div>';
  837. xhtml += ' <div class="WebUploadWidgetContainer">';
  838. xhtml += " <h3><span>" + CMApplication.Dictionnary.WEB_UPLOAD + "</span></h3>";
  839. xhtml += ' <ul class="actions">';
  840. xhtml += ' <li class="restore"><a href=""><span>' + CMApplication.Dictionnary.RESTORE + "</span></a></li>";
  841. xhtml += ' <li class="minimize"><a href=""><span>' + CMApplication.Dictionnary.MINIMIZE + "</span></a></li>";
  842. xhtml += ' <li class="close"><a href=""><span>' + CMApplication.Dictionnary.CLOSE + "</span></a></li>";
  843. xhtml += " </ul>";
  844. xhtml += ' <form action="http://' + CMApplication.Widgets.AdvancedUpload.getUploadServerHostname() + '" method="post" enctype="multipart/form-data">';
  845. if (jQuery.getCookie("email") != "") {
  846. xhtml += ' <div class="destination">';
  847. xhtml += ' <input type="hidden" name="folderId" class="destinationFolderId" value="0" />';
  848. xhtml += " </div>"
  849. }
  850. xhtml += ' <div class="files">';
  851. xhtml += " <label><span>" + CMApplication.Dictionnary.CHOOSE_FILES_TO_UPLOAD + "</span></label>";
  852. xhtml += ' <input type="file" name="files[]" multiple="multiple" />';
  853. xhtml += " </div>";
  854. xhtml += ' <div class="buttons">';
  855. xhtml += ' <button type="submit" class="webUploadSubmit"><span>' + CMApplication.Dictionnary.START_UPLOAD + "</span></button>";
  856. xhtml += " </div>";
  857. xhtml += " </form>";
  858. xhtml += " </div>";
  859. xhtml += "</div>";
  860. $("body").addClass("displayWebUpload").append(xhtml);
  861. if ($("body").scrollTop() > $("html").scrollTop()) {
  862. scrolltopValue = $("body").scrollTop()
  863. } else {
  864. scrolltopValue = $("html").scrollTop()
  865. }
  866. $("#WebUploadWidget").css("top", scrolltopValue)
  867. }, openComplete: function(uploadIdentifier, data) {
  868. CMApplication.Widgets.AdvancedUpload.setUploadProgress(uploadIdentifier, {
  869. total: CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].upload.total,
  870. current: CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].upload.total
  871. });
  872. clearTimeout(CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].progressTimer);
  873. uploadContainer = $('.WebUploadWidget[rel="' + uploadIdentifier + '"]');
  874. uploadContainer.addClass("complete").removeClass("instructions").removeClass("progress").removeClass("fileSelection");
  875. var files = [];
  876. var failedCnt = 0;
  877. if (typeof data == "string") {
  878. $(CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].files).each(function(key, value) {
  879. failedCnt++;
  880. value.isSuccess = false;
  881. value.statusMessage = data;
  882. files.push(value)
  883. })
  884. } else {
  885. $(data).each(function(key, value) {
  886. file = {
  887. name: value.filename
  888. };
  889. switch (value.statusCode) {
  890. case 0:
  891. file.isSuccess = true;
  892. file.size = value.link.size;
  893. file.id = value.link.id;
  894. break;
  895. default:
  896. file.isSuccess = false;
  897. file.statusMessage = value.statusMessage;
  898. failedCnt++
  899. }
  900. files.push(file)
  901. })
  902. }
  903. CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].files = files;
  904. uploadContainer = $('.WebUploadWidget[rel="' + uploadIdentifier + '"]');
  905. if (uploadContainer.length > 0) {
  906. CMApplication.Widgets.AdvancedUpload._updateFiles(uploadIdentifier);
  907. $("form, .progressbar", uploadContainer).remove();
  908. if (failedCnt == 0) {
  909. resultClass = "success";
  910. resultHeading = CMApplication.Dictionnary.YOU_SUCCESSFULLY_UPLOADED + " " + files.length + " file" + (files.length > 1 ? "s" : "")
  911. } else {
  912. if (files.length > failedCnt) {
  913. resultClass = "warning";
  914. resultHeading = CMApplication.Dictionnary.YOU_UPLOADED + " " + (files.length - failedCnt) + " of " + files.length + CMApplication.Dictionnary.FILES
  915. } else {
  916. resultClass = "error";
  917. resultHeading = CMApplication.Dictionnary.ERROR_DURING_THE_UPLOAD
  918. }
  919. }
  920. xhtml = "";
  921. xhtml += '<div class="WebUploadWidgetResult ' + resultClass + '">';
  922. xhtml += " <h4><span>" + resultHeading + "</span></h4>";
  923. xhtml += "</div>";
  924. if (files.length != failedCnt) {
  925. xhtml += ' <a href="' + CMApplication.URLs.languageFilesystemGenerateLink.replace(":id", "") + '" class="viewAllLinks"><span>' + CMApplication.Dictionnary.SHARE_FILES + "</span></a>"
  926. }
  927. uploadContainer.each(function(key, container) {
  928. if ($(container).parent().is("body")) {
  929. $(".WebUploadWidgetContainer", container).append(xhtml)
  930. } else {
  931. $(container).append(xhtml)
  932. }
  933. })
  934. }
  935. if ($("#fileBrowser").length == 1) {
  936. CMApplication.Widgets.FileManager.FileBrowser.browse()
  937. }
  938. $('iframe.webUploadProxy[name="' + uploadIdentifier + '"]').remove()
  939. }, openInstructions: function(uploadIdentifier) {
  940. CMApplication.Widgets.AdvancedUpload._open(uploadIdentifier);
  941. uploadContainer = $('.WebUploadWidget[rel="' + uploadIdentifier + '"]');
  942. uploadContainer.addClass("instructions").removeClass("complete").removeClass("fileSelection").removeClass("progress");
  943. if ($("div.instructions", uploadContainer).length == 0) {
  944. xhtml = "";
  945. xhtml += ' <div class="instructions">';
  946. xhtml += " <p>" + CMApplication.Dictionnary.CHOOSE_FILES_AND_THEN_PRESS_UPLOAD_NOW + "</p>";
  947. xhtml += " </div>";
  948. $(xhtml).insertAfter($("ul.actions", uploadContainer))
  949. }
  950. }, openFileSelection: function(uploadIdentifier) {
  951. CMApplication.Widgets.AdvancedUpload._open(uploadIdentifier);
  952. uploadContainer = $('.WebUploadWidget[rel="' + uploadIdentifier + '"]');
  953. uploadContainer.addClass("fileSelection").removeClass("complete").removeClass("instructions").removeClass("progress");
  954. $(".files label span", uploadContainer).text("Add More Files");
  955. if ($("table", uploadContainer).length == 0) {
  956. xhtml = "";
  957. xhtml += ' <div class="fileListing">';
  958. xhtml += " <table>";
  959. xhtml += " <thead>";
  960. xhtml += " <tr>";
  961. xhtml += ' <th class="fileName" colspan="2">' + CMApplication.Dictionnary.FILE_NAME + "</th>";
  962. xhtml += " </tr>";
  963. xhtml += " </thead>";
  964. xhtml += " <tbody>";
  965. xhtml += " </tbody>";
  966. xhtml += " </table>";
  967. xhtml += " </div>";
  968. $(xhtml).insertBefore($("form", uploadContainer))
  969. }
  970. }, openProgress: function(uploadIdentifier) {
  971. CMApplication.Widgets.AdvancedUpload._open(uploadIdentifier);
  972. uploadContainer = $('.WebUploadWidget[rel="' + uploadIdentifier + '"]');
  973. uploadContainer.addClass("progress").removeClass("complete").removeClass("instructions").removeClass("fileSelection");
  974. if ($("div.progressbar", uploadContainer).length == 0) {
  975. xhtml = "";
  976. xhtml += ' <div class="progressbar">';
  977. xhtml += " <strong>" + CMApplication.Dictionnary.PLEASE_WAIT + "</strong>";
  978. xhtml += ' <div class="total">';
  979. xhtml += ' <div class="progress">';
  980. xhtml += " </div>";
  981. xhtml += " </div>";
  982. xhtml += ' <div class="info">';
  983. xhtml += ' <span class="percent">0%</span>';
  984. xhtml += ' <span class="speed">0b/s</span>';
  985. xhtml += " </div>";
  986. xhtml += " </div>";
  987. $(xhtml).insertAfter($("form", uploadContainer));
  988. CMApplication.Widgets.AdvancedUpload.updateProgress(uploadIdentifier, 500)
  989. }
  990. }, updateProgress: function(uploadIdentifier, nextCallDelay) {
  991. uploadContainers = $('.WebUploadWidget[rel="' + uploadIdentifier + '"]');
  992. uploadContainers.each(function(key, value) {
  993. uploadContainer = $(value);
  994. if ($("div.progressbar", uploadContainer).length > 0) {
  995. myUpload = CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].upload;
  996. $("div.progressbar span.percent", uploadContainer).text(myUpload.percent + "%");
  997. $("div.progressbar span.speed", uploadContainer).text(CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.getHumanReadableSize(myUpload.speed) + "/s");
  998. newWidth = "" + Math.round(myUpload.percent) + "%";
  999. $(".progress", uploadContainer).css("width", newWidth)
  1000. }
  1001. })
  1002. }, getUploadProgress: function(uploadIdentifier) {
  1003. if (CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].upload.percent < 100) {
  1004. jQuery.ajax({
  1005. url: "/keep-alive.php",
  1006. cache: false,
  1007. global: false
  1008. });
  1009. xhtml = '<script type="text/javascript" src="' + CMApplication.URLs.uploadProgress.replace(":unique", new Date().getTime().toString()).replace(":hostserver", CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].originalAction).replace(":progress_key", uploadIdentifier).replace(":progress_key", uploadIdentifier) + '"><\/script>';
  1010. $("body").append(xhtml)
  1011. }
  1012. }, setUploadProgress: function(uploadIdentifier, data) {
  1013. if ("undefined" == (typeof CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier])) {
  1014. return
  1015. }
  1016. uploadStatus = CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].upload;
  1017. now = new Date().getTime();
  1018. uploadStatus.lastSize = uploadStatus.size;
  1019. uploadStatus.size = data.current;
  1020. uploadStatus.total = data.total;
  1021. uploadStatus.percent = Math.round(data.current * 100 / data.total);
  1022. if (uploadStatus.percent >= 100) {
  1023. clearTimeout(CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].progressTimer);
  1024. uploadStatus.percent = 100
  1025. }
  1026. if ("undefined" == (typeof uploadStatus.onePercentSize)) {
  1027. uploadStatus.onePercentSize = 1 / 100 * data.total
  1028. }
  1029. if (uploadStatus.lastUpdate != now) {
  1030. uploadStatus.speed = (uploadStatus.size - uploadStatus.lastSize) / ((parseInt(now) - parseInt(uploadStatus.lastUpdate)) / 1000)
  1031. } else {
  1032. uploadStatus.speed = 0
  1033. }
  1034. timerDelay = 0;
  1035. if (uploadStatus.percent < 100) {
  1036. nextSizeProgressCall = (uploadStatus.percent + 1) * uploadStatus.onePercentSize;
  1037. byteDiff = nextSizeProgressCall - uploadStatus.size;
  1038. timerDelay = Math.ceil(byteDiff / uploadStatus.speed * 1000);
  1039. if (timerDelay < 500) {
  1040. timerDelay = 300
  1041. }
  1042. if (timerDelay > 8000) {
  1043. timerDelay = 8000
  1044. }
  1045. CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].progressTimer = setTimeout("CMApplication.Widgets.AdvancedUpload.getUploadProgress('" + uploadIdentifier + "')", timerDelay)
  1046. }
  1047. uploadStatus.lastUpdate = now;
  1048. CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].upload = uploadStatus;
  1049. CMApplication.Widgets.AdvancedUpload.updateProgress(uploadIdentifier, timerDelay)
  1050. }, _updateFiles: function(uploadIdentifier) {
  1051. if ("undefined" == (typeof uploadIdentifier) && $("#WebUploadWidget").length > 0) {
  1052. uploadIdentifier = $("#WebUploadWidget").attr("rel")
  1053. }
  1054. if ("undefined" == (typeof uploadIdentifier)) {
  1055. return
  1056. }
  1057. uploadContainer = $('.WebUploadWidget[rel="' + uploadIdentifier + '"]');
  1058. filesElements = $('form input[type="file"]', uploadContainer);
  1059. if (filesElements.length > 0 && CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step != "complete") {
  1060. var files = [];
  1061. $(filesElements).each(function(key, input) {
  1062. if ("undefined" != (typeof input.files)) {
  1063. $(input.files).each(function(key, value) {
  1064. files.push({
  1065. name: value.name,
  1066. size: value.size
  1067. })
  1068. })
  1069. } else {
  1070. files.push({
  1071. name: $(input).val(),
  1072. size: null
  1073. })
  1074. }
  1075. });
  1076. CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier]["files"] = files
  1077. }
  1078. var xhtml = "";
  1079. var totalSize = 0;
  1080. $(CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier]["files"]).each(function(key, file) {
  1081. trClass = new Array();
  1082. if (CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step == "complete") {
  1083. trClass.push(file.isSuccess ? "success" : "fail")
  1084. }
  1085. if (! (key % 2)) {
  1086. trClass.push("odd")
  1087. }
  1088. xhtml += " <tr" + (trClass.length > 0 ? ' class="' + trClass.join(" ") + '"' : "") + (CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step == "complete" && file.isSuccess ? ' rel="F' + file.id + '"' : "") + ">";
  1089. colspan = 2;
  1090. addxhtml = "";
  1091. if (CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step == "complete") {
  1092. if (!file.isSuccess) {
  1093. colspan = 1;
  1094. addxhtml += ' <th class="message"><strong>' + CMApplication.Dictionnary.FAIL + "</strong> " + file.statusMessage + "</th>"
  1095. }
  1096. }
  1097. xhtml += ' <th class="fileName" colspan="' + colspan + '"><span>' + file.name + "</span></th>";
  1098. xhtml += addxhtml;
  1099. xhtml += " </tr>"
  1100. });
  1101. $("table tbody", uploadContainer).html(xhtml);
  1102. CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].upload.total = totalSize
  1103. }, _init: function() {
  1104. $("#div_adv_upload_files .chooseFiles a").live("click", function(e) {
  1105. e.preventDefault();
  1106. CMApplication.Widgets.AdvancedUpload.start()
  1107. });
  1108. $(".WebUploadWidget li.restore a").live("click", CMApplication.Widgets.AdvancedUpload.Events.restore);
  1109. $("#WebUploadMinimizer > ul.actions li.close a").live("click", function(e) {
  1110. e.preventDefault();
  1111. $("#WebUploadMinimizer .WebUploadWidget li.close a").trigger("click")
  1112. });
  1113. $(".WebUploadWidget li.close a, .WebUploadWidget .webUploadCancel").live("click", CMApplication.Widgets.AdvancedUpload.Events.close);
  1114. $(".WebUploadWidget li.minimize a").live("click", CMApplication.Widgets.AdvancedUpload.Events.minimize);
  1115. $(".WebUploadWidget.fileSelection form").live("submit", CMApplication.Widgets.AdvancedUpload.Events.submit);
  1116. if (jQuery.browser.msie) {
  1117. $('.WebUploadWidget.instructions input[type="file"]').live("click", function(e) {
  1118. $("#inputFileSelection").removeAttr("id");
  1119. clearTimeout(ieFixForFileSelectionOnChangeEventTimer);
  1120. $(this).attr("id", "inputFileSelection");
  1121. ieFixForFileSelectionOnChangeEventTimer = setTimeout("ieFixForFileSelectionOnChangeEvent()", 200)
  1122. })
  1123. }
  1124. $('.WebUploadWidget.instructions input[type="file"]').live("change", CMApplication.Widgets.AdvancedUpload.Events.addFilesFromInstructionStep);
  1125. $('.WebUploadWidget input[type="file"]').live("change", CMApplication.Widgets.AdvancedUpload.Events.addFiles);
  1126. $(".WebUploadWidget tbody td.share a").live("click", function(e) {
  1127. e.preventDefault();
  1128. CMApplication.Widgets.Dialog.displayUrl($(this).attr("href"))
  1129. });
  1130. $(".WebUploadWidget tbody td.link a").live("click", function(e) {
  1131. e.preventDefault();
  1132. $(this).closest("tr").next().toggle()
  1133. });
  1134. $(".WebUploadWidget tfoot td.link a").live("click", function(e) {
  1135. e.preventDefault();
  1136. $(".WebUploadWidgetContainer a.viewAllLinks", $(this).closest(".WebUploadWidget")).trigger("click")
  1137. });
  1138. $(".WebUploadWidgetContainer a.viewAllLinks").live("click", function(e) {
  1139. e.preventDefault();
  1140. var ids = new Array();
  1141. $('.WebUploadWidget[rel="' + $(this).closest(".WebUploadWidget").attr("rel") + '"] table tbody tr.success:not(.links)').each(function(key, value) {
  1142. ids.push($(value).attr("rel"))
  1143. });
  1144. CMApplication.Widgets.Dialog.displayUrl($(this).attr("href") + ids)
  1145. })
  1146. }
  1147. };
  1148. CMApplication.Widgets.Upload = {
  1149. Events: {
  1150. submit: function(event) {
  1151. uploadIdentifier = "upload_" + new Date().getTime() + "_" + CMApplication.User.sessId + "_" + Math.floor(Math.random() * 90000);
  1152. if (undefined != $("#input-file")[0] && undefined != $("#input-file")[0].files && undefined != $("#input-file")[0].files.length && $("#input-file")[0].files.length > 1) {
  1153. uploadFilename = "Upload of " + $("#input-file")[0].files.length + " files"
  1154. } else {
  1155. uploadFilename = $('input[type="file"]', this).val()
  1156. }
  1157. if (!$("form.webUpload").attr("originalAction")) {
  1158. $("form.webUpload").attr("originalAction", $("form.webUpload").attr("action"))
  1159. }
  1160. $("form.webUpload").attr("action", $("form.webUpload").attr("originalAction") + "/?X-Progress-ID=" + uploadIdentifier);
  1161. $("body").prepend('<iframe rel="' + uploadIdentifier + '" originalAction="' + $("form.webUpload").attr("originalAction") + '" class="upload" name="' + uploadIdentifier + '" src="#"></iframe>');
  1162. $(this).attr("target", uploadIdentifier);
  1163. CMApplication.Widgets.Upload.Progress._construct(uploadIdentifier, uploadFilename);
  1164. setTimeout("if ($('.webUpload').length > 0) $('.webUpload')[0].reset()", 500);
  1165. callbackUrlField = $('input[name="callbackUrl"]', this);
  1166. if (callbackUrlField.length == 0) {
  1167. callbackUrlField = jQuery('<input type="hidden" name="callbackUrl" value="" />').appendTo($(this))
  1168. }
  1169. callbackUrlField.val(CMApplication.URLs.domain + CMApplication.URLs.uploadCallback);
  1170. if (CMApplication.User.role == CMApplication.User.RolesValues.ANONYMOUS) {
  1171. $("#quickUpload").hide()
  1172. }
  1173. if (false && $("iframe.upload").length == 1) {
  1174. CMApplication.Widgets.Ajax.start()
  1175. }
  1176. }
  1177. }, Progress: {
  1178. InProgressTimer: {}, _construct: function(uploadIdentifier, uploadFilename) {
  1179. uploadStatusWrapper = $("#uploadStatusWrapper");
  1180. if (uploadStatusWrapper.length == 0) {
  1181. $('<div id="uploadStatusContainer"><h3>' + CMApplication.Dictionnary.YOUR_UPLOADS + '</h3><div id="uploadStatusWrapper"></div><a id="viewAllLinks" href="">' + CMApplication.Dictionnary.VIEW_ALL_LINKS + "</a></div>").appendTo("body");
  1182. $("#viewAllLinks").live("click", function(event) {
  1183. event.preventDefault();
  1184. var patt1 = new RegExp("[^/]*$");
  1185. var links = "";
  1186. $("#uploadStatusWrapper a.link").each(function() {
  1187. links += patt1.exec($(this).attr("href")) + ","
  1188. });
  1189. CMApplication.Widgets.Dialog.displayUrl(CMApplication.URLs.languageFilesystemGenerateLink.replace(":id", links))
  1190. });
  1191. uploadStatusWrapper = $("#uploadStatusWrapper")
  1192. }
  1193. if (uploadFilename.length > 37) {
  1194. uploadFilename = uploadFilename.substring(0, 17) + "..." + uploadFilename.substring(uploadFilename.length - 17)
  1195. }
  1196. uploadStatusWrapper.append('<div id="' + uploadIdentifier + '" class="uploadStatus"><span class="filename">' + uploadFilename + '</span><div class="progressBar"><div class="state"></div></div><span class="percentageCompleted"></span></div>');
  1197. CMApplication.Widgets.Upload.Progress.updateRequest(uploadIdentifier)
  1198. }, complete: function(uploadIdentifier, results) {
  1199. clearTimeout(CMApplication.Widgets.Upload.Progress.InProgressTimer[uploadIdentifier]);
  1200. $("#" + uploadIdentifier + " .progressBar").remove();
  1201. $('iframe[rel="' + uploadIdentifier + '"]').remove();
  1202. var xhtml = "";
  1203. var errorsMsg = "";
  1204. var successLinks = [];
  1205. $(results).each(function(key, value) {
  1206. xhtml += '<div class="element">';
  1207. if (value.statusCode == 0 && value.linkId != 0) {
  1208. successLinks.push(value.linkId)
  1209. } else {
  1210. xhtml += CMApplication.Dictionnary.ERROR + " <span>" + value.filename + "</span>";
  1211. errorsMsg += "<li><strong>" + value.filename + "</strong>: " + value.statusMessage + "</li>"
  1212. }
  1213. xhtml += "</div>"
  1214. });
  1215. if (successLinks.length > 0) {
  1216. viewLinkUrl = CMApplication.URLs.languageFilesystemGenerateLink.replace(":id", successLinks.join(","));
  1217. xhtml += '<div class="element">';
  1218. xhtml += CMApplication.Dictionnary.COMPLETED + " ";
  1219. xhtml += '<a href="' + viewLinkUrl + '" onclick="CMApplication.Widgets.Dialog.displayUrl(this.href, 700); return false;" class="link" title="' + CMApplication.Dictionnary.VIEW_LINKS + '"><span>' + CMApplication.Dictionnary.VIEW_LINKS + "</span></a>";
  1220. xhtml += "</div>"
  1221. }
  1222. xhtml += '<a href="#" onclick="CMApplication.Widgets.Upload.Progress.close(\'' + uploadIdentifier + '\'); return false;" class="close" title="' + CMApplication.Dictionnary.CLOSE + '"><span>' + CMApplication.Dictionnary.CLOSE + "</span></a>";
  1223. $("#" + uploadIdentifier + " .percentageCompleted").html(xhtml);
  1224. if (false && $("iframe.upload").length == 0) {
  1225. CMApplication.Widgets.Ajax.stop()
  1226. }
  1227. if (errorsMsg != "") {
  1228. errorsMsg = CMApplication.Dictionnary.FOLLOWING_ERROR_DURING_UPLOAD + "<ul>" + errorsMsg + "</ul>";
  1229. CMApplication.Widgets.Dialog.displayMessage(errorsMsg, CMApplication.Widgets.Dialog.Types.error)
  1230. }
  1231. }, close: function(uploadIdentifier) {
  1232. $("#" + uploadIdentifier).remove();
  1233. if ($("#uploadStatusWrapper").children().length == 0) {
  1234. $("#uploadStatusContainer").remove()
  1235. }
  1236. }, updateRequest: function(uploadIdentifier) {
  1237. jQuery.ajax({
  1238. url: "/keep-alive.php",
  1239. cache: false
  1240. });
  1241. xhtml = '<script type="text/javascript" src="' + CMApplication.URLs.uploadProgress.replace(":unique", new Date().getTime().toString()).replace(":hostserver", $('iframe[rel="' + uploadIdentifier + '"]').attr("originalAction")).replace(":progress_key", uploadIdentifier).replace(":progress_key", uploadIdentifier) + '"><\/script>';
  1242. CMApplication.Widgets.Upload.Progress.InProgressTimer[uploadIdentifier] = setTimeout("$('body').append('" + xhtml + "');", 2000)
  1243. }, updateResponse: function(uploadIdentifier, data) {
  1244. if ("undefined" != (typeof CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier])) {
  1245. CMApplication.Widgets.AdvancedUpload.setUploadProgress(uploadIdentifier, data)
  1246. } else {
  1247. if (data.current != null) {
  1248. percent = Math.ceil(parseInt(data.current) / parseInt(data.total) * 100).toString() + "%";
  1249. $("#" + uploadIdentifier + " .state").css("width", percent);
  1250. if (data.percent != 100) {
  1251. CMApplication.Widgets.Upload.Progress.updateRequest(uploadIdentifier);
  1252. $("#" + uploadIdentifier + " .percentageCompleted").text(percent)
  1253. }
  1254. }
  1255. }
  1256. }
  1257. }, _init: function() {
  1258. $(".webUpload").live("submit", CMApplication.Widgets.Upload.Events.submit)
  1259. }
  1260. };
  1261. CMApplication.Widgets.Internationalization = {
  1262. widgetLink: $("#internationalization"),
  1263. Events: {
  1264. open: function(e) {
  1265. if (!$(this).hasClass("active")) {
  1266. e.preventDefault();
  1267. e.stopPropagation();
  1268. CMApplication.Widgets.Internationalization.open(this)
  1269. }
  1270. }, close: function(e) {
  1271. CMApplication.Widgets.Internationalization.close()
  1272. }
  1273. }, open: function() {
  1274. this.widgetLink.addClass("active");
  1275. $(document).bind("click", this.Events.close)
  1276. }, close: function() {
  1277. this.widgetLink.removeClass("active");
  1278. $(document).unbind("click", this.Events.close)
  1279. }
  1280. };
  1281. CMApplication.Widgets.FolderBrowser = {
  1282. url: CMApplication.URLs.languageFilesystemBrowse.replace(/\/\:[a-z]*/gi, "") + "?partial=folderTree&widget=folderBrowser&orderFoldersBy=name&orderFoldersDirection=desc",
  1283. response: null,
  1284. browse: function(folderId) {
  1285. $("#selectAllFiles").attr("checked", null);
  1286. $("#globalSearch").attr("checked", null);
  1287. if (folderId == undefined) {
  1288. var myUrl = CMApplication.Widgets.FolderBrowser.url
  1289. } else {
  1290. var myUrl = CMApplication.Widgets.FolderBrowser.url.replace("list?", "list/" + folderId + "?")
  1291. }
  1292. $.ajax({
  1293. async: false,
  1294. url: myUrl,
  1295. dataType: "html",
  1296. success: function(data, textStatus, XMLHttpRequest) {
  1297. CMApplication.Widgets.FolderBrowser.response = data
  1298. }
  1299. });
  1300. list = "<ul>" + CMApplication.Widgets.FolderBrowser.response + "</ul>";
  1301. return list
  1302. }
  1303. };
  1304. CMApplication.Widgets.FileManager = {
  1305. Items: {
  1306. _items: {}, add: function(items) {
  1307. CMApplication.Widgets.FileManager.Items._items = jQuery.extend({}, CMApplication.Widgets.FileManager.Items._items, items)
  1308. }, getInfo: function(id) {
  1309. return CMApplication.Widgets.FileManager.Items._items[id]
  1310. }
  1311. }, History: {
  1312. log: [0],
  1313. current: 0,
  1314. addLog: function(folderId) {
  1315. CMApplication.Widgets.FileManager.History.log.push(folderId)
  1316. }
  1317. }, NavigationBar: {
  1318. Parent: {
  1319. linkElement: $("#navigationBar li.parent a"),
  1320. Events: {
  1321. click: function(event) {
  1322. event.preventDefault();
  1323. parentFolder = $("#folderTree li:has(li.active)");
  1324. if (parentFolder.length == 0) {
  1325. return
  1326. }
  1327. folderId = parentFolder.attr("rel");
  1328. CMApplication.Widgets.FileManager.FileBrowser.browse(folderId);
  1329. CMApplication.Widgets.FileManager.NavigationBar.Parent.updateLinkStyle()
  1330. }
  1331. }, updateLinkStyle: function() {
  1332. parentFolder = $("#folderTree li:has(li.active)");
  1333. linkElement = CMApplication.Widgets.FileManager.NavigationBar.Parent.linkElement;
  1334. if (parentFolder.length == 0) {
  1335. linkElement.addClass("disabled")
  1336. } else {
  1337. linkElement.removeClass("disabled")
  1338. }
  1339. }
  1340. }, New: {
  1341. linkElement: $("#navigationBar li.new a"),
  1342. Events: {
  1343. click: function(event) {
  1344. event.preventDefault();
  1345. currentFolderId = $("#folderTree li.active").attr("rel");
  1346. CMApplication.Widgets.FileManager.FileBrowser.newFolder(currentFolderId)
  1347. }
  1348. }
  1349. }, GenerateLink: {
  1350. linkElement: $("#navigationBar li.links a"),
  1351. Events: {
  1352. submit: function(event) {
  1353. event.preventDefault();
  1354. event.stopPropagation();
  1355. var myUrl = $(this).attr("action");
  1356. var myParams = $(this).serialize();
  1357. jQuery.ajax({
  1358. async: false,
  1359. url: myUrl,
  1360. type: "POST",
  1361. data: myParams,
  1362. dataType: "html",
  1363. success: function(data, textStatus, XMLHttpRequest) {
  1364. CMApplication.Widgets.Dialog.displayContent(data);
  1365. $("#linksForm").submit(CMApplication.Widgets.FileManager.NavigationBar.GenerateLink.Events.submit)
  1366. }
  1367. })
  1368. }, click: function(event) {
  1369. event.preventDefault();
  1370. elementsId = [];
  1371. $("#fileList li.selected").each(function() {
  1372. elementsId.push($(this).attr("rel"))
  1373. });
  1374. if (elementsId.length == 0) {
  1375. CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_GENERATELINKS_INSTRUCTION, CMApplication.Widgets.Dialog.Types.notice);
  1376. return
  1377. }
  1378. var xHtml = "";
  1379. jQuery.ajax({
  1380. async: false,
  1381. url: CMApplication.URLs.languageFilesystemGenerateLink.replace("/:id", ""),
  1382. type: "POST",
  1383. data: {
  1384. id: elementsId.join(",")
  1385. }, dataType: "html",
  1386. success: function(data, textStatus, XMLHttpRequest) {
  1387. xHtml = data
  1388. }
  1389. });
  1390. CMApplication.Widgets.Dialog.displayContent(xHtml);
  1391. $("#linksForm").submit(CMApplication.Widgets.FileManager.NavigationBar.GenerateLink.Events.submit)
  1392. }
  1393. }
  1394. }, Premium: {
  1395. linkElement: $("#navigationBar li.premium a"),
  1396. Events: {
  1397. click: function(event) {
  1398. if (!$("#selectAllFolder").attr("checked")) {
  1399. event.preventDefault();
  1400. elementsId = [];
  1401. $("#fileList li.selected").each(function() {
  1402. elementsId.push($(this).attr("rel"))
  1403. });
  1404. if (elementsId.length == 0) {
  1405. CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_PREMIUM_INSTRUCTION, CMApplication.Widgets.Dialog.Types.notice);
  1406. return
  1407. }
  1408. } else {
  1409. elementsId = [-1]
  1410. }
  1411. CMApplication.Widgets.FileManager.FileBrowser.premium(elementsId)
  1412. }
  1413. }, updateLinkStyle: function() {
  1414. parentFolder = $("#folderTree li:has(li.active)");
  1415. linkElement = CMApplication.Widgets.FileManager.NavigationBar.Premium.linkElement;
  1416. if ($("#fileList li.selected").length == 0) {
  1417. linkElement.addClass("disabled")
  1418. } else {
  1419. linkElement.removeClass("disabled")
  1420. }
  1421. }
  1422. }, Unpremium: {
  1423. linkElement: $("#navigationBar li.unsetPremium a"),
  1424. Events: {
  1425. click: function(event) {
  1426. event.preventDefault();
  1427. elementsId = [];
  1428. $("#fileList li.selected").each(function() {
  1429. elementsId.push($(this).attr("rel"))
  1430. });
  1431. if (elementsId.length == 0) {
  1432. CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_PREMIUM_INSTRUCTION, CMApplication.Widgets.Dialog.Types.notice);
  1433. return
  1434. }
  1435. CMApplication.Widgets.FileManager.FileBrowser.unpremium(elementsId)
  1436. }
  1437. }, updateLinkStyle: function() {
  1438. parentFolder = $("#folderTree li:has(li.active)");
  1439. linkElement = CMApplication.Widgets.FileManager.NavigationBar.Unpremium.linkElement;
  1440. if ($("#fileList li.selected").length == 0) {
  1441. linkElement.addClass("disabled")
  1442. } else {
  1443. linkElement.removeClass("disabled")
  1444. }
  1445. }
  1446. }, Upload: {
  1447. linkElement: $('#navigationBar li.upload a[href="#"]'),
  1448. Events: {
  1449. click: function(event) {
  1450. event.preventDefault();
  1451. CMApplication.Widgets.AdvancedUpload.start();
  1452. $("#WebUploadWidget .destinationFolderId").val($("#folderTree li.active").attr("rel").replace("D", ""))
  1453. }
  1454. }
  1455. }, updateLinksStyles: function() {
  1456. CMApplication.Widgets.FileManager.NavigationBar.Parent.updateLinkStyle();
  1457. CMApplication.Widgets.FileManager.NavigationBar.Premium.updateLinkStyle();
  1458. CMApplication.Widgets.FileManager.NavigationBar.Unpremium.updateLinkStyle();
  1459. $("#selectAllFiles").attr("checked", null)
  1460. }, _init: function() {
  1461. CMApplication.Widgets.FileManager.NavigationBar.updateLinksStyles();
  1462. CMApplication.Widgets.FileManager.NavigationBar.Parent.linkElement.bind("click", CMApplication.Widgets.FileManager.NavigationBar.Parent.Events.click);
  1463. CMApplication.Widgets.FileManager.NavigationBar.New.linkElement.bind("click", CMApplication.Widgets.FileManager.NavigationBar.New.Events.click);
  1464. CMApplication.Widgets.FileManager.NavigationBar.Upload.linkElement.bind("click", CMApplication.Widgets.FileManager.NavigationBar.Upload.Events.click);
  1465. CMApplication.Widgets.FileManager.NavigationBar.Premium.linkElement.bind("click", CMApplication.Widgets.FileManager.NavigationBar.Premium.Events.click);
  1466. CMApplication.Widgets.FileManager.NavigationBar.Unpremium.linkElement.bind("click", CMApplication.Widgets.FileManager.NavigationBar.Unpremium.Events.click);
  1467. CMApplication.Widgets.FileManager.NavigationBar.GenerateLink.linkElement.bind("click", CMApplication.Widgets.FileManager.NavigationBar.GenerateLink.Events.click)
  1468. }
  1469. }, NavigationHelper: {
  1470. selectAll: {
  1471. selectAll: function() {
  1472. if ($("input.select:not(:checked)").length) {
  1473. $("div.selectAll > input").attr("checked", true);
  1474. $("input.select:not(:checked)").attr("checked", true).parent("li").addClass("selected")
  1475. } else {
  1476. $("div.selectAll > input").attr("checked", false);
  1477. $("input.select:checked").attr("checked", false).parent("li").removeClass("selected")
  1478. }
  1479. CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.update();
  1480. CMApplication.Widgets.FileManager.NavigationBar.updateLinksStyles()
  1481. }
  1482. }, selectAllFolder: {
  1483. selectAllFolder: function() {
  1484. CMApplication.Widgets.FileManager.NavigationBar.updateLinksStyles()
  1485. }
  1486. }, sortBy: {
  1487. update: function() {
  1488. box = $("#sortForm");
  1489. type = $("select", box).val();
  1490. switch (type) {
  1491. case "folder":
  1492. $("li.size, li.downloads, li.sales", box).addClass("disabled");
  1493. break;
  1494. default:
  1495. $("li.size, li.downloads, li.sales", box).removeClass("disabled")
  1496. }
  1497. $("li.asc, li.desc", box).removeClass("asc").removeClass("desc");
  1498. $("li." + $('input[name="' + type + '_field"]', box).val(), box).addClass($('input[name="' + type + '_direction"]', box).val())
  1499. }, sortBy: function() {
  1500. $("#selectAllFiles").attr("checked", null);
  1501. if (window.location.href.indexOf(CMApplication.URLs.languageFilesystemRemoved) > -1) {
  1502. CMApplication.foward(CMApplication.URLs.languageFilesystemRemoved + "/1/" + $('#sortForm input[name="file_field"],#sortby').val() + "/" + $('#sortForm input[name="file_direction"],#direction').val())
  1503. } else {
  1504. type = $("#sortForm select").val();
  1505. if (type == "folder") {
  1506. var mylist = $("#ul_dirs");
  1507. var listitems = mylist.children("li").get();
  1508. listitems.sort(sortFolders);
  1509. $.each(listitems, function(idx, itm) {
  1510. mylist.append(itm)
  1511. });
  1512. ullist = $("#folderTree li. ul").get();
  1513. $.each(ullist, function(idx0, itm0) {
  1514. listitems = $(itm0).children("li").get();
  1515. listitems.sort(sortFolders);
  1516. $.each(listitems, function(idx, itm) {
  1517. $(itm0).append(itm)
  1518. })
  1519. })
  1520. } else {
  1521. CMApplication.Widgets.FileManager.FileBrowser.browse(undefined, false)
  1522. }
  1523. }
  1524. }
  1525. }, setDisplayLinks: {
  1526. setDisplayLinks: function() {
  1527. $.post("/file-manager/set-link-count", {
  1528. linkCount: $("#linksToDisplay").val()
  1529. }, function(data) {
  1530. CMApplication.Widgets.FileManager.FileBrowser.browse()
  1531. })
  1532. }
  1533. }, _init: function() {
  1534. $("div.selectAll a").live("click", function(event) {
  1535. event.preventDefault();
  1536. CMApplication.Widgets.FileManager.NavigationHelper.selectAll.selectAll()
  1537. });
  1538. $("div.selectAll input").live("click", function(event) {
  1539. CMApplication.Widgets.FileManager.NavigationHelper.selectAll.selectAll()
  1540. });
  1541. $("#selectAllFolder").live("click", function(event) {
  1542. CMApplication.Widgets.FileManager.NavigationHelper.selectAllFolder.selectAllFolder()
  1543. });
  1544. $("#linksToDisplay").live("change", function(event) {
  1545. $("#selectAllFiles").attr("checked", null);
  1546. CMApplication.Widgets.FileManager.NavigationHelper.setDisplayLinks.setDisplayLinks()
  1547. });
  1548. $("#searchForm").submit(function(event) {
  1549. event.preventDefault();
  1550. $(".paginator b").replaceWith($(".paginator b big a"));
  1551. $(".paginator > a:nth-child(2)").wrap("<b><big /></b>");
  1552. $("#selectAllFiles").attr("checked", false);
  1553. isSearchResult = $("#queryString").val();
  1554. if ($("#globalSearch").attr("checked")) {
  1555. isGlobalSearch = 1
  1556. }
  1557. CMApplication.Widgets.FileManager.FileBrowser.browse()
  1558. });
  1559. $("#sortForm").submit(function(event) {
  1560. event.preventDefault();
  1561. CMApplication.Widgets.FileManager.NavigationHelper.sortBy.sortBy()
  1562. });
  1563. $("#sortForm li:not(.disabled) a").click(function(event) {
  1564. event.preventDefault();
  1565. container = $("#sortForm");
  1566. isAsc = $(this).parent().hasClass("asc");
  1567. direction = isAsc ? "desc" : "asc";
  1568. $("li.asc, li.desc", container).removeClass("asc").removeClass("desc");
  1569. $(this).parent().addClass(direction);
  1570. field = $(this).parent().attr("class").replace("asc", "").replace("desc", "").replace(" ", "");
  1571. type = $("select", container).val();
  1572. $('#sortForm input[name="' + type + '_field"]').val(field);
  1573. $('#sortForm input[name="' + type + '_direction"]').val(direction);
  1574. CMApplication.Widgets.FileManager.NavigationHelper.sortBy.sortBy()
  1575. });
  1576. $("#sortForm select").change(function(event) {
  1577. event.preventDefault();
  1578. setTimeout("CMApplication.Widgets.FileManager.NavigationHelper.sortBy.update()", 200)
  1579. })
  1580. }
  1581. }, FileBrowser: {
  1582. browserElement: $("#fileBrowser"),
  1583. Events: {
  1584. browse: function(event) {
  1585. if ($(this).closest("li").attr("rel") == "D0") {
  1586. isGlobalSearch = 1;
  1587. $("#globalSearch").attr("checked", true);
  1588. $("#queryStringLabel span").text(CMApplication.Dictionnary.SEARCH_ALL_FOLDERS)
  1589. } else {
  1590. isGlobalSearch = 0;
  1591. $("#globalSearch").attr("checked", false);
  1592. $("#queryStringLabel span").text(CMApplication.Dictionnary.SEARCH_THIS_FOLDERS)
  1593. }
  1594. event.stopPropagation();
  1595. event.preventDefault();
  1596. isSearchResult = false;
  1597. $("#queryString").val("");
  1598. $("#selectAllFiles").attr("checked", false);
  1599. if ($(this).closest("li").hasClass("collapse")) {
  1600. $(this).closest("li").trigger("click")
  1601. }
  1602. CMApplication.Widgets.FileManager.FileBrowser.browse($(this).closest("li").attr("rel"))
  1603. }, search: function(event) {
  1604. event.stopPropagation();
  1605. event.preventDefault();
  1606. CMApplication.Widgets.FileManager.FileBrowser.browse($(this).closest("li").attr("rel"))
  1607. }
  1608. }, getUrl: function(folderId) {
  1609. if (folderId === undefined) {
  1610. folderId = $("#folderTree li.active").length == 1 ? $("#folderTree li.active").attr("rel") : "D0"
  1611. }
  1612. queryString = $("#queryString").val();
  1613. globalSearch = $("#globalSearch:checked").val() == 1 ? 1 : 0;
  1614. orderBy = $('#sortForm input[name="file_field"]').val();
  1615. orderDirection = $('#sortForm input[name="file_direction"]').val();
  1616. page = $('.paginator input[name="page"]').length == 1 ? parseInt($('.paginator input[name="page"]').val()) : 1;
  1617. myUrl = CMApplication.URLs.languageFilesystemBrowse;
  1618. myUrl = myUrl.replace(":folderId", urlencode(folderId));
  1619. myUrl = myUrl.replace(":page", urlencode(page));
  1620. myUrl = myUrl.replace(":orderBy", urlencode(orderBy));
  1621. myUrl = myUrl.replace(":orderDirection", urlencode(orderDirection));
  1622. myUrl = myUrl.replace(":globalSearch", urlencode(globalSearch));
  1623. myUrl = myUrl.replace(":queryString", urlencode(queryString));
  1624. return myUrl
  1625. }, browse: function(folderId, addLog) {
  1626. $("#selectAllFiles").attr("checked", false);
  1627. var addLog;
  1628. if (typeof(addLog) !== "boolean") {
  1629. addLog = true
  1630. }
  1631. if (folderId === undefined) {
  1632. folderId = $("#folderTree li.active").length == 1 ? $("#folderTree li.active").attr("rel") : "D0"
  1633. }
  1634. jQuery.ajax({
  1635. url: CMApplication.Widgets.FileManager.FileBrowser.getUrl(folderId) + "?partial=fileList",
  1636. type: "POST",
  1637. data: {
  1638. folderId: folderId
  1639. }, dataType: "html",
  1640. success: function(data, textStatus, XMLHttpRequest) {
  1641. queryParams = jQuery.unparam(this.data);
  1642. folderId = queryParams.folderId;
  1643. CMApplication.Widgets.FileManager.FileBrowser.FileList.populate(data, folderId);
  1644. CMApplication.Widgets.FileManager.FileBrowser.FolderTree.updateActiveElement(folderId);
  1645. if (addLog) {
  1646. CMApplication.Widgets.FileManager.History.addLog(folderId)
  1647. }
  1648. CMApplication.Widgets.FileManager.NavigationBar.updateLinksStyles();
  1649. CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.update()
  1650. }
  1651. })
  1652. }, move: function(filesId) {
  1653. if ($("#selectAllFiles").attr("checked")) {
  1654. if (typeof(totalItemCount) == "undefined") {
  1655. totalItemCount = totalFilesInFolder
  1656. }
  1657. if (totalItemCount > 100) {
  1658. if (!confirm("Are you sure you want to move " + totalItemCount + " files?")) {
  1659. return
  1660. }
  1661. }
  1662. }
  1663. if ($("#folderTree li.root > ul").length == 1) {
  1664. $("#folderTree li.root ul script").remove();
  1665. list = "<ul>" + $("#folderTree li.root > ul").html() + "</ul>"
  1666. } else {
  1667. list = CMApplication.Widgets.FolderBrowser.browse()
  1668. }
  1669. html = "<h4>" + CMApplication.Dictionnary.SELECT_A_DESTINATION + "</h4>";
  1670. var action = CMApplication.URLs.languageFilesystemMove;
  1671. html += '<form id="selectMoveDestinationForm" action="' + action + '"><div class="content folderTree" id="selectMoveDestination">';
  1672. html += ' <input type="hidden" name="destination" value="" />';
  1673. if (!$("#selectAllFiles").attr("checked")) {
  1674. for (i = 0; i < filesId.length; i++) {
  1675. html += ' <input type="hidden" name="files[]" value="' + filesId[i] + '" />'
  1676. }
  1677. }
  1678. if ($("#selectAllFiles").attr("checked")) {
  1679. currentFolder = $("#folderTree li.active").attr("rel");
  1680. if (isSearchResult) {
  1681. currentFolder = currentFolder + "|" + isSearchResult + "|" + isGlobalSearch
  1682. }
  1683. html += ' <input type="hidden" name="currentFolder" value="' + currentFolder + '" />'
  1684. }
  1685. html += ' <ul class="main">';
  1686. html += ' <li class="root active" rel="D0"><a href="#" class="highlight">root</a>' + list + "</li>";
  1687. html += " </ul>";
  1688. html += ' <button type="submit">' + CMApplication.Dictionnary.MOVE + "</button>";
  1689. html += ' <button type="reset" class="cancel">' + CMApplication.Dictionnary.CANCEL + "</button>";
  1690. html += "</div></form>";
  1691. CMApplication.Widgets.Dialog.displayContent(html, 450);
  1692. $("#selectMoveDestination li.root li a em").replaceWith($("#selectMoveDestination li.root li a em").text());
  1693. $("#selectMoveDestination li.root li.active").removeClass("active");
  1694. $('#selectMoveDestination button[type="submit"]').click(function(e) {
  1695. e.preventDefault();
  1696. if ($("#selectMoveDestination li.active").length > 0) {
  1697. $('#selectMoveDestinationForm input[name="destination"]').val($("#selectMoveDestination li.active").attr("rel"));
  1698. $.post($("#selectMoveDestinationForm").attr("action"), $("#selectMoveDestinationForm").serialize(), function(data, textStatus, XMLHttpRequest) {
  1699. currentFolder = $("#folderTree li.active").attr("rel");
  1700. destinationFolder = data.data.destination != "root" ? data.data.destination : "D0";
  1701. currentFolderIsDestination = data.data.destination == currentFolder || (data.data.destination == "root" && currentFolder == "D0");
  1702. if (data.status == "success" && !currentFolderIsDestination && !$("#selectAllFiles").attr("checked")) {
  1703. for (i in data.data.files) {
  1704. $('#fileList li[rel="' + data.data.files[i] + '"]').remove();
  1705. if ($('#folderTree li:not(.collapse)[rel="' + destinationFolder + '"]').length != 0) {
  1706. $('#folderTree li[rel="' + data.data.files[i] + '"]').appendTo('#folderTree li[rel="' + destinationFolder + '"] > ul')
  1707. } else {
  1708. $('#folderTree li[rel="' + data.data.files[i] + '"]').remove()
  1709. }
  1710. }
  1711. $("#selectAllFiles").attr("checked", false)
  1712. } else {
  1713. if ($("#selectAllFiles").attr("checked")) {
  1714. $("#fileList ul").empty()
  1715. }
  1716. }
  1717. CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.update();
  1718. CMApplication.Widgets.Dialog.close();
  1719. $("#selectAllFiles").attr("checked", false);
  1720. $("#globalSearch").attr("checked", false)
  1721. }, "json")
  1722. }
  1723. });
  1724. $('#selectMoveDestination button[type="reset"]').click(function(e) {
  1725. e.preventDefault();
  1726. CMApplication.Widgets.Dialog.close()
  1727. });
  1728. $("#selectMoveDestination li").die("click");
  1729. $("#selectMoveDestination li").live("click", function(e) {
  1730. e.preventDefault();
  1731. e.stopPropagation();
  1732. $(this).toggleClass("collapse");
  1733. if ($("ul", $(this)).length == 0) {
  1734. $(this).append(CMApplication.Widgets.FolderBrowser.browse($(this).attr("rel")))
  1735. }
  1736. });
  1737. $("#selectMoveDestination li a").die("click");
  1738. $("#selectMoveDestination li a").live("click", function(e) {
  1739. e.preventDefault();
  1740. $("#selectMoveDestination li.active").removeClass("active");
  1741. $("#selectMoveDestination li a.highlight").removeClass("highlight");
  1742. $(this).addClass("highlight");
  1743. $(this).parent().addClass("active")
  1744. })
  1745. }, copy: function(filesId) {
  1746. if ($("#selectAllFiles").attr("checked")) {
  1747. if (typeof(totalItemCount) == "undefined") {
  1748. totalItemCount = totalFilesInFolder
  1749. }
  1750. if (totalItemCount > 100) {
  1751. if (!confirm("Are you sure you want to copy " + totalItemCount + " files?")) {
  1752. return
  1753. }
  1754. }
  1755. }
  1756. if ($("#folderTree li.root > ul").length == 1) {
  1757. $("#folderTree li.root ul script").remove();
  1758. list = "<ul>" + $("#folderTree li.root > ul").html() + "</ul>"
  1759. } else {
  1760. list = CMApplication.Widgets.FolderBrowser.browse()
  1761. }
  1762. html = "<h4>" + CMApplication.Dictionnary.SELECT_A_DESTINATION + "</h4>";
  1763. html += '<form id="selectCopyDestinationForm" action="' + CMApplication.URLs.languageFilesystemCopy + '"><div class="content folderTree" id="selectCopyDestination">';
  1764. html += ' <input type="hidden" name="destination" value="" />';
  1765. if (filesId != -1) {
  1766. if (!$("#selectAllFiles").attr("checked")) {
  1767. for (i = 0; i < filesId.length; i++) {
  1768. html += ' <input type="hidden" name="files[]" value="' + filesId[i] + '" />'
  1769. }
  1770. }
  1771. if ($("#selectAllFiles").attr("checked")) {
  1772. currentFolder = $("#folderTree li.active").attr("rel");
  1773. if (isSearchResult) {
  1774. currentFolder = currentFolder + "|" + isSearchResult + "|" + isGlobalSearch
  1775. }
  1776. html += ' <input type="hidden" name="currentFolder" value="' + currentFolder + '" />'
  1777. }
  1778. } else {}
  1779. html += ' <ul class="main">';
  1780. html += ' <li class="root active" rel="D0"><a href="#" class="highlight">root</a>' + list + "</li>";
  1781. html += " </ul>";
  1782. html += ' <button type="submit">' + CMApplication.Dictionnary.COPY + "</button>";
  1783. html += ' <button type="reset" class="cancel">' + CMApplication.Dictionnary.CANCEL + "</button>";
  1784. html += "</div></form>";
  1785. CMApplication.Widgets.Dialog.displayContent(html, 450);
  1786. $("#selectCopyDestination li.root li a em").replaceWith($("#selectCopyDestination li.root li a em").text());
  1787. $("#selectCopyDestination li.root li.active").removeClass("active");
  1788. $('#selectCopyDestination button[type="submit"]').click(function(e) {
  1789. e.preventDefault();
  1790. if ($("#selectCopyDestination li.active").length > 0) {
  1791. $('#selectCopyDestinationForm input[name="destination"]').val($("#selectCopyDestination li.active").attr("rel"));
  1792. $.post($("#selectCopyDestinationForm").attr("action"), $("#selectCopyDestinationForm").serialize(), function(data, textStatus, XMLHttpRequest) {
  1793. currentFolder = $("#folderTree li.active").attr("rel");
  1794. destinationFolder = data.data.destination != "root" ? data.data.destination : "D0";
  1795. currentFolderIsDestination = data.data.destination == currentFolder || (data.data.destination == "root" && currentFolder == "D0");
  1796. if (data.status == "success") {
  1797. if (currentFolderIsDestination) {
  1798. files = data.infos;
  1799. for (var i in files) {
  1800. file = files[i];
  1801. fileId = i;
  1802. CMApplication.Widgets.FileManager.Items._items["F" + fileId] = CMApplication.Widgets.FileManager.Items._items[file.originalFileId];
  1803. CMApplication.Widgets.FileManager.Items._items["F" + fileId].directory_id = jQuery.unparam(this.data).destination;
  1804. originalElement = $('#fileList li[rel="' + file.originalFileId + '"]');
  1805. originalElement.clone().attr("rel", "F" + fileId).insertAfter(originalElement);
  1806. $('input[type="checkbox"]', originalElement).trigger("click");
  1807. $('#fileList li[rel="F' + fileId + '"] > a > span').text(file.name);
  1808. $('#fileList li[rel="F' + fileId + '"] > span.downloads').text("0");
  1809. $('#fileList li[rel="F' + fileId + '"] > input').val("F" + fileId);
  1810. var patt1 = new RegExp("[^/]+$");
  1811. $('#fileList li[rel="F' + fileId + '"] li a').each(function() {
  1812. $(this).attr("href", $(this).attr("href").replace(patt1, "F" + fileId))
  1813. })
  1814. }
  1815. CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.update()
  1816. }
  1817. CMApplication.Widgets.Dialog.close()
  1818. } else {
  1819. if (data.message == "space") {
  1820. CMApplication.Widgets.Dialog.displayUrl("/maximum-storage?type=copy", 500)
  1821. } else {
  1822. CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_COPY_UNABLE_TO_COPY + " #1", CMApplication.Widgets.Dialog.Types.error)
  1823. }
  1824. }
  1825. $("#selectAllFiles").attr("checked", false);
  1826. $("#globalSearch").attr("checked", false)
  1827. }, "json")
  1828. }
  1829. });
  1830. $('#selectCopyDestination button[type="reset"]').click(function(e) {
  1831. e.preventDefault();
  1832. CMApplication.Widgets.Dialog.close()
  1833. });
  1834. $("#selectCopyDestination li").die("click");
  1835. $("#selectCopyDestination li").live("click", function(e) {
  1836. e.preventDefault();
  1837. e.stopPropagation();
  1838. $(this).toggleClass("collapse");
  1839. if ($("ul", $(this)).length == 0) {
  1840. $(this).append(CMApplication.Widgets.FolderBrowser.browse($(this).attr("rel")))
  1841. }
  1842. });
  1843. $("#selectCopyDestination li a").die("click");
  1844. $("#selectCopyDestination li a").live("click", function(e) {
  1845. e.preventDefault();
  1846. $("#selectCopyDestination li.active").removeClass("active");
  1847. $("#selectCopyDestination li a.highlight").removeClass("highlight");
  1848. $(this).addClass("highlight");
  1849. $(this).parent().addClass("active")
  1850. })
  1851. }, newFolder: function(parentId) {
  1852. CMApplication.Widgets.Dialog.displayUrl(CMApplication.URLs.languageFilesystemCreate.replace(":parentId", parentId), 700);
  1853. editForm = $("form", CMApplication.Widgets.Dialog.dialogContainer);
  1854. $('select[name="parent_folder_id"]', editForm).val($("#folderTree li.active").attr("rel"));
  1855. editForm.bind("successCallback", function(event, data) {
  1856. if (data.status == "success") {
  1857. CMApplication.Widgets.FileManager.FileBrowser.FolderTree.createNode(data.infos)
  1858. } else {
  1859. CMApplication.Widgets.Dialog.displayMessage(data.messages.join("<br />"), CMApplication.Widgets.Dialog.Types.error)
  1860. }
  1861. })
  1862. }, trash: function(filesId) {
  1863. var filesId;
  1864. confirmation = confirm(CMApplication.Dictionnary.ARE_YOU_SURE_YOU_WANT_TO_DELETE_THESE_FILES);
  1865. if (!confirmation) {
  1866. return false
  1867. }
  1868. jQuery.ajax({
  1869. url: CMApplication.URLs.languageFilesystemTrash,
  1870. type: "post",
  1871. async: false,
  1872. data: {
  1873. files: filesId
  1874. }, dataType: "json",
  1875. success: function(data, textStatus, XMLHttpRequest) {
  1876. if (data.status == "success") {
  1877. CMApplication.Widgets.FileManager.deleteSelectedElement = true;
  1878. for (var i in data.data.files) {
  1879. if (data.data.files[i] == $("#itemInfo").attr("rel")) {
  1880. delete CMApplication.Widgets.FileManager.Items._items[data.data.files[i]];
  1881. $('#folderTree li[rel="' + data.data.files[i] + '"]').parent().closest("li").children("a").trigger("click")
  1882. }
  1883. $('li[rel="' + data.data.files[i] + '"]').remove()
  1884. }
  1885. } else {
  1886. CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_TRASH_UNABLE_TO_TRASH + " #1", CMApplication.Widgets.Dialog.Types.error)
  1887. }
  1888. CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.update()
  1889. }
  1890. })
  1891. }, premiumGeneral: function(filesId, premium) {
  1892. var add_msg;
  1893. if ($("#selectAllFiles").attr("checked")) {
  1894. if (typeof(totalItemCount) == "undefined") {
  1895. totalItemCount = totalFilesInFolder
  1896. }
  1897. add_msg = " (" + totalItemCount + ")"
  1898. } else {
  1899. add_msg = ""
  1900. }
  1901. var q = (premium) ? CMApplication.Dictionnary.ARE_YOU_SURE_YOU_WANT_TO_SET_THESE_FILES_ONLY_PREMIUM : CMApplication.Dictionnary.ARE_YOU_SURE_YOU_WANT_TO_UNSET_THESE_FILES_ONLY_PREMIUM;
  1902. var confirmation = confirm(q + add_msg);
  1903. if (!confirmation) {
  1904. return false
  1905. }
  1906. var filesId;
  1907. var currentFolder = "";
  1908. if (filesId != -1) {
  1909. if ($("#selectAllFiles").attr("checked")) {
  1910. currentFolder = $("#folderTree li.active").attr("rel");
  1911. if (isSearchResult) {
  1912. currentFolder = currentFolder + "|" + isSearchResult + "|" + isGlobalSearch
  1913. }
  1914. }
  1915. }
  1916. if (premium) {
  1917. var link_el = "premium";
  1918. var func_success = function(data, textStatus, XMLHttpRequest) {
  1919. if (data.status == "success") {
  1920. CMApplication.Widgets.FileManager.deleteSelectedElement = false;
  1921. for (var i in data.data.files) {
  1922. var a = $('#fileList li[rel="' + data.data.files[i] + '"] a');
  1923. if (!a.hasClass("isPremiumOnly")) {
  1924. a.addClass("isPremiumOnly")
  1925. }
  1926. }
  1927. } else {
  1928. CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_PREMIUM_UNABLE_TO_PREMIUM + " #1", CMApplication.Widgets.Dialog.Types.error)
  1929. }
  1930. }
  1931. } else {
  1932. var link_el = "unsetPremium";
  1933. var func_success = function(data, textStatus, XMLHttpRequest) {
  1934. if (data.status == "success") {
  1935. CMApplication.Widgets.FileManager.deleteSelectedElement = false;
  1936. for (var i in data.data.files) {
  1937. $('#fileList li[rel="' + data.data.files[i] + '"] a').removeClass("isPremiumOnly")
  1938. }
  1939. } else {
  1940. CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_PREMIUM_UNABLE_TO_PREMIUM + " #1", CMApplication.Widgets.Dialog.Types.error)
  1941. }
  1942. }
  1943. }
  1944. jQuery.ajax({
  1945. url: $("#navigationBar li." + link_el + " a").attr("href"),
  1946. type: "post",
  1947. async: false,
  1948. data: {
  1949. files: filesId,
  1950. currentFolder: currentFolder
  1951. }, dataType: "json",
  1952. success: func_success
  1953. })
  1954. }, premium: function(filesId) {
  1955. CMApplication.Widgets.FileManager.FileBrowser.premiumGeneral(filesId, 1)
  1956. }, unpremium: function(filesId) {
  1957. CMApplication.Widgets.FileManager.FileBrowser.premiumGeneral(filesId, 0)
  1958. }, FolderTree: {
  1959. Events: {
  1960. update: function(event) {
  1961. event.stopPropagation();
  1962. event.preventDefault();
  1963. elementContainer = $(this).children("ul");
  1964. if (elementContainer.length == 0) {
  1965. $(this).append("<ul></ul>");
  1966. elementContainer = $(this).children("ul")
  1967. }
  1968. url = $(this).children("a").attr("href");
  1969. if (url === undefined) {
  1970. url = location.href
  1971. }
  1972. $("#globalSearch").attr("checked", false);
  1973. elementContainer.load(url + "?partial=folderTree&orderFoldersBy=" + $('#sortForm input[name="folder_field"]').val() + "&orderFoldersDirection=" + $('#sortForm input[name="folder_direction"]').val())
  1974. }, toggleFolder: function(event) {
  1975. event.stopPropagation();
  1976. event.preventDefault();
  1977. if (!$(event.target).is("li") && !$(this).hasClass("collapse")) {
  1978. return
  1979. }
  1980. $(this).toggleClass("collapse");
  1981. if (!$(event.target).is("li")) {
  1982. return
  1983. }
  1984. if (!$(this).hasClass("collapse")) {
  1985. $(this).trigger("update")
  1986. }
  1987. }
  1988. }, createNode: function(infos) {
  1989. elementContainer = $('#folderTree li[rel="D' + infos.parent_id + '"] > ul');
  1990. if (elementContainer.length == 0) {
  1991. elementContainer = $("ul").appendTo('#folderTree li[rel="D' + infos.parent_id + '"]')
  1992. }
  1993. items = {};
  1994. items["D" + infos.id] = infos;
  1995. CMApplication.Widgets.FileManager.Items.add(items);
  1996. var today = new Date();
  1997. var today_str = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDay() + " " + today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
  1998. return $('<li rel="D' + infos.id + '" class="collapse" data-date="' + today_str + '"><a href="' + CMApplication.URLs.languageFilesystemBrowse.replace(":folderId", "D" + infos.id).replace(/\/\:[a-z]*/gi, "") + '">' + infos.name + "</a></li>").appendTo(elementContainer)
  1999. }, updateActiveElement: function(folderId) {
  2000. $("#folderTree li.active > a").text($("#folderTree li.active > a em").text());
  2001. $("#folderTree li.active").removeClass("active");
  2002. $('#folderTree li[rel="' + folderId + '"]').addClass("active");
  2003. $("#folderTree li.active > a").wrapInner("<em />")
  2004. }, _init: function() {
  2005. $("#folderTree li").live("update", CMApplication.Widgets.FileManager.FileBrowser.FolderTree.Events.update);
  2006. $("#folderTree li").live("click", CMApplication.Widgets.FileManager.FileBrowser.FolderTree.Events.toggleFolder);
  2007. $("#folderTree li a").live("click", CMApplication.Widgets.FileManager.FileBrowser.Events.browse);
  2008. $("#folderTree li.premium").bind("click", function(event) {
  2009. event.preventDefault()
  2010. })
  2011. }
  2012. }, ItemInfo: {
  2013. Item: {
  2014. Events: {
  2015. share: function(event) {
  2016. event.preventDefault();
  2017. var xHtml = "";
  2018. jQuery.ajax({
  2019. async: false,
  2020. url: CMApplication.URLs.languageFilesystemGenerateLink.replace(":id", ""),
  2021. type: "post",
  2022. data: {
  2023. id: $("#itemInfo").attr("rel")
  2024. }, dataType: "html",
  2025. success: function(data, textStatus, XMLHttpRequest) {
  2026. xHtml = data
  2027. }
  2028. });
  2029. CMApplication.Widgets.Dialog.displayContent(xHtml);
  2030. $("#linksForm").submit(CMApplication.Widgets.FileManager.NavigationBar.GenerateLink.Events.submit)
  2031. }, edit: function(event) {
  2032. event.preventDefault();
  2033. CMApplication.Widgets.Dialog.displayUrl($(this).attr("href"));
  2034. editForm = $("form", CMApplication.Widgets.Dialog.dialogContainer);
  2035. editForm.bind("successCallback", function(event, data) {
  2036. for (var key in data.data) {
  2037. if (key != "id") {
  2038. propertyExist = CMApplication.Widgets.FileManager.Items._items[data.data.id][key] != undefined;
  2039. if (propertyExist) {
  2040. CMApplication.Widgets.FileManager.Items._items[data.data.id][key] = data.data[key]
  2041. }
  2042. }
  2043. }
  2044. CMApplication.Widgets.FileManager.Items._items[data.data.id]["updated_on"] = "Now";
  2045. CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.update();
  2046. $('#folderTree li[rel="' + data.data.id + '"] > a > em').text(data.data.name);
  2047. $('#fileList li[rel="' + data.data.id + '"] > a span.fileName').text(data.data.name)
  2048. })
  2049. }, trash: function(event) {
  2050. event.preventDefault();
  2051. var fileId = new Array();
  2052. if ($("#itemInfo").attr("rel").indexOf(",") !== -1) {
  2053. fileId = $("#itemInfo").attr("rel").split(",")
  2054. } else {
  2055. fileId.push($("#itemInfo").attr("rel"))
  2056. }
  2057. CMApplication.Widgets.FileManager.FileBrowser.trash(fileId)
  2058. }, editMultiple: function(event) {
  2059. if ($("#selectAllFiles").attr("checked")) {
  2060. if (typeof(totalItemCount) == "undefined") {
  2061. totalItemCount = totalFilesInFolder
  2062. }
  2063. if (totalItemCount > 100) {
  2064. if (!confirm("Are you sure you want to edit " + totalItemCount + " files?")) {
  2065. return
  2066. }
  2067. }
  2068. currentFolderVal = $("#folderTree li.active").attr("rel");
  2069. if (isSearchResult) {
  2070. currentFolderVal = currentFolderVal + "|" + isSearchResult + "|" + isGlobalSearch
  2071. }
  2072. } else {
  2073. currentFolderVal = -1
  2074. }
  2075. event.preventDefault();
  2076. elementsId = "";
  2077. $("#fileList li.selected").each(function() {
  2078. elementsId = elementsId + "," + ($(this).attr("rel"))
  2079. });
  2080. elementsId = elementsId.substring(1);
  2081. CMApplication.Widgets.Dialog.displayUrl($(this).attr("href") + elementsId);
  2082. editMultipleForm = $("form", CMApplication.Widgets.Dialog.dialogContainer);
  2083. editMultipleForm.bind("successCallback", function(event, data) {
  2084. if (data.status == "success") {
  2085. if ($("#selectAllFiles").attr("checked")) {
  2086. setTimeout("CMApplication.Widgets.FileManager.FileBrowser.browse()", 500)
  2087. } else {
  2088. CMApplication.Widgets.FileManager.FileBrowser.browse()
  2089. }
  2090. } else {
  2091. CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.ERROR, CMApplication.Widgets.Dialog.Types.error)
  2092. }
  2093. });
  2094. $("#currentFolder").val(currentFolderVal)
  2095. }
  2096. }
  2097. }, _init: function() {
  2098. $("#itemInfo ul.action li.copy a").live("click", function(e) {
  2099. e.preventDefault();
  2100. id = new Array();
  2101. if ($("#itemInfo").attr("rel").indexOf(",") !== -1) {
  2102. id = $("#itemInfo").attr("rel").split(",")
  2103. } else {
  2104. id.push($("#itemInfo").attr("rel"))
  2105. }
  2106. CMApplication.Widgets.FileManager.FileBrowser.copy(id)
  2107. });
  2108. $("#itemInfo ul.action li.move a").live("click", function(e) {
  2109. e.preventDefault();
  2110. id = new Array();
  2111. if ($("#itemInfo").attr("rel").indexOf(",") !== -1) {
  2112. id = $("#itemInfo").attr("rel").split(",")
  2113. } else {
  2114. id.push($("#itemInfo").attr("rel"))
  2115. }
  2116. CMApplication.Widgets.FileManager.FileBrowser.move(id)
  2117. });
  2118. $("#itemInfo.isSelection ul.action li.edit a").live("click", CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.Item.Events.editMultiple);
  2119. $("#itemInfo:not(.isSelection) ul.action li.edit a").live("click", CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.Item.Events.edit);
  2120. $("#itemInfo ul.action li.trash a").live("click", CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.Item.Events.trash);
  2121. $("#itemInfo ul.action li.share a").live("click", CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.Item.Events.share)
  2122. }, getHumanReadableSize: function(size) {
  2123. size = parseFloat(size);
  2124. units = new Array();
  2125. units.push("B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB");
  2126. unit = units.shift();
  2127. cnt = 0;
  2128. now = new Date().getTime();
  2129. while (size >= 1024) {
  2130. if (++cnt > 8) {
  2131. break
  2132. }
  2133. size = size / 1024;
  2134. unit = units.shift()
  2135. }
  2136. result = (Math.round(size * 100) / 100).toString() + " " + unit;
  2137. return result
  2138. }, update: function() {
  2139. switch ($("body#FileSystem_Index #fileList li input:checked").length) {
  2140. case 0:
  2141. CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.updateFolder($("#folderTree li.active").attr("rel"));
  2142. break;
  2143. case 1:
  2144. CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.updateFile($("#fileList li input:checked").val());
  2145. break;
  2146. default:
  2147. var ids = new Array();
  2148. $("#fileList li input:checked").each(function() {
  2149. ids.push($(this).val())
  2150. });
  2151. if (!$("#selectAllFiles").attr("checked")) {
  2152. CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.updateFiles(ids)
  2153. } else {
  2154. CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.selectAllFiles(ids)
  2155. }
  2156. break
  2157. }
  2158. }, updateFolder: function(id) {
  2159. if ("undefined" == (typeof id)) {
  2160. return
  2161. }
  2162. if (id == "D0") {
  2163. $("#itemInfo").removeClass("isFile").removeClass("isSelection").addClass("isFolder").html("").hide();
  2164. return
  2165. }
  2166. fileInfo = CMApplication.Widgets.FileManager.Items.getInfo(id);
  2167. xHtml = "";
  2168. xHtml += '<strong class="label"><span>' + fileInfo.name + "</span></strong>";
  2169. xHtml += '<ul class="action">';
  2170. xHtml += ' <li class="move"><a href="' + CMApplication.URLs.languageFilesystemMove.replace(":id", id) + '" title="Move"><span>' + CMApplication.Dictionnary.MOVE + "</span></a>";
  2171. xHtml += ' <li class="edit"><a href="' + CMApplication.URLs.languageFilesystemEdit.replace(":id", id) + '" title="Edit"><span>' + CMApplication.Dictionnary.EDIT + "</span></a>";
  2172. xHtml += ' <li class="trash"><a href="' + CMApplication.URLs.languageFilesystemTrash.replace(":id", id) + '" title="Trash"><span>' + CMApplication.Dictionnary.TRASH + "</span></a>";
  2173. xHtml += ' <li class="share"><a href="' + CMApplication.URLs.languageFilesystemGenerateLink.replace(":id", id) + '" title="Share"><span>' + CMApplication.Dictionnary.SHARE + "</span></a>";
  2174. xHtml += "</ul>";
  2175. if (typeof(totalItemCount) == "undefined") {
  2176. totalItemCount = totalFilesInFolder
  2177. }
  2178. xHtml += '<div class="info">';
  2179. xHtml += ' <span class="isPublic">' + (fileInfo.is_public == 1 ? "Public" : "Private") + "</span>";
  2180. xHtml += ' <span class="contain">Contain ' + totalItemCount + " files</span>";
  2181. xHtml += "</div>";
  2182. if (fileInfo.description != "") {
  2183. xHtml += '<div class="description">';
  2184. xHtml += ' <span class="field">' + CMApplication.Dictionnary.DESCRIPTION + "</span>";
  2185. xHtml += ' <span class="value">' + fileInfo.description + "</span>";
  2186. xHtml += "</div>"
  2187. }
  2188. if (fileInfo.created_on != null) {
  2189. xHtml += '<div class="createdOn">';
  2190. xHtml += ' <span class="field">' + CMApplication.Dictionnary.DATE_CREATED + "</span>";
  2191. xHtml += ' <span class="value">' + fileInfo.created_on + "</span>";
  2192. xHtml += "</div>"
  2193. }
  2194. if (fileInfo.created_on != fileInfo.updated_on) {
  2195. xHtml += '<div class="updatedOn">';
  2196. xHtml += ' <span class="field">' + CMApplication.Dictionnary.DATE_UPDATED + "</span>";
  2197. xHtml += ' <span class="value">' + fileInfo.updated_on + "</span>";
  2198. xHtml += "</div>"
  2199. }
  2200. xHtml += '<div class="links">';
  2201. if (fileInfo.is_public == 1) {
  2202. url = "http://www.wupload.com/folder/" + (fileInfo.unique_id != "" ? fileInfo.unique_id : fileInfo.id);
  2203. xHtml += " <textarea>" + url + "</textarea>"
  2204. } else {
  2205. xHtml += "<em>" + CMApplication.Dictionnary.MUST_BE_PUBLIC + "</em>"
  2206. }
  2207. xHtml += "</div>";
  2208. $("#itemInfo").attr("rel", id).removeClass("isFile").removeClass("isSelection").addClass("isFolder").html(xHtml).show()
  2209. }, updateFile: function(id) {
  2210. fileInfo = CMApplication.Widgets.FileManager.Items.getInfo(id);
  2211. switch (fileInfo.source_id) {
  2212. case 1:
  2213. itemSource = CMApplication.Dictionnary.COPY;
  2214. break;
  2215. case 6:
  2216. case 2:
  2217. itemSource = CMApplication.Dictionnary.WEB_UPLOAD;
  2218. break;
  2219. case 3:
  2220. case 4:
  2221. itemSource = CMApplication.Dictionnary.REMOTE_UPLOAD;
  2222. break;
  2223. case 5:
  2224. itemSource = "FTP";
  2225. break;
  2226. default:
  2227. itemSource = CMApplication.Dictionnary.UNKNOWN
  2228. }
  2229. xHtml = "";
  2230. xHtml += '<strong class="label"><span>' + fileInfo.name + "</span></strong>";
  2231. xHtml += '<ul class="action">';
  2232. xHtml += ' <li class="copy"><a href="' + CMApplication.URLs.languageFilesystemCopy.replace(":id", id) + '" title="Copy"><span>' + CMApplication.Dictionnary.COPY + "</span></a>";
  2233. xHtml += ' <li class="move"><a href="' + CMApplication.URLs.languageFilesystemMove.replace(":id", id) + '" title="Move"><span>' + CMApplication.Dictionnary.MOVE + "</span></a>";
  2234. xHtml += ' <li class="edit"><a href="' + CMApplication.URLs.languageFilesystemEdit.replace(":id", id) + '" title="Edit"><span>' + CMApplication.Dictionnary.EDIT + "</span></a>";
  2235. xHtml += ' <li class="trash"><a href="' + CMApplication.URLs.languageFilesystemTrash.replace(":id", id) + '" title="Trash"><span>' + CMApplication.Dictionnary.TRASH + "</span></a>";
  2236. xHtml += ' <li class="share"><a href="' + CMApplication.URLs.languageFilesystemGenerateLink.replace(":id", id) + '" title="Share"><span>' + CMApplication.Dictionnary.SHARE + "</span></a>";
  2237. xHtml += ' <li class="download"><a href="' + CMApplication.URLs.languageDownload.replace(":id", id.replace("F", "")) + '" title="Download"><span>' + CMApplication.Dictionnary.DOWNLOAD_LINK + "</span></a>";
  2238. xHtml += "</ul>";
  2239. xHtml += '<div class="info">';
  2240. xHtml += ' <span class="size">' + CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.getHumanReadableSize(fileInfo.size) + "</span>";
  2241. if (fileInfo.premium_only == 1) {
  2242. xHtml += ' <span class="premiumOnly">Premium Only</span>'
  2243. }
  2244. xHtml += ' <span class="password">' + (fileInfo.password != null && fileInfo.password != "" ? "Has password" : "No password") + "</span>";
  2245. xHtml += ' <span class="source">Via ' + itemSource + "</span>";
  2246. xHtml += "</div>";
  2247. if (fileInfo.description != "") {
  2248. xHtml += '<div class="description">';
  2249. xHtml += ' <span class="field">' + CMApplication.Dictionnary.DESCRIPTION + "</span>";
  2250. xHtml += ' <span class="value">' + fileInfo.description + "</span>";
  2251. xHtml += "</div>"
  2252. }
  2253. xHtml += '<div class="createdOn">';
  2254. xHtml += ' <span class="field">' + CMApplication.Dictionnary.DATE_CREATED + "</span>";
  2255. xHtml += ' <span class="value">' + fileInfo.created_on + "</span>";
  2256. xHtml += "</div>";
  2257. if (fileInfo.created_on != fileInfo.updated_on) {
  2258. xHtml += '<div class="updatedOn">';
  2259. xHtml += ' <span class="field">' + CMApplication.Dictionnary.DATE_UPDATED + "</span>";
  2260. xHtml += ' <span class="value">' + fileInfo.updated_on + "</span>";
  2261. xHtml += "</div>"
  2262. }
  2263. xHtml += '<div class="links">';
  2264. url = "http://www.wupload.com/file/" + fileInfo.id;
  2265. xHtml += " <textarea>" + url + "</textarea>";
  2266. xHtml += "</div>";
  2267. $("#itemInfo").attr("rel", id).removeClass("isFolder").removeClass("isSelection").addClass("isFile").html(xHtml).show()
  2268. }, updateFiles: function(ids) {
  2269. xHtml = "";
  2270. xHtml += '<strong class="label"><span>' + ids.length + " files selected</span></strong>";
  2271. totalSize = 0;
  2272. for (i = 0; i < ids.length; i++) {
  2273. fileInfo = CMApplication.Widgets.FileManager.Items.getInfo(ids[i]);
  2274. totalSize += fileInfo.size
  2275. }
  2276. xHtml += '<ul class="action">';
  2277. xHtml += ' <li class="copy"><a href="' + CMApplication.URLs.languageFilesystemCopy.replace(":id", "") + '" title="Copy"><span>' + CMApplication.Dictionnary.COPY + "</span></a>";
  2278. xHtml += ' <li class="move"><a href="' + CMApplication.URLs.languageFilesystemMove.replace(":id", "") + '" title="Move"><span>' + CMApplication.Dictionnary.MOVE + "</span></a>";
  2279. xHtml += ' <li class="edit"><a href="' + CMApplication.URLs.languageFilesystemEditMultiple.replace(":id", "") + '" title="Edit"><span>' + CMApplication.Dictionnary.EDIT + "</span></a>";
  2280. xHtml += ' <li class="trash"><a href="' + CMApplication.URLs.languageFilesystemTrash.replace(":id", "") + '" title="Trash"><span>' + CMApplication.Dictionnary.TRASH + "</span></a>";
  2281. xHtml += ' <li class="share"><a href="' + CMApplication.URLs.languageFilesystemGenerateLink.replace(":id", ids.join(",")) + '" title="Share"><span>' + CMApplication.Dictionnary.SHARE + "</span></a>";
  2282. xHtml += "</ul>";
  2283. xHtml += '<div class="info">';
  2284. xHtml += ' <span class="size">' + CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.getHumanReadableSize(totalSize) + "</span>";
  2285. xHtml += "</div>";
  2286. xHtml += '<div class="links">';
  2287. xHtml += " <textarea>";
  2288. $(ids).each(function() {
  2289. xHtml += "http://www.wupload.com/file/" + this.replace("F", "") + "\n"
  2290. });
  2291. xHtml += "</textarea>";
  2292. xHtml += "</div>";
  2293. $("#itemInfo").attr("rel", ids.join(",")).removeClass("isFolder").removeClass("isFile").addClass("isSelection").html(xHtml).show()
  2294. }, selectAllFiles: function(ids) {
  2295. xHtml = "";
  2296. var msg = "";
  2297. if (typeof(totalItemCount) == "undefined") {
  2298. totalItemCount = totalFilesInFolder
  2299. }
  2300. if (isSearchResult) {
  2301. msg = totalItemCount + ' files selected<br>("' + isSearchResult + '" - search results)'
  2302. } else {
  2303. msg = totalItemCount + " files selected (full dir)"
  2304. }
  2305. xHtml += '<strong class="label"><span>' + msg + "</span></strong>";
  2306. if (totalItemCount <= ids.length) {
  2307. totalSize = 0;
  2308. for (i = 0; i < ids.length; i++) {
  2309. fileInfo = CMApplication.Widgets.FileManager.Items.getInfo(ids[i]);
  2310. totalSize += fileInfo.size
  2311. }
  2312. xHtml += '<ul class="action">';
  2313. xHtml += ' <li class="copy"><a href="' + CMApplication.URLs.languageFilesystemCopy.replace(":id", "") + '" title="Copy"><span>' + CMApplication.Dictionnary.COPY + "</span></a>";
  2314. xHtml += ' <li class="move"><a href="' + CMApplication.URLs.languageFilesystemMove.replace(":id", "") + '" title="Move"><span>' + CMApplication.Dictionnary.MOVE + "</span></a>";
  2315. xHtml += ' <li class="edit"><a href="' + CMApplication.URLs.languageFilesystemEditMultiple.replace(":id", "") + '" title="Edit"><span>' + CMApplication.Dictionnary.EDIT + "</span></a>";
  2316. xHtml += ' <li class="trash"><a href="' + CMApplication.URLs.languageFilesystemTrash.replace(":id", "") + '" title="Trash"><span>' + CMApplication.Dictionnary.TRASH + "</span></a>";
  2317. xHtml += ' <li class="share"><a href="' + CMApplication.URLs.languageFilesystemGenerateLink.replace(":id", ids.join(",")) + '" title="Share"><span>' + CMApplication.Dictionnary.SHARE + "</span></a>";
  2318. xHtml += "</ul>";
  2319. xHtml += '<div class="info">';
  2320. xHtml += ' <span class="size">' + CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.getHumanReadableSize(totalSize) + "</span>";
  2321. xHtml += "</div>";
  2322. xHtml += '<div class="links">';
  2323. xHtml += " <textarea>";
  2324. $(ids).each(function() {
  2325. xHtml += "http://www.wupload.com/file/" + this.replace("F", "") + "\n"
  2326. });
  2327. xHtml += "</textarea>";
  2328. xHtml += "</div>";
  2329. $("#itemInfo").attr("rel", ids.join(",")).removeClass("isFolder").removeClass("isFile").addClass("isSelection").html(xHtml).show()
  2330. } else {
  2331. xHtml += '<ul class="action">';
  2332. xHtml += ' <li class="copy"><a href="' + CMApplication.URLs.languageFilesystemCopy.replace(":id", "") + '" title="Copy"><span>' + CMApplication.Dictionnary.COPY + "</span></a>";
  2333. xHtml += ' <li class="move"><a href="' + CMApplication.URLs.languageFilesystemMove.replace(":id", "") + '" title="Move"><span>' + CMApplication.Dictionnary.MOVE + "</span></a>";
  2334. xHtml += ' <li class="edit"><a href="' + CMApplication.URLs.languageFilesystemEditMultiple.replace(":id", "") + '" title="Edit"><span>' + CMApplication.Dictionnary.EDIT + "</span></a>";
  2335. xHtml += ' <li class="share"><a href="' + CMApplication.URLs.languageFilesystemGenerateLink.replace(":id", ids.join(",")) + '" title="Share"><span>' + CMApplication.Dictionnary.SHARE + "</span></a>";
  2336. xHtml += "</ul>";
  2337. $("#itemInfo").attr("rel", ids.join(",")).removeClass("isFolder").removeClass("isFile").addClass("isSelection").html(xHtml).show()
  2338. }
  2339. }
  2340. }, FileList: {
  2341. deleteSelectedElement: false,
  2342. Item: {
  2343. Events: {
  2344. share: function(event) {
  2345. event.preventDefault();
  2346. var xHtml = "";
  2347. jQuery.ajax({
  2348. async: false,
  2349. url: $(this).attr("href"),
  2350. type: "GET",
  2351. dataType: "html",
  2352. success: function(data, textStatus, XMLHttpRequest) {
  2353. xHtml = data
  2354. }
  2355. });
  2356. CMApplication.Widgets.Dialog.displayContent(xHtml);
  2357. $("#linksForm").submit(CMApplication.Widgets.FileManager.NavigationBar.GenerateLink.Events.submit)
  2358. }, edit: function(event) {
  2359. event.preventDefault();
  2360. CMApplication.Widgets.Dialog.displayUrl($(this).attr("href"));
  2361. editForm = $("form", CMApplication.Widgets.Dialog.dialogContainer);
  2362. editForm.bind("successCallback", function(event, data) {
  2363. items = {};
  2364. items["F" + data.infos.id] = data.infos;
  2365. CMApplication.Widgets.FileManager.Items.add(items);
  2366. CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.update();
  2367. $('#fileList li[rel="F' + data.infos.id + '"] > a span').text(data.infos.name)
  2368. })
  2369. }, copy: function(event) {
  2370. event.preventDefault();
  2371. var ids = new Array($(this).parents("li[rel]").attr("rel"));
  2372. CMApplication.Widgets.FileManager.FileBrowser.copy(ids)
  2373. }, move: function(event) {
  2374. event.preventDefault();
  2375. var ids = new Array($(this).parents("li[rel]").attr("rel"));
  2376. CMApplication.Widgets.FileManager.FileBrowser.move(ids)
  2377. }, trash: function(event) {
  2378. event.preventDefault();
  2379. var fileId = new Array();
  2380. fileId[0] = $(this).closest("#fileList > ul > li").attr("rel");
  2381. CMApplication.Widgets.FileManager.FileBrowser.trash(fileId)
  2382. }, premium: function(event) {
  2383. event.preventDefault();
  2384. var fileId = new Array();
  2385. fileId[0] = $(this).closest("#fileList > ul > li").attr("rel");
  2386. CMApplication.Widgets.FileManager.FileBrowser.premium(fileId)
  2387. }
  2388. }, _init: function() {
  2389. $("#fileList ul.fileAction li.copy a").live("click", CMApplication.Widgets.FileManager.FileBrowser.FileList.Item.Events.copy);
  2390. $("#fileList ul.fileAction li.move a").live("click", CMApplication.Widgets.FileManager.FileBrowser.FileList.Item.Events.move);
  2391. $("#fileList ul.fileAction li.share a").live("click", CMApplication.Widgets.FileManager.FileBrowser.FileList.Item.Events.share);
  2392. $("#fileList ul.fileAction li.edit a").live("click", CMApplication.Widgets.FileManager.FileBrowser.FileList.Item.Events.edit);
  2393. $("#fileList ul.fileAction li.trash a").live("click", CMApplication.Widgets.FileManager.FileBrowser.FileList.Item.Events.trash);
  2394. $("#fileList ul.fileAction li.premium a").live("click", CMApplication.Widgets.FileManager.FileBrowser.FileList.Item.Events.premium)
  2395. }
  2396. }, createNode: function(id, name, isDir, size, downloads, extension) {
  2397. elementContainer = $("#fileList > ul");
  2398. xhtml = "";
  2399. xhtml += '<li rel="' + id + '"' + (isDir ? ' class="folder"' : "") + ">\n";
  2400. xhtml += ' <input type="checkbox" class="select" value="' + id + '" />\n';
  2401. xhtml += " <a" + (!isDir ? ' class="ext_' + extension + '"' : "") + "><span>" + name + "</span></a>\n";
  2402. xhtml += ' <span class="size">' + size + "</span>\n";
  2403. xhtml += ' <span class="downloads">' + (!isDir ? downloads : "&nbsp;") + "</span>\n";
  2404. xhtml += ' <ul class="fileAction">\n';
  2405. xhtml += ' <li class="share"><a title="' + CMApplication.Dictionnary.SHARE + '" href="' + CMApplication.URLs.languageFilesystemGenerateLink.replace(":id", id) + '">' + CMApplication.Dictionnary.SHARE + "</a></li>\n";
  2406. xhtml += ' <li class="edit"><a title="' + CMApplication.Dictionnary.EDIT + '" href="' + CMApplication.URLs.languageFilesystemEdit.replace(":id", id) + '">' + CMApplication.Dictionnary.EDIT + "</a></li>\n";
  2407. xhtml += ' <li class="trash"><a title="' + CMApplication.Dictionnary.TRASH + '" href="' + CMApplication.URLs.languageFilesystemTrash.replace(":id", id) + '">' + CMApplication.Dictionnary.TRASH + "</a></li>\n";
  2408. xhtml += " </ul>\n";
  2409. if (!isDir) {
  2410. newElement = $(xhtml).appendTo(elementContainer)
  2411. } else {
  2412. newElement = $(xhtml).prependTo(elementContainer)
  2413. }
  2414. return newElement
  2415. }, populate: function(content, folderId) {
  2416. $("#fileList").html(content);
  2417. $(".navigationHelper .paginator").replaceWith($("#fileList .paginator"))
  2418. }, Selection: function(event, selectAll) {
  2419. isOriginalCheckboxClick = event.clientX !== undefined;
  2420. if ((isOriginalCheckboxClick && $(this).is(":checked")) || (!isOriginalCheckboxClick && !$(this).is(":checked"))) {
  2421. $(this).parent("li").addClass("selected");
  2422. $("#selectAllFolder").attr("checked", false)
  2423. } else {
  2424. $("#selectAllFiles").attr("checked", false);
  2425. $(this).parent("li").removeClass("selected")
  2426. }
  2427. CMApplication.Widgets.FileManager.NavigationBar.updateLinksStyles();
  2428. if (selectAll !== true) {
  2429. setTimeout("CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.update()", 1)
  2430. }
  2431. }, _init: function() {
  2432. $("#fileList > ul > li:has(input.select:checked)").addClass("selected");
  2433. $("#fileList > ul > li input.select").live("click", CMApplication.Widgets.FileManager.FileBrowser.FileList.Selection);
  2434. $("#fileList > ul > li").live("mousedown", function(event) {
  2435. if ($(event.target).is("li") || $(event.target).is("#fileList > ul > li > a, #fileList > ul > li > a span")) {
  2436. $("input.select", this).click()
  2437. }
  2438. });
  2439. CMApplication.Widgets.FileManager.NavigationHelper.sortBy.update()
  2440. }
  2441. }
  2442. }, adjustFileBrowserHeight: function() {
  2443. fileManagerHeight = $(window).height();
  2444. $("#fileManager").css("height", fileManagerHeight);
  2445. fileBrowserHeight = fileManagerHeight - ($("#fileBrowser").outerHeight() - $("#fileBrowser").height());
  2446. $("#fileManager > *:not(#fileBrowser)").each(function() {
  2447. fileBrowserHeight -= $(this).outerHeight()
  2448. });
  2449. if (fileBrowserHeight < 200) {
  2450. fileBrowserHeight = 200;
  2451. $("#fileManager").css("height", fileManagerHeight + fileBrowserHeight)
  2452. }
  2453. $("#fileBrowser").css("height", fileBrowserHeight);
  2454. $("#fileBrowser").css("display", "block")
  2455. }, _init: function() {
  2456. CMApplication.Widgets.FileManager.FileBrowser.ItemInfo._init();
  2457. CMApplication.Widgets.FileManager.FileBrowser.FileList._init();
  2458. CMApplication.Widgets.FileManager.FileBrowser.FileList.Item._init();
  2459. CMApplication.Widgets.FileManager.FileBrowser.FolderTree._init();
  2460. CMApplication.Widgets.FileManager.NavigationBar._init();
  2461. CMApplication.Widgets.FileManager.NavigationHelper._init();
  2462. CMApplication.Widgets.FileManager.adjustFileBrowserHeight();
  2463. if ($("#fileManager").length == 1) {
  2464. window.location.href = "#fileManager"
  2465. }
  2466. $("#fileManager > .exportLinks a").live("click", function(e) {
  2467. e.preventDefault();
  2468. if ($(this).is("#exportFolderLinks")) {
  2469. url = CMApplication.URLs.languageFilesystemExportFolderLinks.replace(":folderId", $("#folderTree li.active").attr("rel").replace("D", "")) + "/" + $("#typeExport").val()
  2470. } else {
  2471. url = $(this).attr("href") + "/-1/" + $("#typeExport").val()
  2472. }
  2473. window.open(url)
  2474. })
  2475. }
  2476. };
  2477. CMApplication.Widgets.Login = {
  2478. widgetLink: $("#lMainUsage li.login a:not(.active,.signup,.lang)"),
  2479. widgetContainer: $("#loginWidget"),
  2480. Events: {
  2481. open: function(e) {
  2482. e.preventDefault();
  2483. if (!$(this).hasClass("active")) {
  2484. e.stopPropagation();
  2485. CMApplication.Widgets.Login.open(this)
  2486. }
  2487. }, close: function(e) {
  2488. clickedElement = $(e.target);
  2489. isChild = CMApplication.Widgets.Login.widgetContainer.has(clickedElement).length > 0;
  2490. isSame = CMApplication.Widgets.Login.widgetContainer[0] === clickedElement[0];
  2491. if (!isChild && !isSame) {
  2492. e.preventDefault();
  2493. CMApplication.Widgets.Login.close()
  2494. }
  2495. }, submit: function(e) {
  2496. e.preventDefault();
  2497. CMApplication.Widgets.Login.submit($(this))
  2498. }
  2499. }, open: function() {
  2500. this.widgetLink.addClass("active");
  2501. this.widgetContainer.show();
  2502. $(document).bind("click", this.Events.close)
  2503. }, close: function() {
  2504. this.widgetContainer.hide();
  2505. this.widgetLink.removeClass("active");
  2506. $(document).unbind("click", this.Events.close)
  2507. }, submit: function(form) {
  2508. jQuery.ajax({
  2509. data: form.serialize(),
  2510. dataType: "json",
  2511. cache: false,
  2512. url: form.attr("action"),
  2513. type: form.attr("method"),
  2514. success: function(data, textStatus, XMLHttpRequest) {
  2515. try {
  2516. if (data.status == "success") {
  2517. if ($.browser.webkit) {
  2518. $("form", CMApplication.Widgets.Login.widgetContainer).unbind("submit");
  2519. $("form", CMApplication.Widgets.Login.widgetContainer).submit()
  2520. } else {
  2521. if (data.redirect) {
  2522. CMApplication.foward(data.redirect)
  2523. }
  2524. }
  2525. } else {
  2526. msg = CMApplication.Dictionnary.UNEXPECTED_PROCESS_ERROR + "\n\n";
  2527. for (var field in data.messages) {
  2528. msg += field + ":\n";
  2529. value = data.messages[field];
  2530. if (typeof(value) === "object") {
  2531. for (var subfield in value) {
  2532. msg += " - " + value[subfield] + "\n"
  2533. }
  2534. } else {
  2535. msg += " - " + value + "\n"
  2536. }
  2537. }
  2538. CMApplication.Widgets.Dialog.displayMessage(msg, CMApplication.Widgets.Dialog.Types.error)
  2539. }
  2540. } catch(e) {
  2541. if (e == "d is null") {
  2542. e = e + " (" + textStatus + ") / " + XMLHttpRequest.responseText
  2543. }
  2544. CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.LOGIN_UNEXPECTED_PROCESS_ERROR + " #1" + e, CMApplication.Widgets.Dialog.Types.exception)
  2545. }
  2546. }
  2547. })
  2548. }, decode: function(input) {
  2549. var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  2550. var output = "";
  2551. var chr1, chr2, chr3;
  2552. var enc1, enc2, enc3, enc4;
  2553. var i = 0;
  2554. input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
  2555. while (i < input.length) {
  2556. enc1 = _keyStr.indexOf(input.charAt(i++));
  2557. enc2 = _keyStr.indexOf(input.charAt(i++));
  2558. enc3 = _keyStr.indexOf(input.charAt(i++));
  2559. enc4 = _keyStr.indexOf(input.charAt(i++));
  2560. chr1 = (enc1 << 2) | (enc2 >> 4);
  2561. chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
  2562. chr3 = ((enc3 & 3) << 6) | enc4;
  2563. output = output + String.fromCharCode(chr1);
  2564. if (enc3 != 64) {
  2565. output = output + String.fromCharCode(chr2)
  2566. }
  2567. if (enc4 != 64) {
  2568. output = output + String.fromCharCode(chr3)
  2569. }
  2570. }
  2571. return output
  2572. }, _init: function() {
  2573. CMApplication.Widgets.Login.widgetLink.bind("click", CMApplication.Widgets.Login.Events.open);
  2574. $("form", CMApplication.Widgets.Login.widgetContainer).bind("submit", CMApplication.Widgets.Login.Events.submit)
  2575. }
  2576. };
  2577. jQuery.extend(CMApplication.Bootstrap, {
  2578. _initPremiumPurchase: CMApplication.Widgets.Purchase._init,
  2579. _initUser: function() {
  2580. CMApplication.User.sessId = jQuery.getCookie("PHPSESSID");
  2581. CMApplication.User.email = jQuery.getCookie("email");
  2582. CMApplication.User.isAffiliate = jQuery.getCookie("isAffiliate") == 1;
  2583. if (jQuery.getCookie("role") == CMApplication.User.RolesNames[2]) {
  2584. CMApplication.User.role = CMApplication.User.RolesNames[2]
  2585. } else {
  2586. if (jQuery.getCookie("role") == CMApplication.User.RolesNames[1]) {
  2587. CMApplication.User.role = CMApplication.User.RolesNames[1]
  2588. } else {
  2589. CMApplication.User.role = CMApplication.User.RolesNames[0]
  2590. }
  2591. }
  2592. }, _initLayout: CMApplication.Layout._init,
  2593. _initLoginWidget: CMApplication.Widgets.Login._init,
  2594. _initInternationalizationWidget: function() {
  2595. CMApplication.Widgets.Internationalization.widgetLink.bind("click", CMApplication.Widgets.Internationalization.Events.open)
  2596. }, _initViewportAdjustment: function() {
  2597. CMApplication.Viewport.adjust();
  2598. window.onresize = CMApplication.Viewport.adjust
  2599. }, _initAdvancedUpload: CMApplication.Widgets.AdvancedUpload._init,
  2600. _initUpload: CMApplication.Widgets.Upload._init,
  2601. _initFileManager: CMApplication.Widgets.FileManager._init,
  2602. _initDownload: CMApplication.Pages.Download._init,
  2603. _initToolsUserMenu: CMApplication.Widgets.Tools._init,
  2604. _initStatsUserMenu: CMApplication.Widgets.Stats._init,
  2605. _initStats: function() {
  2606. $("#use_points").live("click", function(event) {
  2607. event.preventDefault();
  2608. CMApplication.Widgets.Dialog.displayUrl(this.href, undefined, "inlineStyle", event.target);
  2609. $("#DialogWidgetContent #upgradeAccount form").die("successCallback");
  2610. $("#DialogWidgetContent #upgradeAccount form").die("failCallback");
  2611. $("#DialogWidgetContent #upgradeAccount form").live("successCallback", function() {
  2612. alert("Completed, thank you")
  2613. });
  2614. $("#DialogWidgetContent #upgradeAccount form").live("failCallback", function(a, b) {
  2615. alert("Error while executing request:\n\n- " + b.messages.join("\n- "))
  2616. })
  2617. });
  2618. $("#statisticSales a").live("click", function(event) {
  2619. event.preventDefault();
  2620. CMApplication.Widgets.Dialog.displayUrl(this.href, 600, "inlineStyle", event.target)
  2621. })
  2622. }, _initFaq: function() {
  2623. $('body#Support_Faq .CL3 a[href^="#"], body#Support_Faq .CL3 a[href^="' + window.location.href.replace(window.location.hash, "") + '#"]').live("click", function(e) {
  2624. e.preventDefault();
  2625. $($(this).attr("href").replace(window.location.href.replace(window.location.hash, ""), "")).toggleClass("odd")
  2626. })
  2627. }, _initNews: function() {
  2628. $("body#News_Index #newsPosts h3").live("click", function(e) {
  2629. e.preventDefault();
  2630. $(this).parent().toggleClass("openPost")
  2631. })
  2632. }, _initDialog: CMApplication.Widgets.Dialog._init,
  2633. _initGenerateLink: function() {
  2634. $("#DialogWidgetContent .fileLinks a,#DialogWidgetContent .emailLinks a").live("click", function(e) {
  2635. e.preventDefault();
  2636. files = new Array();
  2637. $('input[name="id[]"]').each(function(index) {
  2638. files[index] = $(this).val()
  2639. });
  2640. jQuery.ajax({
  2641. url: $(this).attr("href"),
  2642. type: "post",
  2643. async: false,
  2644. data: {
  2645. files: files.join(",")
  2646. }, dataType: "html",
  2647. success: function(data, textStatus, XMLHttpRequest) {
  2648. CMApplication.Widgets.Dialog.displayContent(data)
  2649. }
  2650. })
  2651. });
  2652. $("#linksForm textarea, #linksForm input").live("focus", function() {
  2653. $(this).select()
  2654. });
  2655. $("#linksForm #outputType, #linksForm #selectFileName, #linksForm #domainName").live("change", function(e) {
  2656. files = new Array();
  2657. $('input[name="id[]"]').each(function(index) {
  2658. files[index] = $(this).val()
  2659. });
  2660. jQuery.ajax({
  2661. url: CMApplication.URLs.languageFilesystemGenerateLink.replace(":id", files.join(",")),
  2662. type: "post",
  2663. async: false,
  2664. data: {
  2665. id: files.join(","),
  2666. outputType: $("#outputType").val(),
  2667. selectFileName: $("#selectFileName").val()
  2668. }, dataType: "html",
  2669. success: function(data, textStatus, XMLHttpRequest) {
  2670. CMApplication.Widgets.Dialog.displayContent(data)
  2671. }
  2672. })
  2673. })
  2674. }, _initManageFilesHelp: function() {
  2675. $("#fileManager p.help a").live("click", function(event) {
  2676. event.preventDefault();
  2677. CMApplication.Widgets.Dialog.displayUrl($(this).attr("href"), 900)
  2678. })
  2679. }, _initManageSecurityQuestions: function() {
  2680. $("#User_Settings .securityQuestion, #User_Settings .securityQuestionModify").live("click", function(event) {
  2681. event.preventDefault();
  2682. CMApplication.Widgets.Dialog.displayUrl($(this).attr("href"), 500)
  2683. })
  2684. }, _initHelp: function() {
  2685. $("a.help").live("click", function(event) {
  2686. event.preventDefault();
  2687. CMApplication.Widgets.Dialog.displayUrl($(this).attr("href"), undefined, "inlineStyle", event.target)
  2688. })
  2689. }, _initMaximumStorage: function() {
  2690. $(".maximumStorage").live("click", function(event) {
  2691. event.preventDefault();
  2692. CMApplication.Widgets.Dialog.displayUrl("/maximum-storage", 500)
  2693. })
  2694. }, _initAffiliatePlanA: function() {
  2695. $("#Affiliates_Index #affiliatePlans a.affiliatePlanA").live("click", function(event) {
  2696. event.preventDefault();
  2697. CMApplication.Widgets.Dialog.displayUrl(this.href, 636, "defaultStyle affiliatePlanA")
  2698. })
  2699. }, _initAffiliatePlanB: function() {
  2700. $("#Affiliates_Index #affiliatePlans a.affiliatePlanB").live("click", function(event) {
  2701. event.preventDefault();
  2702. CMApplication.Widgets.Dialog.displayUrl(this.href, 636, "defaultStyle affiliatePlanB ")
  2703. })
  2704. }, _initAffiliatePlanC: function() {
  2705. $("#Affiliates_Index #affiliatePlans a.affiliatePlanC").live("click", function(event) {
  2706. event.preventDefault();
  2707. CMApplication.Widgets.Dialog.displayUrl(this.href, 900, "defaultStyle affiliatePlanC ")
  2708. })
  2709. }
  2710. });
  2711. $("body.FileSystem div.paginator a").live("click", function(event) {
  2712. if (window.location.href.indexOf(CMApplication.URLs.languageFilesystemRemoved) == -1) {
  2713. event.preventDefault();
  2714. currentPage = parseInt($(this).siblings('input[name="page"]').val());
  2715. if ($(this).hasClass("previous")) {
  2716. if (currentPage > 1) {
  2717. $(this).siblings('input[name="page"]').val(currentPage - 1);
  2718. CMApplication.Widgets.FileManager.FileBrowser.browse()
  2719. }
  2720. } else {
  2721. if ($(this).hasClass("next")) {
  2722. if (currentPage < parseInt($(this).siblings(".total").text())) {
  2723. $(this).siblings('input[name="page"]').val(currentPage + 1);
  2724. CMApplication.Widgets.FileManager.FileBrowser.browse()
  2725. }
  2726. } else {
  2727. if ($(this).hasClass("first")) {
  2728. if (currentPage > 1) {
  2729. $(this).siblings('input[name="page"]').val(1);
  2730. CMApplication.Widgets.FileManager.FileBrowser.browse()
  2731. }
  2732. } else {
  2733. if ($(this).hasClass("last")) {
  2734. var last = parseInt($(this).siblings(".total").text());
  2735. if (currentPage < last) {
  2736. $(this).siblings('input[name="page"]').val(last);
  2737. CMApplication.Widgets.FileManager.FileBrowser.browse()
  2738. }
  2739. }
  2740. }
  2741. }
  2742. }
  2743. } else {
  2744. return true
  2745. }
  2746. });
  2747. $('body.FileSystem div.paginator input[name="page"]').live("change", function(event) {
  2748. if (window.location.href.indexOf(CMApplication.URLs.languageFilesystemRemoved) == -1) {
  2749. event.preventDefault();
  2750. CMApplication.Widgets.FileManager.FileBrowser.browse()
  2751. } else {
  2752. return true
  2753. }
  2754. });
  2755. CMApplication.Bootstrap.run()
  2756. });
  2757. window.onbeforeunload = function(a) {
  2758. message = null;
  2759. try {
  2760. if ($("iframe.webUploadProxy").length || $("iframe.upload").length) {
  2761. if (typeof a == "undefined") {
  2762. a = window.event
  2763. }
  2764. if (a) {
  2765. a.returnValue = CMApplication.Dictionnary.LEAVING_WILL_CANCEL_UPLOADS
  2766. }
  2767. return message
  2768. }
  2769. } catch(b) {}
  2770. };
  2771.  
  2772. function sortList(c) {
  2773. var b = document.getElementById(c);
  2774. for (var e in b.childNodes) {
  2775. var a = b.childNodes[e];
  2776. for (var d in b.childNodes) {
  2777. var f = b.childNodes[d];
  2778. if ((a.innerText != "undefined" || f.innerText != "undefined") && a.innerText > f.innerText) {
  2779. if (b.firstChild != a) {
  2780. b.insertBefore(f, a)
  2781. }
  2782. }
  2783. }
  2784. }
  2785. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement