Msg box added and background image saving complete

This commit is contained in:
Harry Bomrah 2012-04-18 22:01:12 +08:00
parent b4bf81d40a
commit 4bad25e682
6 changed files with 117 additions and 55 deletions

View File

@ -1,5 +1,20 @@
// JavaScript Document
//harry
//harry
$.extend($.expr[':'], {
'containsi': function (elem, i, match, array) {
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
}
});
$.fn.sort = function(c) {
return this.pushStack([].sort.apply(this, arguments), []);
};
var sortAscending = function(a, b) {
return $(a).find("h1").text() > $(b).find("h1").text() ? 1 : -1;
};
var sortDescending = function(a, b) {
return $(a).find("h1").text() < $(b).find("h1").text() ? 1 : -1;
};
var orbitDesktop = function(dom){
orbitDesktopAPI.apply(this);
o = this;
@ -25,18 +40,18 @@ var orbitDesktop = function(dom){
custom = true;
}
o.theme = theme;
loadTheme(desktopSettings.customtheme);
loadTheme(desktopSettings.customtheme,desktopSettings.wallpaper);
}else{loadTheme();}
})
var loadTheme = function(dhtml){
var loadTheme = function(customtheme,customwallpaper){
$.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){
o.themesettings = eval(ts);
$('head').append( $('<link rel="stylesheet" id="dyn_css" type="text/css" />').attr('href', "/"+o.themefolder+"/"+theme+"/css/"+ts.css));
if(custom){
$("head").find("#dyn_css").remove();
$("head").append(dhtml);
$("head").append(customtheme);
}
$(document).ready(function(){o.loadWallpaper();o.bindDesktopEvents();o.loadIconCache();o.initializeDesktop();});
$(document).ready(function(){o.loadWallpaper(customwallpaper);o.bindDesktopEvents();o.loadIconCache();o.initializeDesktop();});
})
}
};
@ -263,7 +278,9 @@ var orbitDesktop = function(dom){
}
};
this.tempFunc = function(th){
o.confirm("What","","",function(reply){
alert(reply);
})
}
this.initializeAppSearch = function(target){
o.currenthtml = target;
@ -602,25 +619,33 @@ var orbitDesktop = function(dom){
});
$("a#theme_submit").click(function(){
var colors = new Array;
$("tr#color_inputs input").each(function(){
colors[$(this).attr("for")] = $(this).val();
})
var dhtml ="<style> .thmc1 { background: "+colors['thmc1']+"; }.thmc2 { background: "+colors['thmc2']+"; }.thmc3 { background: #FFFFFF; }.thmc4 { background: "+colors['thmc4']+"; }.thmtxt { color: "+colors['thmtxt']+"; }.thmtxth { color: "+colors['thmtxth']+"; }.g_sep { border-color: "+colors['g_sep']+";} body{background-color: "+colors['background']+"} </style>";
$("head").find("#dyn_css").remove();
$("head").append(dhtml);
$.post("/desktop/save_desktop_settings",{"save":"customtheme","desktopid":o.desktopId,"theme":dhtml},function(result,status){
if(status=="success"){
if(result[0].success=="true")
o.notify("Custom theme saved!!","success",2);
else
o.notify("Custom theme saving failed!!","imp",2);
}else{
o.notify("Connection problem!!","alert",2);
o.confirm("Are you sure that you want to set this custom theme?",["Yes","No"],3,function(reply){
if(reply){
var colors = new Array;
$("#color_input input").each(function(){
colors[$(this).attr("for")] = $(this).val();
})
var dhtml ="<style> .thmc1 { background: "+colors['thmc1']+"; }.thmc2 { background: "+colors['thmc2']+"; }.thmc3 { background: #FFFFFF; }.thmc4 { background: "+colors['thmc4']+"; }.thmtxt { color: "+colors['thmtxt']+"; }.thmtxth { color: "+colors['thmtxth']+"; }.g_sep { border-color: "+colors['g_sep']+";} body{background-color: "+colors['background']+"} </style>";
$("head").find("#dyn_css").remove();
$("head").append(dhtml);
$.post("/desktop/save_desktop_settings",{"save":"customtheme","desktopid":o.desktopId,"theme":dhtml},function(result,status){
if(status=="success"){
if(result[0].success=="true")
o.notify("Custom theme saved!!","success",2);
else
o.notify("Custom theme saving failed!!","imp",2);
}else{
o.notify("Connection problem!!","alert",2);
}
})
}
})
});
$(".stock_wallpaper .ssl_item").click(function(){
var wallpapername = $(this).find("img").attr("alt");
o.changeWallpaper(wallpapername);
})
}
var loadthmc = function(){
$('.color-picker').each(function(){
@ -658,17 +683,19 @@ var orbitDesktop = function(dom){
themes();
});
};
this.loadWallpaper = function(wallpaper){
if(!wallpaper)wallpaper = o.themesettings.background;
if(!wallpaper)wallpapernm = o.themesettings.background;else wallpapernm = wallpaper
var ww = $(window).width();
var wh = $(window).height();
if(o.themesettings.background)
$("img#thmbackground").attr({"src":"/"+o.themefolder+"/"+o.theme+"/images/"+wallpaper,"width":ww}).css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","height":"auto"});
if(!wallpaper)
$("img#thmbackground").attr({"src":"/"+o.themefolder+"/"+o.theme+"/images/"+wallpapernm,"width":ww}).css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","height":"auto"});
else
$("img#thmbackground").attr({"src":"/"+"images/"+wallpaper,"width":ww}).css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","height":"auto"});
$("img#thmbackground").attr({"src":o.wallpaperPath+wallpaper,"width":ww}).css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","height":"auto"});
$("div#bgover").css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","width":ww,"height":wh});
};
this.loadIconCache = function(){
var imgs = $("ul.docklist img");
$.each(imgs,function(){
@ -690,6 +717,18 @@ var orbitDesktop = function(dom){
})
};
this.saveWallpaper = function(wallpaper){
$.post("desktop/save_desktop_settings",{"save":"wallpaper","wallpapernm":wallpaper,"desktopid":o.desktopId},function(result,status){
if(status=="success"){
if(result[0].success=="true")
o.notify("Wallpaper saved!!","success",2);
else
o.notify("Wallpaper saving failed!!","imp",2);
}else{
o.notify("Connection problem!!","alert",2);
}
})
}
o.initialize();
}
@ -697,6 +736,7 @@ orbitDesktop.prototype.themefolder = "themes";
orbitDesktop.prototype.widgetfolder = "desktop_widgets";
orbitDesktop.prototype.desktopId = "1";
orbitDesktop.prototype.notifyImgPath = "temp";
orbitDesktop.prototype.wallpaperPath = "/assets/stockBackground/";
orbitDesktop.prototype.iconPath = "/assets/icons/";
orbitDesktop.prototype.currentLanguage = "en";
var uselessfunction = function(){

View File

@ -1,18 +1,5 @@
// JavaScript Document
$.extend($.expr[':'], {
'containsi': function (elem, i, match, array) {
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
}
});
$.fn.sort = function(c) {
return this.pushStack([].sort.apply(this, arguments), []);
};
var sortAscending = function(a, b) {
return $(a).find("h1").text() > $(b).find("h1").text() ? 1 : -1;
};
var sortDescending = function(a, b) {
return $(a).find("h1").text() < $(b).find("h1").text() ? 1 : -1;
};
//Harry Bomrah
var orbitDesktopAPI = function(){
o = this;
this.notify = function(msg,type,time){
@ -63,4 +50,35 @@ var orbitDesktopAPI = function(){
}
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
};
this.changeWallpaper = function(wallpaper){
$("img#thmbackground").attr("src",o.wallpaperPath+wallpaper);
o.saveWallpaper(wallpaper);
};
this.confirm = function(msg,btnvalues,highlighted,callbackfn){
if(!btnvalues)btnvalues=["Ok","Cancel"];
if(highlighted!=1 || highlighted!=2)highlighted=2;
if(!msg)msg = "Are you sure?"
var $confirm = $("#orbitdiag");
$confirm.find(".diag_action a").addClass("admbg admtxt");
$confirm.find(".diag_message").text(msg);
if(highlighted == 1)
$confirm.find("#diag_confirm").removeClass("admbg admtxt").addClass("thmc1 thmtxt");
if(highlighted == 2)
$confirm.find("#diag_cancel").removeClass("admbg admtxt").addClass("thmc1 thmtxt");
$confirm.find("#diag_confirm").text(btnvalues[0]).one("click",function(){
$confirm.hide();
$confirm.find(".diag_action a").unbind();
if(typeof callbackfn=="function")
callbackfn.call(this,true);
});
$confirm.find("#diag_cancel").text(btnvalues[1]).one("click",function(){
$confirm.hide();
$confirm.find(".diag_action a").unbind();
if(typeof callbackfn=="function")
callbackfn.call(this,false);
});
$confirm.show();
}
};
orbitDesktopAPI.prototype.notifyImgPath = "temp";
orbitDesktopAPI.prototype.wallpaperPath = "temp";

View File

@ -42,6 +42,7 @@ class DesktopController< ApplicationController
case @savewhat
when "theme"
@desktop.update_attributes(:theme => params["theme"])
@desktop.update_attributes(:wallpaper => nil)
when "desktopnames"
@sections = @desktop.sections
x = 0;
@ -64,6 +65,8 @@ class DesktopController< ApplicationController
when "customtheme"
@desktop.update_attributes(:theme => "custom")
@desktop.update_attributes(:customtheme => params['theme'])
when "wallpaper"
@desktop.update_attributes(:wallpaper => params["wallpapernm"])
end
a = Array.new
a << {"success"=>"true"}

View File

@ -4,6 +4,7 @@ class Desktop
field :theme, default: "default"
field :customtheme
field :wallpaper
belongs_to :user

View File

@ -81,8 +81,8 @@
<div class="diag_holder_inner">
<div class="diag_message">Continue anyway?</div>
<div class="diag_action">
<a href="" id="diag_confirm" class="diag_btn thmc1 thmtxt w1 hh2 hp">Yes</a>
<a href="" id="diag_cancel" class="diag_btn admbg admtxt w1 hh2 hp">Cancel</a>
<a href="" id="diag_confirm" class="diag_btn admbg admtxt w1 hh2 hp" onclick="return false;">Yes</a>
<a href="" id="diag_cancel" class="diag_btn admbg admtxt w1 hh2 hp" onclick="return false;">Cancel</a>
</div>
</div>
</div>

View File

@ -64,21 +64,21 @@
</div>
<div id="st3" class="st_c">
<div class="stock_wallpaper ssl">
<div class="sb1 ssl_item"><img src="assets/stockBackground/thumb/1.jpg" alt=""></div>
<div class="sb2 ssl_item"><img src="assets/stockBackground/thumb/2.jpg" alt=""></div>
<div class="sb3 ssl_item"><img src="assets/stockBackground/thumb/3.jpg" alt=""></div>
<div class="sb4 ssl_item"><img src="assets/stockBackground/thumb/4.jpg" alt=""></div>
<div class="sb5 ssl_item"><img src="assets/stockBackground/thumb/5.jpg" alt=""></div>
<div class="sb6 ssl_item"><img src="assets/stockBackground/thumb/6.jpg" alt=""></div>
<div class="sb7 ssl_item"><img src="assets/stockBackground/thumb/7.jpg" alt=""></div>
<div class="sb8 ssl_item"><img src="assets/stockBackground/thumb/8.jpg" alt=""></div>
<div class="sb9 ssl_item"><img src="assets/stockBackground/thumb/9.jpg" alt=""></div>
<div class="sb10 ssl_item"><img src="assets/stockBackground/thumb/10.jpg" alt=""></div>
<div class="sb11 ssl_item"><img src="assets/stockBackground/thumb/11.jpg" alt=""></div>
<div class="sb12 ssl_item"><img src="assets/stockBackground/thumb/12.jpg" alt=""></div>
<div class="sb1 ssl_item"><img src="assets/stockBackground/thumb/1.jpg" alt="1.jpg"></div>
<div class="sb2 ssl_item"><img src="assets/stockBackground/thumb/2.jpg" alt="2.jpg"></div>
<div class="sb3 ssl_item"><img src="assets/stockBackground/thumb/3.jpg" alt="3.jpg"></div>
<div class="sb4 ssl_item"><img src="assets/stockBackground/thumb/4.jpg" alt="4.jpg"></div>
<div class="sb5 ssl_item"><img src="assets/stockBackground/thumb/5.jpg" alt="5.jpg"></div>
<div class="sb6 ssl_item"><img src="assets/stockBackground/thumb/6.jpg" alt="6.jpg"></div>
<div class="sb7 ssl_item"><img src="assets/stockBackground/thumb/7.jpg" alt="7.jpg"></div>
<div class="sb8 ssl_item"><img src="assets/stockBackground/thumb/8.jpg" alt="8.jpg"></div>
<div class="sb9 ssl_item"><img src="assets/stockBackground/thumb/9.jpg" alt="9.jpg"></div>
<div class="sb10 ssl_item"><img src="assets/stockBackground/thumb/10.jpg" alt="10.jpg"></div>
<div class="sb11 ssl_item"><img src="assets/stockBackground/thumb/11.jpg" alt="11.jpg"></div>
<div class="sb12 ssl_item"><img src="assets/stockBackground/thumb/12.jpg" alt="12.jpg"></div>
</div>
<div class="s_action">
<a href="" id="theme_submit" class="setting_btn thmc1 thmtxt w1 hh2 hp">Confirm</a>
<!-- <div href="" class="setting_btn thmc1 thmtxt w1 hh2 hp" onclick="o.tempFunc();return false;">Confirm</a> -->
</div>
<div class="clear"></div>
</div>