diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index 586cf728c..e5f3c3fba 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -108,8 +108,8 @@ var orbitDesktop = function(dom){ this.contentHolder = dom; this.themesettings = ""; this.theme = "4f8d3f493b67fcd05f086359"; - this.transitionTime = 1000; - this.currenthtml = "desktop.html"; + this.transitionTime = 500; + this.currenthtml = "home"; this.currentface = "home"; this.desktopData = {}; this.tp = ""; @@ -313,8 +313,8 @@ var orbitDesktop = function(dom){ }) $(window).resize(function(){ - // var ww = $(window).width(); - // $("img#thmbackground").attr({"width":ww}); + var ww = $(window).width(); + $("img#thmbackground").attr({"width":ww}); if( $('.tinycanvas').length > 0 ){ $('.tinycanvas').tinyscrollbar_update('relative'); } if($(o.contentHolder).find("div.app_frame").length > 0){ $(o.contentHolder).find("div.app_frame").each(function(){ @@ -378,8 +378,8 @@ var orbitDesktop = function(dom){ }; this.layout_data = function(h){ - var $e; - var column_container,layout, base_width, total_width, gutter, no_of_entries = 0, pagination_link, pagination_variable; + var $e; + var column_container,layout, base_width , no_of_entries = 0, pagination_link , pagination_variable, gutter, total_width; o.paging = true; gutter = (!isNaN(gutter)) ? gutter : 12; this.layout_data.generate_layout_html = function(l){ @@ -393,6 +393,7 @@ var orbitDesktop = function(dom){ case "simple": total_columns++; temp_div.append(column_container.html()); + total_width = "auto"; break; case "datalist": no_of_entries = (typeof column_container.attr("per-column") != "undefined"? parseInt(column_container.attr("per-column")) : 4); @@ -411,7 +412,10 @@ var orbitDesktop = function(dom){ x = 0; temp_div.append(column); } - }); + }) + if(x != 0){ + temp_div.append(column); + } } total_width = (!isNaN(base_width)) ? (base_width + gutter*2 +1) * total_columns : null; break; @@ -419,17 +423,16 @@ var orbitDesktop = function(dom){ entries = column_container.find("div[column=true]"),x = 0,column; if(entries.length!=0){ entries.each(function(i,ul){ - column = $("
"); } - $("#content > #holder").hide("drop",{ easing: "easeInOutQuint" },o.transitionTime,function(){ + $("#content").hide("drop",o.transitionTime,function(){ o.currenthtml = target; o.currentface = target; var cache = false; if(!o.desktopData[o.currentface]){ $(o.contentHolder).empty().load(url,function(data){ if(typeof o.data_method != "undefined"){ - if(o.data_method != ""){ + if(o.data_method != "") window.o[o.data_method](target,url,cache); - } } try{ if(!customload) @@ -566,8 +568,8 @@ var orbitDesktop = function(dom){ o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[load=true]"),data); } }catch(EX){} - header_ani(); - }); + + }) }else{ $(o.contentHolder).html(o.desktopData[o.currentface]); try{ @@ -582,26 +584,11 @@ var orbitDesktop = function(dom){ }catch(EX){} cache = true; if(typeof o.data_method != "undefined"){ - if(o.data_method != ""){ - window.o[o.data_method](target,url,cache); - } + if(o.data_method != "") + window.o[o.data_method](target,url,cache); } - header_ani(); } }); - $('#header') - .delay(600) - .effect('drop',{ - easing: 'easeInOutQuint', - direction: 'down' - },300); - } - - var header_ani = function(){ - $('#header').hide().toggle('drop',{easing: 'easeInOutQuint', direction:'down'}); - $('#header > *').each(function(i){ - $(this).hide().delay(i*100).fadeIn(400,'easeInOutQuint'); - }); } } this.sub_menu_item = function(dom,data){ @@ -645,7 +632,7 @@ var orbitDesktop = function(dom){ } this.initializeDesktop = function(target,url,cache){ //this is for initializing main desktops that are sections and tiles - if(!target)target = "desktop"; + if(!target)target = "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);}); @@ -732,7 +719,8 @@ var orbitDesktop = function(dom){ .gridster({ widget_margins: [6, 6], widget_base_dimensions: [120, 120], - // avoid_overlapped_widgets: true, + // avoid_overlapped_widgets: true, + serialize_params: function($w, wgd) { return { col: wgd.col, row: wgd.row, id: $w.data("id") } }, draggable : { start : function(event, ui){ dragged.addClass("noClick"); @@ -785,6 +773,9 @@ var orbitDesktop = function(dom){ }) } + var newpos = o.gridvar.serialize(); + console.log(newpos); + $.post("/desktop/newpositions",{"newpositions":newpos}); } } }).data('gridster'); @@ -829,24 +820,45 @@ var orbitDesktop = function(dom){ // }); } var loadTiles = function(id){ //This will load tiles for a specific desktop .. id of section has to be passed here to load tiles - $("#desktop #group_wrapper").empty(); + $("div#desktop div#group_wrapper").empty(); $.getJSON("/desktop/getgroups",{sectionid:id},function(tiles){ - tiles.sort(o.sortJSON("position",true,parseInt)); + // tiles.sort(o.sortJSON("position",true,parseInt)); var tilecolors = o.themesettings.tilecolor; var totaltiles_in_a_row = 4; var opacity = ["op07","op08","op09",""]; - var row = 1,col = 1,x = 1,y = 1; + var row = 0,col = 1,x = 1,y = 1,total_x = 0,prev_y = 0; var $group = $('
'); var $ul = $(''); $.each(tiles,function(i,tile){ - if(row >= 4){ - row = 1; - col++; - } var shape = tile.shape.split(" "); - x = parseInt(shape[0].substr(1,1)); - y = parseInt(shape[1].substr(1,1)); + // if(tile.title == "Weather")console.log("Big - row : " + tile.row + ", col : "+ tile.column); + // if(tile.title == "Google Scholar")console.log("Scholar - row : " + tile.row + ", col : "+ tile.column); + + // if(total_x % 2 != 0) + // row = row - y; + // if(i == 7)tile.row = null; + if(tile.row){ + row = tile.row; + col = tile.column; + x = parseInt(shape[0].substr(1,1)); + y = parseInt(shape[1].substr(1,1)); + }else{ + x = parseInt(shape[0].substr(1,1)); + if(total_x % 2 == 0){ + row = row + y; + }else if(x == 1){ + col++; + } + y = parseInt(shape[1].substr(1,1)); + total_x = total_x + ( x * y ); + prev_y = y; + if(total_x > 8){ + row = 1; + total_x = 0; + col++; + } + } var tilecolor = tilecolors[Math.floor(Math.random()*tilecolors.length)]; var op = opacity[Math.floor(Math.random()*opacity.length)]; var f = (tile.fullsize?"fullsize":null); @@ -854,14 +866,14 @@ var orbitDesktop = function(dom){ if(tile.data_category == "app") $li = $('
  • '+tile.title+'

  • '); else - $li = $('
  • Loading

    '+tile.title+'

  • '); + $li = $('
  • Loading

    '+tile.title+'

  • '); - row = row + y; + $ul.append($li); }) $group.append($ul); - $("#desktop #group_wrapper").append($group); + $("div#desktop div#group_wrapper").append($group); bindHandlers(); o.initializeWidgets(); @@ -936,7 +948,7 @@ var orbitDesktop = function(dom){ tempstyle = "style='display:none;'"; $("#desktop #section_heading").text(section.name); } - $("div#desktop ul#section_list").append($('
  • '+section.name+'
  • ')); + $("div#desktop ul#section_list").append($('
  • '+section.name+'
  • ')); }) bindSecondaryHandlers(); }) @@ -1135,9 +1147,9 @@ var orbitDesktop = function(dom){ }); $.post("/desktop/save_desktop_settings",{"save":"appnewsection","appid":ui.draggable.attr("id"),"newsectionid":$(this).data("content"),"desktopid":o.desktopId}); - if(o.sectionId == $(this).data("content") || o.sectionId == elementParent.attr("id")){ + // if(o.sectionId == $(this).data("content") || o.sectionId == elementParent.attr("id")){ o.desktopData["home"]=""; - } + // } } $(this).find('span.tile').addClass('op06',400); }, @@ -1594,26 +1606,19 @@ var orbitDesktop = function(dom){ }) }; this.initializeWidgets = function(){ // this function will initialize all the widgets in the desktop - var elements = $("#group_wrapper .widget"); + + var elements = $("#group_wrapper li.widget"); $.each(elements,function(){ var widget = $(this); if(widget.attr("data-category")=="widget"){ - var widgetname = widget.attr("data-content"); - $.getScript(widget.attr("js-link")).done(function(){ - // widget.find(".appholder").load(widget.attr("data-content")); - $.get(widgetname).done(function(html){ - widget - .find('.appholder') - .html(html) - .css('top','100%') - .delay(800) - .animate({top:'0%'},500,'easeInOutQuint'); - }); + var widgename = widget.attr("data-content"); + $.getScript(widget.attr("js-link"),function(){ + widget.find("div.appholder").load(widget.attr("data-content")); }); - // $(this).find(".appholder").append( ''); + $(this).find("div.appholder").append( '') } - }); + }) }; this.saveWallpaper = function(wallpaper){ // this function saves wallpaper in db $.post("/desktop/save_desktop_settings",{"save":"wallpaper","wallpapernm":wallpaper,"desktopid":o.desktopId},function(result){ @@ -1729,6 +1734,12 @@ var orbitDesktop = function(dom){ }); }); } + this.use_select2 = function(){ + $('select:not(.select2-offscreen)').select2({ + minimumResultsForSearch: -1 + // minimumInputLength: -1 + }); + } o.initialize(); } diff --git a/config/mongoid.yml b/config/mongoid.yml index 2fa55a361..56df1a692 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -8,10 +8,10 @@ defaults: &defaults development: <<: *defaults - database: test_site + database: test_site_harry test: <<: *defaults - database: test_site + database: test_site_harry # set these environment variables on your prod server production: diff --git a/lib/tasks/desktop.rake b/lib/tasks/desktop.rake index 9bb968ae8..0ad9468c8 100644 --- a/lib/tasks/desktop.rake +++ b/lib/tasks/desktop.rake @@ -1,13 +1,24 @@ # encoding: utf-8 -namespace :desktop do - task :destroy_build_desktop => :environment do - Desktop.all.destroy_all - u = User.all - u.each do |us| - x = us.initialize_desktop - x.save! - puts "Desktop created for " + us.email.to_s +namespace :tiles do + task :destroy_build_tiles => :environment do + Tile.destroy_all + secs = Section.all + dws = DesktopWidget.all + secs.each do |sec,x| + grp = sec.groups.first + t = Tile.new(data_category: "app", data_content: "wikibooks", position: 1, shape: "w1 h1", title: "WikiBooks") + grp.tiles+=[t] + t = Tile.new(data_category: "app", data_content: "envocab", position: 2, shape: "w1 h1", title: "English Vocabulary") + grp.tiles+=[t] + @i = 3 + dws.each do |dw| + t = Tile.new(data_category: "widget", position: @i,desktop_widget_id: dw.id) + @i = @i + 1 + grp.tiles+=[t] + end + grp.save! end + puts "Section " + x + " done!" end end \ No newline at end of file