Advertisement
Rapptz

Untitled

Jun 20th, 2012
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 4.53 KB | None | 0 0
  1.         $(function () {
  2.  
  3.             $('#m-subnav li').eq(0).addClass('active'); // set left menu
  4.  
  5.             $('#spin-btn').click(function (x) {
  6.                 x.preventDefault();
  7.                 if (!nexon.sso.isLoggedIn) {
  8.                     nexon.gnt.popupLogin();
  9.                     return;
  10.                 }
  11.                 window.gachapon.runSpin1();
  12.             });
  13.  
  14.             // nexon popup class override for having callback functionality
  15.             var popupWrap = $('#gnt_popup'),
  16.                 popupCenter = $('#gnt_popup_center'),
  17.                 popupScreen = $('#gnt_screen');
  18.             $.extend(nexon.gnt, {
  19.                 hideCallback: null,
  20.                 popupHide: function () {
  21.                     popupWrap.removeClass().hide().css({ 'width': null, 'margin-left': null });
  22.                     popupCenter.html('');
  23.                     popupScreen.hide();
  24.                     //location.hash = '#/';
  25.                     if (typeof this.hideCallback == 'function')
  26.                         this.hideCallback();
  27.                 },
  28.                 popupShow: function () {
  29.                     popupWrap.show().find('#gnt_popup_close').data('goto', 'popupHide');
  30.                     popupScreen.show();
  31.                     return {
  32.                         wrap: popupWrap,
  33.                         center: popupCenter
  34.                     };
  35.                 }
  36.             });
  37.  
  38.             $('#gachapon-text a').click(function (e) {
  39.                 popupShow('detailedGuide');
  40.                 return false;
  41.             });
  42.  
  43.             $('#tabs li').tabs().filter('[data-tab="coupon-history"]').click(function (e) {
  44.                 e.preventDefault();
  45.                 window.gachapon.showHistory();
  46.             });
  47.  
  48.             //// test
  49.             //window.gachapon.updateNXBalance({ credit: '#credit', prepaid: '#prepaid' });
  50.  
  51.             $('#more-spins-btn').click(function (e) {
  52.                 e.preventDefault();
  53.                 if (!nexon.sso.isLoggedIn) {
  54.                     nexon.gnt.popupLogin();
  55.                     return;
  56.                 }
  57.                 var p = popupShow('getMoreSpins');
  58.                 var types = p.center.find('input:radio[name=payment-type]');
  59.                 var selector = p.center.find('.currentSpins select');
  60.  
  61.                 function updatePrices() {
  62.                     var price = selector.find('option:selected').data('price');
  63.                     if (price === undefined) return;
  64.                     var paytype = types.filter(':checked').val();
  65.                     var prepaid = window.gachapon.nx.prepaid;
  66.                     var credit = window.gachapon.nx.credit;
  67.                     var remain_prepaid = p.center.find('.remain_prepaid');
  68.                     var remain_credit = p.center.find('.remain_credit');
  69.                     var spin_prices = p.center.find('.spin_price');
  70.                     spin_prices.text('');
  71.                     if (paytype == 'prepaid') {
  72.                         prepaid -= price;
  73.                         spin_prices.eq(0).text(price.digits());
  74.                     }
  75.                     if (paytype == 'credit') {
  76.                         credit -= price;
  77.                         spin_prices.eq(1).text(price.digits());
  78.                     }
  79.  
  80.                     remain_prepaid.text(prepaid.digits());
  81.                     remain_credit.text(credit.digits());
  82.                 }
  83.  
  84.                 types.click(function (e) {
  85.                     updatePrices();
  86.                 });
  87.                 selector.change(function (e) {
  88.                     var changed = $(e.target);
  89.                     updatePrices();
  90.                 });
  91.  
  92.                 types.eq(0).click();
  93.                 p.center.find('.gnt_bot .gnt_button:eq(0)').click(function (e) {
  94.                     var value = selector.val();
  95.                     var paytype = types.filter(':checked').val();
  96.                     if (value == '') {
  97.                         alert('Please select quantity');
  98.                         return;
  99.                     }
  100.                     window.gachapon.purchaseSpin(value, paytype == 'prepaid', function () {
  101.                         popupShow('thankYou');
  102.                     });
  103.                 });
  104.             });
  105.  
  106.             $('.reel-strip > div, .item-icons > div').balloon({ css: { opacity: 1 },
  107.                 minLifetime: 0, showDuration: 0, hideDuration: 0
  108.             });
  109.  
  110.             $('.item-scroll').itemRotator({
  111.                 speed: 400
  112.             });
  113.             /*
  114.             function hashChange() {
  115.             var hashes = (location.hash.length > 1 ? location.hash.substr(1).parseToArray() : {});
  116.             var page = hashes['page'];
  117.             if (page !== undefined) {}
  118.             }
  119.             $(window).unbind('hashchange').bind('hashchange', hashChange);
  120.             hashChange();*/
  121.  
  122.         });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement