2011-03-10 9 views
1

私は最初のFirefox拡張を作ろうとしています。これは新しいタブページをChromeのようなタブページに置き換えます。機能の1つは、「最も訪問されたサイト」のタイルで、並べ替えにドラッグアンドドロップすることができます。私はそれらをドラッグアンドドロップしているが、私はどのようにDIVの新しい場所を保存するか分からない。場所を保存できる区切りの区切り

これは私が使用しているスクリプトです:

$(document).ready(function(){ 
jQuery.fn.redswap = function(options){ 
    var selectedItems=this; 
    redsettings = jQuery.extend({ 
     speed:"Medium", 
     opacity:0.7 
     }, options); 
    $(selectedItems).mouseover(function(){ 
     $(selectedItems).disableSelection(); 
     $(selectedItems).droppable({ 
      drop: function(event, ui) { 
       dropindex=$(selectedItems).index(this); 
       var dragposition=$(selectedItems[dragindex]).position(); 
       var dropposition=$(selectedItems[dropindex]).position(); 

       withDifference=parseInt(dragposition.left)-parseInt(dropposition.left); 
       heightDifference=parseInt(dragposition.top)-parseInt(dropposition.top); 

       $(selectedItems[dropindex]).animate({ 
        left:'+='+withDifference, 
        top:'+='+heightDifference 
       },redsettings.speed,function(){ 

       }); 

       $(selectedItems[dragindex]).animate({ 
        left:'+='+(withDifference*(-1)), 
        top:'+='+(heightDifference*(-1)) 
       },redsettings.speed,function(){ 
        //Complete 
       }); 


      }, 


     }); 

     $(this).draggable({ 
     opacity:redsettings.opacity, 
     helper: 'clone', 
     containment: 'parent', 
     scroll: false, 
     drag:function(event, ui){ 
       dragindex=$(selectedItems).index(this); 
      } 

     }); 

    }); 
    }; 

}); 

    // Settings 

$(document).ready(function(){ 
    $("#wrapper").tabs(); 
    $("div[id*='box']").redswap({ 
     speed:'slow', 
     opacity:.75 
    }); 
}); 

そして、これは私のHTMLです:

<div id="1box" class="item"> 
    <a href="http://www.google.com/reader/view"><img src="thumbs/01.png" border="0" /> 
    <h1>Google Reader</a></h1><a href="#" class="x"></a><a href="#" class="tack"></a> 
</div> 
<div id="2box" class="item"> 
    <a href="https://mail.google.com/"><img src="thumbs/02.png" border="0" /> 
    <h1>Gmail</a></h1><a href="#" class="x"></a><a href="#" class="tack"></a> 
</div> 
<div id="3box" class="item"> 
    <a href="http://calendar.google.com/"><img src="thumbs/03.png" border="0" /> 
    <h1>Google Calendar</a></h1><a href="#" class="x"></a><a href="#" class="tack"></a> 
</div> 
<div id="4box" class="item"> 
    <a href="http://www.twitter.com/"><img src="thumbs/04.png" border="0" /> 
    <h1>Twitter</a></h1><a href="#" class="x"></a><a href="#" class="tack"></a> 
</div> 

HTMLは最終ではない、まだ、それはドラッグアンドドロップを行います。私がDIVの新しい順序をどのように保存できるか考えて、それを閉じてもう一度開くと、それは新しい設定です。このスクリプトではできない場合は、新しいバージョンを指さしても問題ありません。

送って、私は馬鹿だようなので、私を扱うください:)

をまた、あなたは物事のコーディング部分に私を助けることに興味があるなら、私はJavaScriptに非常に非常に新しいです覚えておいてください私にメッセージ。

答えて

0

シーケンス情報を格納するために何らかのストレージを探しているようです。 Firefoxの拡張機能に適用され

3つのアプローチは、どちらかのSQLiteやファイルシステムのオプションは、あなたのアプリケーションのために働くだろう。このStack Overflow question

で議論されている、私は思います。

関連する問題