阿命

论坛发帖添加自定义表情方法(临时)(北方表情)

[code]var KancolleCurrentExpression = function() {

var obj = this;

var $ = jQuery;

obj.$imgdiv = null;

/* 表情图片的最大宽度,设置为0则不限制 */

obj.maxWidth = 100;

/* 表情图片的最大高度,设置为0则不限制 */

obj.maxHeight = 100;

/* 表情图片的地址列表 */

obj.imglist = [

‘http://ww4.sinaimg.com/large/005X3pWTjw1ep9sstew0ej301f01k742.jpg’,

‘http://ww2.sinaimg.com/large/005X3q9sjw1ep9vpewuhfj302j036glg.jpg’,

‘http://ww1.sinaimg.com/large/005X4kHAjw1ep9sp2x7lvj304b04g3yi.jpg’,

‘http://ww2.sinaimg.com/large/dabbd266jw1eqdixk5nqsj201c01c3yi.jpg’,

‘http://ww1.sinaimg.com/large/dabbd266jw1eqo1cciyt7j20b40awjrr.jpg’

];

obj.createBtn = function() {

var a = $(‘自定义表情‘);

a.css({

backgroundPosition: ‘-3px -80px’

});

return a;

};

obj.createImageList = function() {

var div = $(‘

‘);

div.addClass(‘current_imgs_div’);

var close = $(‘

‘);

close.addClass(‘close’);

div.append(close);

var ul = $(‘

    ‘);

    div.append(ul);

    $.each(obj.imglist, function(index, val) {

    var item = obj.createItem(val);

    ul.append(item);

    });

    return div;

    };

    obj.createItem = function(url) {

    var li = $(‘

  • ‘);

    var img = new Image();

    img.src = url;

    li.append(img);

    return li;

    };

    obj.bindEventByButton = function($obj) {

    $obj.bind(‘click’, function() {

    if (obj.$imgdiv.css(‘display’) == ‘none’) {

    var p = $(this).offset();

    obj.showDiv(p);

    } else {

    obj.hideDiv();

    }

    });

    };

    obj.hasEdit = function() {

    var $edit = $(‘#e_body’);

    return $edit.length > 0;

    };

    obj.setCss = function(div) {

    div.css({

    width: ‘530px’,

    height: ‘300px’,

    border: ‘1px solid #ccc’,

    position: ‘absolute’,

    background: ‘#eee’,

    display: ‘none’,

    top: ‘0’,

    left: ‘0’

    });

    div.find(‘ul’).css({

    width: ‘520px’,

    height: ‘270px’,

    margin: ’25px 5px 5px 5px’,

    overflowY: ‘scroll’,

    padding: ‘0’

    });

    div.find(‘li’).css({

    listStyle: ‘none’,

    float: ‘left’,

    width: ’50px’,

    height: ’50px’,

    margin: ‘5px’,

    border: ‘1px solid #ccc’,

    textAlign: ‘center’,

    cursor: ‘pointer’,

    background: ‘#fff’,

    overflow: ‘hidden’

    });

    div.find(‘li img’).css({

    height: ’50px’

    });

    div.find(‘.close’).css({

    width: ’20px’,

    height: ’20px’,

    position: ‘absolute’,

    background: ‘#FF0’,

    top: ‘4px’,

    right: ‘5px’,

    cursor: ‘pointer’,

    background: ‘url(http://dz.aemedia.org/./template/999test_cn_img/dz_model_15020401/common/cls.gif) no-repeat 0 0’

    });

    };

    obj.bindEventByImagelist = function(div) {

    div.find(‘li’).bind(‘click’, function() {

    var url = $(this).find(‘img’).attr(‘src’);

    if (!!url) {

    var style = ”;

    if (obj.maxWidth > 0) {

    style += ‘max-width:’ + obj.maxWidth + ‘px;’;

    }

    if (obj.maxHeight > 0) {

    style += ‘max-height:’ + obj.maxHeight + ‘px;’;

    }

    var html = ‘‘;

    insertText(html, false);

    obj.hideDiv();

    }

    });

    div.find(‘.close’).bind(‘click’, function() {

    obj.hideDiv();

    });

    };

    obj.showDiv = function(p) {

    obj.$imgdiv.css({

    top: p.top + 50,

    left: p.left – 100

    });

    obj.$imgdiv.show();

    };

    obj.hideDiv = function() {

    obj.$imgdiv.hide();

    };

    obj.appendToBody = function() {

    if ($(‘.current_imgs_div’).length > 0) return;

    $(‘body’).append(obj.$imgdiv);

    };

    obj.init = function() {

    if (!obj.hasEdit()) return;

    var btn = obj.createBtn();

    $(‘#e_body #e_sml’).after(btn);

    obj.bindEventByButton(btn);

    var imgdiv = obj.createImageList();

    obj.setCss(imgdiv);

    obj.bindEventByImagelist(imgdiv);

    obj.$imgdiv = imgdiv;

    obj.appendToBody();

    };

    };

    var kancolleCurrentExpression = new KancolleCurrentExpression();

    kancolleCurrentExpression.init();[/code]

    Pages: 1 2 3

    发表回复

    1. omysho说道:

      {:4_102:}命酱这么有空为啥不去……【呵呵】

    2. 龙神阿渡说道:

      半夜的可怕程序猿!

    3. 阿命说道:

      omysho 发表于 2015-3-31 00:48

      命酱这么有空为啥不去……【呵呵】

      {:4_91:}kcv 源码变了好多 还得重新研究一遍(原jie因kou)

    4. xiannuan说道:

      阿命 发表于 2015-3-31 00:49

      kcv 源码变了好多 还得重新研究一遍(原jie因kou)

      晚安

      好东西,不过喵懒得下插件了

      等论坛改(

    5. SkywalkerJi说道:

      阿命dalao又有黑科技了

    6. 泊地棲姬说道:

      前排围观程序猿( *・ω・)

    7. dragoon007说道:

      {:4_88:}继续围观不务正业的程序猿

    8. U-511改说道:

      感觉好厉害的样子……

    9. 駆逐艦雪風说道:

      不明觉厉,前排跪命触,先收藏看看_(:зゝ∠)_

    10. 看見代碼也是跪了

    11. 井石头说道:

      我只想知道论坛什么时候实装北方表情套{:4_102:}

    12. 阿命说道:

      井石头 发表于 2015-3-31 02:35

      我只想知道论坛什么时候实装北方表情套

      {:4_102:}这个只能at Y大了

      然而可以这样




    13. 阿命说道:

      駆逐艦雪風 发表于 2015-3-31 01:28

      不明觉厉,前排跪命触,先收藏看看_(:зゝ∠)_

      _(:зゝ∠)_牙牙早~

    14. 阿命说道:

      U-511改 发表于 2015-3-31 01:28

      感觉好厉害的样子……

      _(:зゝ∠)_ U酱早~

    15. 阿命说道:

      dragoon007 发表于 2015-3-31 01:01

      继续围观不务正业的程序猿

      _(:зゝ∠)_ 我只是为了水找点合理的东西

    16. xiannuan说道:

      阿命 发表于 2015-3-31 09:25

      这个只能at Y大了

      然而可以这样

      _(:зゝ∠)_好生羡慕

    17. 阿命说道:

      泊地棲姬 发表于 2015-3-31 00:58

      前排围观程序猿( *・ω・)

      ( *・ω・)瞪~反围观

    18. 阿命说道:

      xiannuan 发表于 2015-3-31 09:27

      _(:зゝ∠)_好生羡慕

      使用很简单的哦

    19. 懒到条蛇咁说道:

      {:4_90:} 程序猿好可怕

    20. xiannuan说道:

      阿命 发表于 2015-3-31 09:29

      使用很简单的哦

      {:4_91:}喵不太想用插件..你看喵连kcv都没有的_(:зゝ∠)_

      不过应该再过一段时间就管不住手了。阿命你可以等等

    21. 阿命说道:

      长度竟然超过限制了

      [code]obj.imglist = [

      ‘http://ww4.sinaimg.com/large/dabbd266jw1eqon8ro4lmj204a03e0sp.jpg’,

      ‘http://ww4.sinaimg.com/large/dabbd266jw1eqon8sgtcnj206104eaa9.jpg’,

      ‘http://ww3.sinaimg.com/large/dabbd266jw1eqon8v6v0xj204t03xdfx.jpg’,

      ‘http://ww2.sinaimg.com/large/dabbd266jw1eqon8uaqoij202q022dfo.jpg’,

      ‘http://ww1.sinaimg.com/large/dabbd266jw1eqon8wf9c5j205c04swep.jpg’,

      ‘http://ww4.sinaimg.com/large/dabbd266jw1eqon8xc8p8j204w04xt8y.jpg’,

      ‘http://ww1.sinaimg.com/large/dabbd266jw1eqon8xyzrrj203i02emx3.jpg’,

      ‘http://ww3.sinaimg.com/large/dabbd266jw1eqon8ynyv8j205503kt8o.jpg’,

      ‘http://ww1.sinaimg.com/large/dabbd266jw1eqon9176zmj205506aaa8.jpg’,

      ‘http://ww1.sinaimg.com/large/dabbd266jw1eqon91zaxxj203w03zaa2.jpg’,

      ‘http://ww2.sinaimg.com/large/dabbd266jw1eqon93c7onj203902w3yd.jpg’,

      ‘http://ww2.sinaimg.com/large/dabbd266jw1eqon94ee10j20go0blmzr.jpg’,

      ‘http://ww3.sinaimg.com/large/dabbd266jw1eqon95gzjmj2043050q33.jpg’,

      ‘http://ww1.sinaimg.com/large/dabbd266jw1eqon96ealuj206r05m0t7.jpg’,

      ‘http://ww1.sinaimg.com/large/dabbd266jw1eqon97a1i9j202n031gli.jpg’,

      ‘http://ww3.sinaimg.com/large/dabbd266jw1eqon985sm6j206i07zmxm.jpg’,

      ‘http://ww2.sinaimg.com/large/dabbd266jw1eqon98zyc6j2038049mx6.jpg’,

      ‘http://ww3.sinaimg.com/large/dabbd266jw1eqon99ow64j205804g74g.jpg’,

      ‘http://ww4.sinaimg.com/large/dabbd266jw1eqon9ay02ej2036041mx5.jpg’,

      ‘http://ww2.sinaimg.com/large/dabbd266jw1eqon9bxuvsj207e05swes.jpg’,

      ‘http://ww4.sinaimg.com/large/dabbd266jw1eqon9cr7xhj203s044dft.jpg’,

      ‘http://ww4.sinaimg.com/large/dabbd266jw1eqon9dfvkij208005pmxk.jpg’,

      ‘http://ww3.sinaimg.com/large/dabbd266jw1eqon9ej27dj207q074t93.jpg’,

      ‘http://ww3.sinaimg.com/large/dabbd266jw1eqon9f886jj2029042a9x.jpg’,

      ‘http://ww4.sinaimg.com/large/dabbd266jw1eqon9fv2ouj205h04274f.jpg’,

      ‘http://ww4.sinaimg.com/large/dabbd266jw1eqon9gvprej206f06ymxm.jpg’,

      ‘http://ww1.sinaimg.com/large/dabbd266jw1eqon9hq8c4j20cb07vmy5.jpg’,

      ‘http://ww1.sinaimg.com/large/dabbd266jw1eqon9ih2wzj209p030wep.jpg’,

      ‘http://ww4.sinaimg.com/large/dabbd266jw1eqon9jgzjyj206407ajs3.jpg’,

      ‘http://ww3.sinaimg.com/large/dabbd266jw1eqon9k2dmaj20ci08nq4b.jpg’,

      ‘http://ww2.sinaimg.com/large/dabbd266jw1eqon9l3ui2j208t07mgmb.jpg’,

      ‘http://ww1.sinaimg.com/large/dabbd266jw1eqonafabobj208e06kaak.jpg’,

      ‘http://ww3.sinaimg.com/large/dabbd266jw1eqonag3w57j205k02qq2z.jpg’,

      ‘http://ww4.sinaimg.com/large/dabbd266jw1eqonakl1r1j20a50c9q4f.jpg’,

      ‘http://ww3.sinaimg.com/large/dabbd266jw1eqoncemgf5j204703o3yi.jpg’,

      ‘http://ww1.sinaimg.com/large/dabbd266jw1eqoncfljmej204t04ljrh.jpg’,

      ‘http://ww4.sinaimg.com/large/dabbd266jw1eqonclxlbfj206w04w0t0.jpg’,

      ‘http://ww1.sinaimg.com/large/dabbd266jw1eqoncqe3kij205m053mx7.jpg’,

      ‘http://ww1.sinaimg.com/large/dabbd266jw1eqoncwlgosj203k04hdfw.jpg’,

      ‘http://ww4.sinaimg.com/large/dabbd266jw1eqond70n36j205g05w0t0.jpg’,

      ‘http://ww3.sinaimg.com/large/dabbd266jw1eqondac6wmj207o03z0sz.jpg’,

      ‘http://ww3.sinaimg.com/large/dabbd266jw1eqondebbldj203b0263ye.jpg’,

      ‘http://ww2.sinaimg.com/large/dabbd266jw1eqondlzhppj204i04idfw.jpg’,

      ‘http://ww4.sinaimg.com/large/dabbd266jw1eqondovu9hj206i055wer.jpg’,

      ‘http://ww2.sinaimg.com/large/dabbd266jw1eqondse6xxj20b807caat.jpg’,

      ‘http://ww1.sinaimg.com/large/dabbd266jw1eqondxnjadj207i05m74o.jpg’,

      ‘http://ww4.sinaimg.com/large/dabbd266jw1eqone04lzhj206r06wjru.jpg’

      ];[/code]

    22. 阿命说道:

      懒到条蛇咁 发表于 2015-3-31 09:30

      程序猿好可怕

      {:4_102:}来用么

    23. 阿命说道:

      xiannuan 发表于 2015-3-31 09:32

      喵不太想用插件..你看喵连kcv都没有的_(:зゝ∠)_

      不过应该再过一段时间就管不住手了。阿命你可 …

      {:4_102:}北方的诱惑

    24. U-511改说道:

      阿命 发表于 2015-3-31 09:26

      _(:зゝ∠)_ U酱早~

      早啊_(:з」∠)_

    25. {:4_102:}求论坛统一加

    26. 阿命说道:

      无畏级核潜艇 发表于 2015-3-31 09:47

      求论坛统一加



      加!加!加!北方的这些可以论坛直接加,不过自定义的就比较不好弄了,因为还得弄个保存用户自定义表情的接口

    27. Aris说道:

      然而这些表情并不简单明了,有些意义不明{:4_88:}

    28. 阿命说道:

      Aris 发表于 2015-3-31 09:55

      然而这些表情并不简单明了,有些意义不明

      用来卖萌的

    官方微信

    Login

    跳至工具栏