new feature in desktop for uploading wallpapers or putting url link

This commit is contained in:
Harry Bomrah 2013-08-01 21:50:49 +08:00 committed by saurabhbhatia
parent 0f3a8414be
commit 42615f02ea
35 changed files with 97 additions and 34 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 516 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 278 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 651 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 427 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -1,5 +1,5 @@
// JavaScript Document
//harry
//harry bomrah
//Inititialize function will initialize desktop
//callback-method will be called after desktop controlled ajax call
@ -16,6 +16,11 @@
//"pagination-link" = "url" this url will be used for pagination.. this will override last link url.
//"pagination-var" = "variable to send paramater with url for pagination" this will enable pagination with this attribute for that view.
//for forms
//form-type = "ajax_form" will turn form to ajax submit
//notification = string will display after the form is succesfully submitted
//for layout tinyscrollbar
//content-layout="datalist|column|simple" datalist is for data list from database.. column is usually for forms and some other pages.. simple is without any columns, the page will be displayed as it is.. base width will be considered the default width for tinyscrollbar
//base-width="300" this is the basic width of each column and in case of simple layout it ll be the final width
@ -241,20 +246,24 @@ var orbitDesktop = function(dom){
},'*[content-type=menu] a');
$("body").on("submit","form[form-type=ajax_form]",function(){
var callback_method = $(this).attr("callback-method");
var dt = null;
var callback_method = $(this).attr("callback-method"),
dt = null,
notification = $(this).attr("notification");
dt = $(this).attr("response-type");
if(dt == null){
dt = "json";
}
var options = {
dataType : dt,
resetForm : true,
success:function(responseText, statusText, xhr, $form){
if(typeof callback_method != "undefined"){
if(callback_method != ""){
window.o[o.data_method][callback_method](responseText,statusText,xhr,$form);
}
}
if(notification != "")
o.notify(notification,"success");
},
error:function(){
o.notify("Please try again later!","imp");
@ -1242,8 +1251,8 @@ var orbitDesktop = function(dom){
});
$(".stock_wallpaper .ssl_item").click(function(){
var wallpapername = $(this).find("img").attr("alt");
o.changeWallpaper(wallpapername);
var wallpaper = $(this).find("img").data("link");
o.changeWallpaper(wallpaper);
})
}
var loadthmc = function(){ // a general function to load the themecolor in color selector
@ -1516,7 +1525,7 @@ var orbitDesktop = function(dom){
if(!wallpaper){
$("#thmbackground").attr("src",o.themesettings.background);
} else {
$("#thmbackground").attr("src",o.wallpaperPath+wallpaper);
$("#thmbackground").attr("src",wallpaper);
}
};

View File

@ -72,7 +72,7 @@ var orbitDesktopAPI = function(){
this.changeWallpaper = function(wallpaper){
//takes 1 parameter
//wallpaper (string): takes wallpaper and sets the wallpaper
$("#thmbackground").attr("src",o.wallpaperPath+wallpaper);
$("#thmbackground").attr("src",wallpaper);
o.saveWallpaper(wallpaper);
};
this.confirm = function(settings,callbackfn){

View File

@ -1,5 +1,5 @@
// JavaScript Document
//harry
//harry bomrah
//Inititialize function will initialize desktop
//callback-method will be called after desktop controlled ajax call

View File

@ -32,8 +32,9 @@ class DesktopController< ApplicationController
end
def get_themes
desktop = current_user.desktop
@themes = DesktopTheme.all
# raise @themes.inspect
@wallpapers = desktop.desktop_wallpapers.all
render "desktop/settings/themes", :layout => false
end
@ -46,6 +47,23 @@ class DesktopController< ApplicationController
render "desktop/settings/connections", :layout => false
end
def wallpaper_upload
desktop = current_user.desktop
wallpaper = desktop.desktop_wallpapers.new
if params[:imagelink] != ""
wallpaper.type = "url"
wallpaper.link = params[:imagelink]
wallpaper.save!
elsif params[:imagefile]
wallpaper.file = params[:imagefile]
wallpaper.type = "file"
wallpaper.save!
end
render :json=>{"success"=>true}.to_json
end
#ajax data load....

View File

@ -11,21 +11,36 @@ class FacebookController< ApplicationController
user.save!
end
render :json=>{"success"=>true,"user"=>user.facebook.fb_identifier}.to_json
# respond_to do |format|
# format.js
# end
end
def get_friends
@url = "http://fb.tp.rulingcom.com/get_friends?identifier=" + current_user.facebook.fb_identifier
uri = URI.parse(@url)
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
friends = response.body
friends = JSON.parse(friends)
output = Array.new
friends.each do |friend|
output << friend['name']
end
render :json=>{"count"=>friends.count,"friends"=>output}.to_json
if current_user.facebook
@url = "http://fb.tp.rulingcom.com/get_friends?identifier=" + current_user.facebook.fb_identifier
uri = URI.parse(@url)
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
friends = response.body
friends = JSON.parse(friends)
output = Array.new
friends.each do |friend|
output << {"name"=>friend['name'],"identifier"=>friend['identifier']}
end
render :json=>{"success"=>true,"count"=>friends.count,"friends"=>output}.to_json
else
render :json=>{"success"=>false,"message"=>"User is not connected to facebook."}.to_json
end
end
def disconnect
user_fb = current_user.facebook
if user_fb
user_fb.destroy
end
render :json=>{"success"=>true}.to_json
end
end

View File

@ -10,6 +10,7 @@ class Desktop
has_and_belongs_to_many :desktop_widgets, :autosave => true
has_many :sections, :autosave => true, :dependent => :destroy
has_many :desktop_wallpapers, :autosave => true, :dependent => :destroy
# has_many :desktop_widgets, :autosave => true, :dependent => :destroy
before_create :initialize_section

View File

@ -0,0 +1,11 @@
class DesktopWallpaper
include Mongoid::Document
include Mongoid::Timestamps
mount_uploader :file, ImageUploader
field :type
field :link
belongs_to :desktop
end

View File

@ -3,6 +3,7 @@
<a href="" onclick="window.open('<%= @url %>','login_window','height=250,width=400,titlebar=0,statusbar=0,location=0');return false;">Connect FaceBook</a>
<a href="/facebook/get_friends" ajax-remote="get" >Get Friends</a>
<a href="/facebook/disconnect" ajax-remote="get" >Disconnect from facebook</a>
<!-- <ul class="s_form w2 hp" id="facebook_connection">
<li><span class="c_status">No Connection</span></li>
<li><img src="/assets/connection/facebook.png" alt="" class="c_icon"><h1 class="c_name">Facebook</h1></li>

View File

@ -3,6 +3,7 @@
<li><a href="#st1" class="hh1 hp thmc2 thmtxt" data-active="true">Themes</a></li>
<li><a href="#st2" class="hh1 hp admtxt admbg">Theme Color</a></li>
<li><a href="#st3" class="hh1 hp admtxt admbg">Wallpaper</a></li>
<li><a href="#st4" class="hh1 hp admtxt admbg">Upload Wallpaper</a></li>
</ul>
</div>
@ -61,22 +62,27 @@
</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="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>
<% @wallpapers.each do |wallpaper| %>
<% if wallpaper.type == "file" %>
<div class="sb1 ssl_item"><img src="<%= wallpaper.file.thumb %>" data-type="<%= wallpaper.type %>" data-link="<%= wallpaper.file %>"></div>
<% elsif wallpaper.type == "url" %>
<div class="sb1 ssl_item"><img src="<%= wallpaper.link %>" data-type="<%= wallpaper.type %>" data-link="<%= wallpaper.link %>"></div>
<% end %>
<% end %>
</div>
<!-- <div class="s_action">
<div href="" class="setting_btn thmc1 thmtxt w1 hh1 hp" onclick="o.tempFunc();return false;">Confirm</a>
</div> -->
<div class="clear"></div>
</div>
<div id="st4" class="st_c">
<form action="<%= desktop_wallpaper_upload_path %>" method="post" form-type="ajax_form" notification="Wallpaper uploaded successfully!!!">
<label>Image Link</label><input type="text" name="imagelink" />
Or
<label>Upload from computer</label><input type="file" name="imagefile" />
<input type="submit" class="fn_btn ini_input hp hh1 thmc2 thmtxt" value="Save" />
<input type="reset" class="fn_btn ini_input hp hh1 thmc2 thmtxt" value="Clear" />
</form>
</div>
</div>

View File

@ -0,0 +1 @@
window.close();

View File

@ -301,8 +301,9 @@ Orbit::Application.routes.draw do
match "/facebook/register_fb" => "facebook#register_fb"
match "/facebook/get_friends" => "facebook#get_friends"
match "/facebook/disconnect" => "facebook#disconnect"
match "/desktop/wallpaper_upload" => "desktop#wallpaper_upload"
#match '/desktop_orbit/eventajaxload' => 'desktop_publications#create_journal'
#match '/desktop_orbit/eventajaxload' => 'desktop_publications#delete_journal'