spacevillain (spacevillain) wrote in changelog,
spacevillain
spacevillain
changelog

[ljcom] r11830: LJSUP-11857: Cyr sub domains

Committer: atyurin
LJSUP-11857: Cyr sub domains
ajax add/delete
U   trunk/htdocs/js/pay.js
U   trunk/htdocs/shop/selfpromo.bml.text.local
U   trunk/templates/Shop/DomainRU.tmpl
Modified: trunk/htdocs/js/pay.js
===================================================================
--- trunk/htdocs/js/pay.js	2012-04-26 14:30:00 UTC (rev 11829)
+++ trunk/htdocs/js/pay.js	2012-04-26 14:31:27 UTC (rev 11830)
@@ -532,6 +532,115 @@
 			})
 			.change(); // init
 		});
+	},
+
+	cyrillicDomains: function() {
+
+		var shop 			= jQuery('#shop_domainru'),
+			tabs 			= shop.find('.m-buy-types'),
+			domainForm		= shop.find('form'),
+			
+			domainField 	= domainForm.find('.b-domainru-field'),
+			domainInput		= domainField.find('#src_name'),
+
+			authas 			= domainForm.find('[name="authas"]'),
+			tos 			= domainForm.find('#domainru-confirm'),
+			submitButton	= domainForm.find('[type="submit"]'),
+
+			domainTemplate	= jQuery("#domainTemplate"),
+			domains 		= jQuery(".b-domainru-domains").children('tbody'),
+			
+			removeLinks 	= jQuery('.b-domainru-remove');
+
+		var errorClass = [],
+			endpoint = LiveJournal.getAjaxUrl('domain_ru');
+
+		domainInput.input(function() {
+			if (jQuery(this).val().trim().length > 0) {
+				submitButton.removeAttr('disabled');
+			} else {
+				submitButton.attr('disabled', 'disabled');
+			}
+		}).input();
+
+		domainForm.submit(function(e) {
+			var sure = confirm(Site.ml_text['/shop/selfpromo.bml.ask_add']);
+			sure && jQuery.ajax({
+				url: endpoint,
+				type: 'POST',
+				dataType: 'json',
+
+				data: {
+					action: 'add',
+					authas: authas.length > 0 ? authas.val() : Site.remoteUser,
+					src_name: domainInput.val()
+				},
+
+				success: function(res) {
+					if (res.error) {
+						var c;
+						domainField.addClass(
+							c = 'b-domainru-%error%'.replace('%error%', res.error)
+						);
+						errorClass.push(c);
+					} else {
+						var freshClass = 'b-domainru-domains-new';
+
+						domains
+							.children().removeClass(freshClass).end()
+							.append(
+								domainTemplate.tmpl({
+									userpic: res.userpic,
+									domain: res.src_name,
+									baseUrl: Site.remoteJournalBase,
+									user: res.authas
+								})
+								.ljAddContextualPopup()
+								.addClass(freshClass)
+							);
+
+						domainField.removeClass(errorClass.join(' '));
+
+						tabs.children().last().find('a').click();
+					}
+				}
+			});
+
+			e.preventDefault();
+			return false;
+		});
+
+		tabs.children().first().find('a').click(function() {
+			setTimeout(function() {
+				domainInput.focus();
+			}, 0);
+		});
+
+		removeLinks.length && shop.on('click', '.b-domainru-remove', function(e) {
+			var that = this;
+
+			var sure = confirm(Site.ml_text['/shop/selfpromo.bml.ask_delete']);
+			sure && jQuery.ajax({
+				url: endpoint,
+				type: 'POST',
+				dataType: 'json',
+
+				data: {
+					action: 'delete',
+					authas: jQuery(that).data('user'),
+					src_name: jQuery(that).data('domain')
+				},
+
+				success: function(res) {
+					if (!res.error) jQuery(that).parents('tr').detach();
+				}
+			});
+
+			e.preventDefault();
+			return false;
+		})
+
+		tabs.tabsChanger();
 	}
 }
 
@@ -545,5 +654,6 @@
 	$('shop_userheads') && Shop.pageUserheads() ||
 	$('shop_diskquota') && Shop.pageDiskquota() ||
 	$('shop_renameaccount') && Shop.pageRename() ||
-	$('ccform') && Shop.pageCreditCard();
+	$('ccform') && Shop.pageCreditCard() ||
+	$('shop_domainru') && Shop.cyrillicDomains()
 });

Modified: trunk/htdocs/shop/selfpromo.bml.text.local
===================================================================
--- trunk/htdocs/shop/selfpromo.bml.text.local	2012-04-26 14:30:00 UTC (rev 11829)
+++ trunk/htdocs/shop/selfpromo.bml.text.local	2012-04-26 14:31:27 UTC (rev 11830)
@@ -1,4 +1,8 @@
 ;; -*- coding: utf-8 -*-
+.ask_add=Are you sure?
+
+.ask_delete=Are you sure?
+
 .btn.preview|staleness=1
 .btn.preview=Preview
 

Modified: trunk/templates/Shop/DomainRU.tmpl
===================================================================
--- trunk/templates/Shop/DomainRU.tmpl	2012-04-26 14:30:00 UTC (rev 11829)
+++ trunk/templates/Shop/DomainRU.tmpl	2012-04-26 14:31:27 UTC (rev 11830)
@@ -1,6 +1,22 @@
 <TMPL_INCLUDE name="templates/Shop/Error.tmpl">
 <TMPL_INCLUDE name="templates/Shop/Warnings.tmpl">
 
+<script type="text/x-jquery-tmpl" id="domainTemplate">
+<tr>
+    <td class="b-domainru-domains-user">
+        {{html userpic}}
+    </td>
+    <td class="b-domainru-domains-domain">
+        <a href="http://${domain}.zhzh.rf" target="_blank">${domain}<TMPL_VAR expr="ml('shop.view.domainru.url')"></a>
+    </td>
+    <td class="b-domainru-domains-remove">
+        <a href="?type=manage&amp;delete=1&amp;auth=${user}&amp;dom=${domain}" title="Remove domain" class="b-domainru-remove" data-domain="${domain}" data-user="${user}">
+            <i class="b-domainru-remove-icon"></i>Remove domain
+        </a>
+    </td>
+</tr>
+</script>
+
 <div id="shop_domainru">
 
 <div class="b-shop-intro b-renacc-intro">
@@ -23,7 +39,7 @@
     </ul>
     <ul class="b-buy-goods">
         <li class="b-buy-goods-item<TMPL_IF EXPR="type eq 'buy'"> current</TMPL_IF>">
-			<TMPL_IF form_enabled>
+            <TMPL_IF form_enabled>
             <form method="post">
                 <fieldset>
                     <TMPL_VAR form_auth>
@@ -56,14 +72,14 @@
                     </div>
                 </fieldset>
             </form>
-			</TMPL_IF>
+            </TMPL_IF>
         </li>
         <li class="b-buy-goods-item<TMPL_IF EXPR="type ne 'buy'"> current</TMPL_IF>">
             <div class="b-buy-intro">
                 <TMPL_IF domains>
                     <table class="b-domainru-domains">
                         <TMPL_LOOP domains>
-                            <tr class="<TMPL_IF __odd__>b-domainru-domains-odd<TMPL_ELSE>b-domainru-domains-even</TMPL_IF">
+                            <tr>
                                 <td class="b-domainru-domains-user">
                                     <TMPL_VAR auth_display>
                                 </td>

Tags: atyurin, js, ljcom, local, spacevillain, tmpl
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