src/main/webapp/resources/js/typeahead.js

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

$(function () {
   
    module("typeahead", {
        setup: function(){
            sfx = $('#qunit-fixture'),
            fx = $('#async-fixture');               
            $.support.transition = false;
        }
    });  

    asyncTest("should load correct value and save new entered text (source as objects)", function () {
        var v = 2, 
          e = $('<a href="#" data-pk="1" data-name="text1" data-type="typeahead" data-value="'+v+'" data-url="post.php"></a>').appendTo(fx).editable({
            source: groups,
            typeahead: {
               items: 5
            }     
          }),
          newText = 'adm';
          
        
        equal(e.text(), groups[v], 'autotext ok');    
        equal(e.data().editable.value, v, 'initial value ok');    

        e.click();
        var p = tip(e), 
           $input = p.find('input[type=text]');
           
        ok(p.is(':visible'), 'popup visible');
        ok($input.length, 'input exists');
        equal($input.val(), groups[v], 'input contain correct text');
        equal($input.data('value'), v, 'input contain correct data-value');
        ok($input.typeahead, 'typeahead applied to input');
        
        $input.val(newText).keyup();
        
        ok(p.find('.typeahead.dropdown-menu').is(':visible'), 'dropdown visible');
        
        //select `Admin`
        v = 5;
        
        ok(p.find('.typeahead.dropdown-menu').find('li').length, 'active item exists');
        p.find('.typeahead.dropdown-menu').find('li').mouseover().click();
        
        equal($input.val(), groups[v], 'input contain correct text');        
        p.find('form').submit(); 
                                 
        setTimeout(function() {
           ok(!p.is(':visible'), 'popup closed');
           equal(e.data('editable').value, v, 'new text saved to value');
           equal(e.text(), groups[v], 'new text shown'); 

           e.click();
           p = tip(e), 
           $input = p.find('input[type=text]');
                      
           $input.val('not_matched_text').keyup();
           ok(!p.find('.typeahead.dropdown-menu').is(':visible'), 'dropdown not visible');

           p.find('form').submit(); 
后面还有 65 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。