From 5b7c4224469187777961b24c3060f79f75a3fe58 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 2 May 2012 17:05:40 +0800 Subject: [PATCH] position update fixed.. --- app/assets/javascripts/orbitdesktop.js | 46 ++++++++++++-------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index 623f3f6b..1cdc8339 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -1,9 +1,7 @@ + // JavaScript Document //harry //Inititialize function will initialize desktop - - - $.extend($.expr[':'], { 'containsi': function (elem, i, match, array) { return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; @@ -25,7 +23,6 @@ var orbitDesktop = function(dom){ this.contentHolder = dom; this.themesettings = ""; this.theme = "4f8d3f493b67fcd05f086359"; -// this.themefolder = "themes"; this.transitionTime = 500; this.currenthtml = "desktop.html"; this.currentface = "home"; @@ -136,11 +133,11 @@ var orbitDesktop = function(dom){ o.currentface = "home"; var bindHandlers = function(){ // this function will bind all the handlers in the desktop - var groupWrapperWidth = 0; $("div#desktop .group").each(function(){groupWrapperWidth+=$(this).outerWidth(true);}); $("div#desktop #group_wrapper").css("width",groupWrapperWidth); + var first = true; $("div#desktop .g_col").sortable({ connectWith: ".g_col", tolerance: 'pointer' , @@ -148,37 +145,37 @@ var orbitDesktop = function(dom){ containment: '#group_wrapper', helper: 'clone', stop:function(){ - var newpostitions = new Array; - var groupids = new Array; - $.each($("div#desktop .group"),function(i,grp){ - var groupone = new Array; - groupids.push($(grp).attr("id")); - $ul = $(grp).find(".g_col .element"); - $.each($ul,function(){ - groupone.push($(this).attr("id")); - }) - newpostitions.push(groupone); - }); - $.post("/desktop/newpositions",{"sectionid":o.sectionId,"newpos":newpostitions,"groupids":groupids}); + first = true; }, update:function(){ + if(first){ + first = false; + var newpostitions = new Array; + var groupids = new Array; + $.each($("div#desktop .group"),function(i,grp){ + var groupone = new Array; + groupids.push($(grp).attr("id")); + $ul = $(grp).find(".g_col .element"); + $.each($ul,function(){ + groupone.push($(this).attr("id")); + }) + newpostitions.push(groupone); + }); + $.post("/desktop/newpositions",{"sectionid":o.sectionId,"newpos":newpostitions,"groupids":groupids}); + } var s = $(this).find('.element').length; if(s!=0){ last = $(this).find('.element').eq(s-1).position(), lasth = $(this).find('.element').eq(s-1).outerHeight(true); - if ((last.top+lasth)>528){ $(this).sortable('cancel'); } }else{$(this).remove();} - }, receive: function(event, ui){ - var s = $(this).find('.element').length, last = $(this).find('.element').eq(s-1).position(), lasth = $(this).find('.element').eq(s-1).outerHeight(true); - if ((last.top+lasth)>528){ $(ui.sender).sortable('cancel'); } @@ -228,12 +225,12 @@ var orbitDesktop = function(dom){ bw = parseInt(brick[0].substr(1)), bh = parseInt(brick[1].substr(1)), bd = bw * bh; - if(bh==1 && bw==1){ small++; }else if(bh!=1 && bw!=1){ single = true; - } + } + if(small==2){ small=0; single=false; @@ -899,5 +896,4 @@ orbitDesktop.prototype.currentLanguage = "en"; orbitDesktop.prototype.currentUsername = "Harry"; var uselessfunction = function(){ $.post("/desktop/temp_func",{sectionid:"4f83e7bbbd98eb041600001d"}); -} - +} \ No newline at end of file