index-debug.js 5.14 KB
define("index", ["jquery","swiper","index"], function(require, exports, module){
var yohobuy;

//require('./js/common');

//equire('./js/category/entry');
//require('./js/guang/entry');
//require('./js/home/entry');
//require('./js/index/entry');
//require('./js/passport/entry');
require("js/product/entry");
//require('./js/me/entry');

module.exports = yohobuy;

});
define("js/product/entry", ["jquery","swiper","index"], function(require, exports, module){
/*
*
 *  产品打包入口
 * @author: liangzhifeng<zhifeng.liang@yoho.cn>
 * @date: 2015/10/12
 */

require("js/product/detail/detail-app");


});
define("js/product/detail/detail-app", ["jquery","swiper","index"], function(require, exports, module){
/**
 *  商品详情  --for app web view
 * @author: 赵彪<bill.zhao@yoho.cn>
 * @date: 2015/12/19
 */
var $ = require("jquery"),
    loading = require("js/plugin/loading"),
    Swiper = require("swiper");

var sizeSwiper,
    refSwiper;

loading.showLoadingMask();


require("js/product/recommend-for-you-product-desc");

//判断是否要显示向左滑动提示
function hiddenTips($ele) {
    var offsetContainer,
        offsetLastColumn;

    if ($ele.length > 0) {
        offsetContainer = $ele[0].getBoundingClientRect().right;
        offsetLastColumn = $ele.find('.swiper-slide:last-child')[0].getBoundingClientRect().right;


        if (offsetLastColumn - offsetContainer < 0) {
            $ele.next('.tips').css('display', 'none');
        } else {
            $ele.next('.tips').css('display', 'block');
        }
    }
}


function wrapElements(selector, count) {
    var elArr = null;

    $(selector).each(function(idx, el) {
        elArr = $(selector).slice(idx, idx + count);

        if (elArr.length === count && idx % count === 0) {
            $(elArr).wrapAll($('<div class="js-wraper"></div>'));
        }
    });
}


//function showRecommend() {
//    var recommendSwiper,
//        $recommendForYou = $('.recommend-for-you'),
//        $recommndEl = $('#swiper-recommend a');
//
//    if ($recommndEl.length === 0){
//       $recommendForYou.hide();
//       return;
//    }
//
//    $recommendForYou.show();
//
//    if ($('#swiper-recommend').length) {
//        recommendSwiper = new Swiper('#swiper-recommend', {
//            slidesPerView: 'auto',
//            grabCursor: true,
//            slideElement: 'a',
//            lazyLoading: true,
//            watchSlidesVisibility: true
//        });
//    }
//}

function hideHeaderFooter() {
    $('#yoho-header').hide();
    $('#yoho-footer').hide();
}

function initPage() {
    var $page = $('#app-detail');

    $page.removeClass('hide');

    loading.hideLoadingMask();

    hideHeaderFooter();
    //showRecommend();
    sizeSwiper = new Swiper('#size-swiper-container',{
        slidesPerView: 'auto'
    });

    //模特试穿左右滑动
    refSwiper = new Swiper('#reference-swiper-container',{
        slidesPerView: 'auto'
    });

    hiddenTips($('#size-swiper-container'));
    hiddenTips($('#reference-swiper-container'));

    wrapElements('.detail .column', 2);
}


$(document).ready(initPage);

});
define("js/plugin/loading", ["jquery"], function(require, exports, module){
/**
 * Loading mask
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/29
 */

var $ = require("jquery");

var $page = $('.yoho-page');

var $loading,
    hasInit = false;

/** modify by liangzhifeng at 2015.11.2 */

// 初始化
function init($container) {
    var html = '<div class="loading-mask hide">' +
                    '<div class="loading">' +
                        '<div></div><div></div><div></div>' +
                    '</div>' +
               '</div>';

    hasInit = true;
    if ($container === undefined) {
        $container = $page;
    }

    $container.append(html);

    $loading = $container.children('.loading-mask');
}

//显示loading
function showLoadingMask() {
    if (!hasInit) {
        init();
        hasInit = true;
    }
    $loading.removeClass('hide');
}

//隐藏loading
function hideLoadingMask() {
    $loading.addClass('hide');
}

exports.init = init;
exports.showLoadingMask = showLoadingMask;
exports.hideLoadingMask = hideLoadingMask;
});
define("js/product/recommend-for-you-product-desc", ["swiper","jquery","index"], function(require, exports, module){
/**
* 为您优选
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/11/16
*/


var Swiper = require("swiper"),
   $ = require("jquery");

var recommendSwiper,
   $recommendForYou = $('.recommend-for-you'),
   preferenceUrl = $('#preferenceUrl').val();

if (preferenceUrl) {
   $.get(preferenceUrl).then(function(html) {
       if (html.length < 5) {
           $recommendForYou.css('display', 'none');
       } else {
           $recommendForYou.html(html).show();
           if ($('#swiper-recommend').length) {
               recommendSwiper = new Swiper('#swiper-recommend', {
                   slidesPerView: 'auto',
                   grabCursor: true,
                   slideElement: 'a',
                   lazyLoading: true,
                   watchSlidesVisibility: true
               });
           }
       }

   }).fail(function() {
       $recommendForYou.hide();
   });
}
























































});