Vlad Kurkin (b_vladi) wrote in changelog,
Vlad Kurkin
b_vladi
changelog

[livejournal] r20849: LJSUP-10799: Check radio-buttons at Mana...

Committer: vkurkin
LJSUP-10799: Check radio-buttons at Manage Userpics
U   trunk/htdocs/js/editpics.js
Modified: trunk/htdocs/js/editpics.js
===================================================================
--- trunk/htdocs/js/editpics.js	2011-12-23 08:35:16 UTC (rev 20848)
+++ trunk/htdocs/js/editpics.js	2011-12-23 08:36:52 UTC (rev 20849)
@@ -2,85 +2,111 @@
 var uploadInProgress = false;
 var pbar = new LJProgressBar();
 
-function submitForm () {
-  if (uptrack) uptrack.stopTracking();
+function submitForm() {
+	if (uptrack) {
+		uptrack.stopTracking();
+	}
 
-  uploadInProgress = true;
+	uploadInProgress = true;
 
-  var frm = $("uploadPic");
-  var postgoto = $("go_to");
+	var frm = $("uploadPic");
+	var postgoto = $("go_to");
 
-  if (!frm || !postgoto) return;
+	if (!frm || !postgoto) {
+		return;
+	}
 
-  // to $POST{'go_to'} value of "jscallup" means our iframe returns a javascript
-  // document that calls up to us to tell us it's done.
-  postgoto.value = "jscallup";
+	// to $POST{'go_to'} value of "jscallup" means our iframe returns a javascript
+	// document that calls up to us to tell us it's done.
+	postgoto.value = "jscallup";
 
-  frm.target = "upiframe";
-  uptrack = new UploadTracker(frm, uploadCallback);
+	frm.target = "upiframe";
+	uptrack = new UploadTracker(frm, uploadCallback);
 
-  $("uploadStatus").innerHTML = "Uploading, please wait...";
-  $("progressBar").style.display = "block";
-  $("uploadStatus").style.display = "block";
-  return true;
+	$("uploadStatus").innerHTML = "Uploading, please wait...";
+	$("progressBar").style.display = "block";
+	$("uploadStatus").style.display = "block";
+	return true;
 }
 
 // called from iframe's content (manage/uploaded) on complete, after
 // uptrackWebUpload.pm redirects the iframe there:
-function onUploadComplete (gotoUrl) {
-  if (!uploadInProgress) return; // silly IE, caching the iframe's content
+function onUploadComplete(gotoUrl) {
+	if (!uploadInProgress) {
+		return;
+	} // silly IE, caching the iframe's content
 
-  if (uptrack) uptrack.stopTracking();
+	if (uptrack) {
+		uptrack.stopTracking();
+	}
 
-  if (pbar)
-    pbar.setIndefinite(true);
+	if (pbar) {
+		pbar.setIndefinite(true);
+	}
 
-  $("uploadStatus").innerHTML = "Upload complete.";
+	$("uploadStatus").innerHTML = "Upload complete.";
 
-  window.location = gotoUrl;
+	window.location = gotoUrl;
 }
 
 // called by the perlbal upload tracker library
-function uploadCallback (data) {
-  if (! (data && data.total)) return;
-  if (pbar) {
-    pbar.setMax(data.total);
-    pbar.setValue(data.done);
-  }
-  var percent = Math.floor(data.done/data.total*100);
-  var status = Math.floor(data.done / 1024) + " kB / " + Math.floor(data.total / 1024) + " kB, " + percent + "% complete";
-  $("uploadStatus").innerHTML = status;
+function uploadCallback(data) {
+	if (! (data && data.total)) {
+		return;
+	}
+	if (pbar) {
+		pbar.setMax(data.total);
+		pbar.setValue(data.done);
+	}
+	var percent = Math.floor(data.done / data.total * 100);
+	$("uploadStatus").innerHTML = Math.floor(data.done / 1024) + " kB / " + Math.floor(data.total / 1024) + " kB, " + percent + "% complete";
 }
 
-function setup () {
-  if (!$("progressBar"))
-    return;
+function setup() {
+	if (!$("progressBar")) {
+		return;
+	}
 
-  if (pbar)
-    pbar.init($("progressBar"));
+	if (pbar) {
+		pbar.init($("progressBar"));
+	}
 
-  $("progressBar").className="lj_progresscontainer";
+	$("progressBar").className = "lj_progresscontainer";
 }
 
 function editpicsInit() {
-    if ($("upload_desc_link")) {
-        $("upload_desc_link").style.display = 'block';
-        $("upload_desc").style.display = 'none';
-    }
+	if ($("upload_desc_link")) {
+		$("upload_desc_link").style.display = 'block';
+		$("upload_desc").style.display = 'none';
+	}
 
-    if ($("upload_desc_photo_link")) {
-        $("upload_desc_photo_link").style.display = 'block';
-        $("upload_desc_photo").style.display = 'none';
-    }
+	if ($("upload_desc_photo_link")) {
+		$("upload_desc_photo_link").style.display = 'block';
+		$("upload_desc_photo").style.display = 'none';
+	}
+
+	var radio_file = jQuery('#radio_file'), radio_url = jQuery('#radio_url'), input_file = jQuery('input[name=userpic]'), input_url = jQuery('input[name=urlpic]');
+
+	if (radio_file.length && input_file.length) {
+		input_file.bind('change', function() {
+			radio_file.attr('checked', true);
+		});
+	}
+
+	if (radio_url.length && input_url.length) {
+		input_url.input(function() {
+			radio_url.attr('checked', true);
+		});
+	}
 }
 
 function toggleElement(elementId) {
-    var el = $(elementId);
-    if (el && el.style.display == 'block') {
-        el.style.display = 'none';
-    } else {
-        el.style.display = 'block';
-    }
+	var el = $(elementId);
+	if (el && el.style.display == 'block') {
+		el.style.display = 'none';
+	} else {
+		el.style.display = 'block';
+	}
 }
 
 DOM.addEventListener(window, "load", setup);

Tags: b_vladi, js, livejournal, vkurkin
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments