features and widgets added
Conflicts: app/assets/javascripts/orbitdesktop.js
This commit is contained in:
parent
c8aa50ee87
commit
793d739726
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 8.0 KiB |
|
@ -37,6 +37,71 @@ var sortAscending = function(a, b) {
|
|||
var sortDescending = function(a, b) {
|
||||
return $(a).find("h1").text() < $(b).find("h1").text() ? 1 : -1;
|
||||
};
|
||||
jQuery.ajax = (function(_ajax){
|
||||
|
||||
var protocol = location.protocol,
|
||||
hostname = location.hostname,
|
||||
exRegex = RegExp(protocol + '//' + hostname),
|
||||
YQL = 'http' + (/^https/.test(protocol)?'s':'') + '://query.yahooapis.com/v1/public/yql?callback=?',
|
||||
query = 'select * from html where url="{URL}" and xpath="*"';
|
||||
|
||||
function isExternal(url) {
|
||||
return !exRegex.test(url) && /:\/\//.test(url);
|
||||
}
|
||||
|
||||
return function(o) {
|
||||
|
||||
var url = o.url;
|
||||
|
||||
if ( /get/i.test(o.type) && !/json/i.test(o.dataType) && isExternal(url) ) {
|
||||
|
||||
// Manipulate options so that JSONP-x request is made to YQL
|
||||
|
||||
o.url = YQL;
|
||||
o.dataType = 'json';
|
||||
|
||||
o.data = {
|
||||
q: query.replace(
|
||||
'{URL}',
|
||||
url + (o.data ?
|
||||
(/\?/.test(url) ? '&' : '?') + jQuery.param(o.data)
|
||||
: '')
|
||||
),
|
||||
format: 'xml'
|
||||
};
|
||||
|
||||
// Since it's a JSONP request
|
||||
// complete === success
|
||||
if (!o.success && o.complete) {
|
||||
o.success = o.complete;
|
||||
delete o.complete;
|
||||
}
|
||||
|
||||
o.success = (function(_success){
|
||||
return function(data) {
|
||||
|
||||
if (_success) {
|
||||
// Fake XHR callback.
|
||||
_success.call(this, {
|
||||
responseText: (data.results[0] || '')
|
||||
// YQL screws with <script>s
|
||||
// Get rid of them
|
||||
.replace(/<script[^>]+?\/>|<script(.|\s)*?\/script>/gi, '')
|
||||
}, 'success');
|
||||
}
|
||||
|
||||
};
|
||||
})(o.success);
|
||||
|
||||
}
|
||||
|
||||
return _ajax.apply(this, arguments);
|
||||
|
||||
};
|
||||
|
||||
})(jQuery.ajax);
|
||||
|
||||
|
||||
var orbitDesktop = function(dom){
|
||||
orbitDesktopAPI.apply(this);
|
||||
// o = this;
|
||||
|
@ -53,11 +118,12 @@ var orbitDesktop = function(dom){
|
|||
this.gridvar = null;
|
||||
this.lastlink= null;
|
||||
this.tinyscrollbar = null;
|
||||
this.locationdata = {};
|
||||
this.initialize = function(){
|
||||
|
||||
var theme = o.theme;
|
||||
var custom = false;
|
||||
|
||||
o.getlocation();
|
||||
$.getJSON("/desktop/get_desktop_settings",{"get":"desktop","desktopid":o.desktopId},function(desktopSettings){
|
||||
if(desktopSettings){
|
||||
if(desktopSettings.theme!="custom"){
|
||||
|
@ -82,6 +148,7 @@ var orbitDesktop = function(dom){
|
|||
o.loadWallpaper(customwallpaper);
|
||||
o.bindDesktopEvents();
|
||||
o.loadIconCache();
|
||||
o.getlocation();
|
||||
var custom_load = window.location.hash;
|
||||
if(!custom_load){
|
||||
$(o.contentHolder).empty().load("/desktop/desktop",function(){
|
||||
|
@ -115,6 +182,31 @@ var orbitDesktop = function(dom){
|
|||
})
|
||||
};
|
||||
|
||||
this.getlocation = function(){
|
||||
var locationSuccess = function(pos){
|
||||
o.locationdata.lat = pos.coords.latitude;
|
||||
o.locationdata.lng = pos.coords.longitude;
|
||||
$.getJSON("http://maps.googleapis.com/maps/api/geocode/json?latlng="+o.locationdata.lat+","+o.locationdata.lng+"&sensor=true",function(data){
|
||||
$.each(data.results[0].address_components,function(i,val){
|
||||
o.locationdata[val.types[0]] = val.long_name;
|
||||
})
|
||||
o.locationdata.formatted_address = data.results[0].formatted_address;
|
||||
})
|
||||
}
|
||||
|
||||
var locationError = function(){
|
||||
o.notify("Unable to find your location!","alert");
|
||||
}
|
||||
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(locationSuccess,locationError);
|
||||
}
|
||||
else{
|
||||
o.notify("Your browser does not support Geolocation!","alert");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.bindDesktopEvents = function(){ //this function will bind the global handlers to thd desktop, for example doc
|
||||
$(".docklist a").click(function(){
|
||||
o.menu_item($(this));
|
||||
|
@ -296,17 +388,16 @@ var orbitDesktop = function(dom){
|
|||
column_container = $e.find("div.overview");
|
||||
layout = column_container.attr("content-layout"), base_width = parseInt(column_container.attr("base-width")), no_of_entries,total_columns=0, pagination_link = column_container.attr("pagination-link"), pagination_variable = column_container.attr("pagination-var");
|
||||
var temp_div = $("<div></div>");
|
||||
var entries = [];
|
||||
switch (layout){
|
||||
case "simple":
|
||||
total_columns++;
|
||||
temp_div.append(column_container.html());
|
||||
var entries = [];
|
||||
total_width = "auto";
|
||||
break;
|
||||
case "datalist":
|
||||
no_of_entries = (typeof column_container.attr("per-column") != "undefined"? parseInt(column_container.attr("per-column")) : 4);
|
||||
var height_percentage = 100/no_of_entries;
|
||||
var entries = column_container.find("li[item=true]"),x = 0;
|
||||
entries = column_container.find("li[item=true]"),x = 0;
|
||||
if(entries.length != 0){
|
||||
entries.each(function(i,li){
|
||||
if(x == 0){
|
||||
|
@ -324,7 +415,7 @@ var orbitDesktop = function(dom){
|
|||
total_width = (!isNaN(base_width)) ? (base_width + gutter*2 +1) * total_columns : null;
|
||||
break;
|
||||
case "column":
|
||||
var entries = column_container.find("div[column=true]"),x = 0,column;
|
||||
entries = column_container.find("div[column=true]"),x = 0,column;
|
||||
if(entries.length!=0){
|
||||
entries.each(function(i,ul){
|
||||
column = $("<div class='column type_column' style='width:"+base_width+"px;margin-right:"+gutter+"px;padding-right:"+gutter+"px;'></div");
|
||||
|
@ -336,6 +427,9 @@ var orbitDesktop = function(dom){
|
|||
}
|
||||
total_width = (!isNaN(base_width)) ? (base_width + gutter*2 +1) * total_columns : null;
|
||||
break;
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
// total_width = (!isNaN(base_width) ? ( base_width + 12 ) * total_columns : null);
|
||||
return {"markup":temp_div.html(),"width":total_width,"total":entries.length};
|
||||
|
@ -440,6 +534,7 @@ var orbitDesktop = function(dom){
|
|||
if(!customload)customload=false;
|
||||
var target = dom.attr("id");
|
||||
var url = dom.attr("href");
|
||||
if(!url)return false;
|
||||
o.lastlink = url;
|
||||
o.data_method = dom.attr("callback-method");
|
||||
if(o.currenthtml!=target){
|
||||
|
@ -452,7 +547,6 @@ var orbitDesktop = function(dom){
|
|||
$("#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){
|
||||
|
@ -609,51 +703,6 @@ var orbitDesktop = function(dom){
|
|||
// }
|
||||
// }
|
||||
// });
|
||||
o.simple_drop_down();
|
||||
o.tinyscrollbar_ext({
|
||||
main: '.tinycanvas'
|
||||
})
|
||||
|
||||
|
||||
// $("div#group_wrapper ul li[data-category=app]").click(function(){
|
||||
// o.appWindow({
|
||||
// title : $(this).find("a").attr("href"),
|
||||
// appid : $(this).find("a").attr("href")
|
||||
// });
|
||||
// });
|
||||
}
|
||||
var loadTiles = function(id){ //This will load tiles for a specific desktop .. id of section has to be passed here to load tiles
|
||||
$("div#desktop div#group_wrapper").empty();
|
||||
$.getJSON("/desktop/getgroups",{sectionid:id},function(tiles){
|
||||
tiles.sort(o.sortJSON("position",true,parseInt));
|
||||
var tilecolors = o.themesettings.tilecolor;
|
||||
var totaltiles_in_a_row = 4;
|
||||
var opacity = ["op05","op06","op07","op08","op09"];
|
||||
var row = 1,col = 1,x = 1,y = 1;
|
||||
var $group = $('<div class="grid gridster"></div>');
|
||||
var $ul = $('<ul style="margin: -6px 0 0 -6px;"></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));
|
||||
var tilecolor = tilecolors[Math.floor(Math.random()*tilecolors.length)];
|
||||
var op = opacity[Math.floor(Math.random()*opacity.length)];
|
||||
if(tile.data_category == "app")
|
||||
$li = $('<li data-id="'+tile.id+'" class="widget" data-row="'+row+'" data-col="'+col+'" data-sizex="'+x+'" data-sizey="'+y+'" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'"><span class="tile '+tilecolor+' '+op+'"></span><a href="'+tile.data_content+'" class="appicon" onclick="return false;"><img src="'+o.iconPath+tile.data_content+'.png" alt="" ></a><h1 class="appname thmtxt">'+tile.title+'</h1></li>');
|
||||
else
|
||||
$li = $('<li data-id="'+tile.id+'" class="widget" data-row="'+row+'" data-col="'+col+'" data-sizex="'+x+'" data-sizey="'+y+'" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'" js-link="'+tile.js[0].url+'" css-link="'+tile.css.url+'"><span class="tile '+tilecolor+' '+op+'"></span><div class="appholder"><div class="thmtxt o-loading"><i class="icon-spinner icon-spin"></i> Loading</div></div><h1 class="appname thmtxt">'+tile.title+'</h1></li>');
|
||||
|
||||
row = row + y;
|
||||
|
||||
$ul.append($li);
|
||||
})
|
||||
$group.append($ul);
|
||||
$("div#desktop div#group_wrapper").append($group);
|
||||
var dragged = null,draggable,lastpos = [];
|
||||
o.gridvar = $(".grid ul").find("> li ").mousedown(function(e){
|
||||
!draggable;
|
||||
|
@ -668,7 +717,11 @@ var orbitDesktop = function(dom){
|
|||
widget_base_dimensions: [120, 120],
|
||||
// avoid_overlapped_widgets: true,
|
||||
draggable : {
|
||||
start : function(event, ui){
|
||||
dragged.addClass("noClick");
|
||||
},
|
||||
stop: function(event, ui){
|
||||
|
||||
// var widgetchanged_col = dragged.attr("data-col");
|
||||
// var total = 0;
|
||||
// // console.log(widgetchanged.col);
|
||||
|
@ -706,7 +759,7 @@ var orbitDesktop = function(dom){
|
|||
$(".grid ul .widget[data-col="+i+"]").each(function(){
|
||||
var pos = $(this).position();
|
||||
if(pos){
|
||||
console.log(pos.top + $(this).height() + 6);
|
||||
|
||||
if((pos.top + $(this).height() + 6) > 550){
|
||||
revertbacktiles();
|
||||
|
||||
|
@ -733,6 +786,66 @@ var orbitDesktop = function(dom){
|
|||
break;
|
||||
}
|
||||
}
|
||||
o.simple_drop_down();
|
||||
o.tinyscrollbar_ext({
|
||||
main: '.tinycanvas'
|
||||
})
|
||||
$("li.app[data-category=app]").click(function(){
|
||||
if(!$(this).hasClass("noClick")){
|
||||
var url = $(this).find("a").data("url");
|
||||
var app = $(this);
|
||||
o.appWindow({
|
||||
"appid" : app.data("id"),
|
||||
"title" : app.data("title"),
|
||||
"url" : url
|
||||
})
|
||||
}
|
||||
dragged.removeClass("noClick");
|
||||
|
||||
})
|
||||
|
||||
// $("div#group_wrapper ul li[data-category=app]").click(function(){
|
||||
// o.appWindow({
|
||||
// title : $(this).find("a").attr("href"),
|
||||
// appid : $(this).find("a").attr("href")
|
||||
// });
|
||||
// });
|
||||
}
|
||||
var loadTiles = function(id){ //This will load tiles for a specific desktop .. id of section has to be passed here to load tiles
|
||||
$("div#desktop div#group_wrapper").empty();
|
||||
$.getJSON("/desktop/getgroups",{sectionid:id},function(tiles){
|
||||
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 $group = $('<div class="grid gridster"></div>');
|
||||
var $ul = $('<ul style="margin: -6px 0 0 -6px;"></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));
|
||||
var tilecolor = tilecolors[Math.floor(Math.random()*tilecolors.length)];
|
||||
var op = opacity[Math.floor(Math.random()*opacity.length)];
|
||||
var f = (tile.fullsize?"fullsize":null);
|
||||
|
||||
if(tile.data_category == "app")
|
||||
$li = $('<li data-id="'+tile.id+'" class="app" data-row="'+row+'" data-col="'+col+'" data-sizex="'+x+'" data-sizey="'+y+'" data-title="'+tile.title+'" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'"><span class="tile '+tilecolor+' '+op+'"></span><a href="'+tile.data_content+'" class="appicon" onclick="return false;" data-url="'+tile.link+'"><img src="'+o.iconPath+tile.data_content+'.png" alt="" ></a><h1 class="appname thmtxt">'+tile.title+'</h1></li>');
|
||||
else
|
||||
$li = $('<li data-id="'+tile.id+'" class="widget '+f+'" data-row="'+row+'" data-col="'+col+'" data-sizex="'+x+'" data-sizey="'+y+'" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'" js-link="'+tile.js[0].url+'" css-link="'+tile.css.url+'"><span class="tile '+tilecolor+' '+op+'"></span><div class="appholder"><div class="thmtxt all-loading"><i class="icon-spinner icon-spin"></i> Loading </div></div><h1 class="appname thmtxt">'+tile.title+'</h1></li>');
|
||||
|
||||
row = row + y;
|
||||
|
||||
$ul.append($li);
|
||||
})
|
||||
$group.append($ul);
|
||||
$("div#desktop div#group_wrapper").append($group);
|
||||
|
||||
bindHandlers();
|
||||
o.initializeWidgets();
|
||||
})
|
||||
|
|
|
@ -115,6 +115,7 @@ var orbitDesktopAPI = function(){
|
|||
//takes set of arguments as array and gives callback
|
||||
//settings.method (string) : like open and close
|
||||
//settings.title (string) : the window title
|
||||
//settings.extUrl (boolean) : true for opening external url else false
|
||||
//settings.appid (string) : appid.. user can use this appid to open or close or refresh the window
|
||||
//settings.url (string) : it is the url if you want to force external url to open in appwindow... you have to pass extURL in appid if you want to open externalurl
|
||||
if(typeof settings == "undefined")settings = {};
|
||||
|
@ -123,13 +124,16 @@ var orbitDesktopAPI = function(){
|
|||
return;
|
||||
}
|
||||
if(!settings.method)settings.method = "open";
|
||||
if(!settings.extUrl)settings.extUrl = true;
|
||||
if(settings.method == 'open'){
|
||||
var appurl = "http://www.rulingcom.com";
|
||||
o.windowcounter++;
|
||||
if(!settings.title)settings.title = "New Window "+o.windowcounter;
|
||||
if(settings.appid=="extURL"){
|
||||
if(settings.extUrl){
|
||||
if(settings.url){
|
||||
if(settings.url.substr(0,3)!="http")settings.url = "http://"+settings.url;
|
||||
|
||||
if(settings.url.substr(0,4)!="http")settings.url = "http://"+settings.url;
|
||||
console.log(settings.url)
|
||||
var urlregex = new RegExp("^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([0-9A-Za-z]+\.)");
|
||||
if(urlregex.test(settings.url))
|
||||
appurl = settings.url;
|
||||
|
@ -143,7 +147,7 @@ var orbitDesktopAPI = function(){
|
|||
return;
|
||||
}
|
||||
}
|
||||
var whtml =$('<div id="app_frame_'+o.windowcounter+'" class="thmc2 app_frame" data-content="'+settings.appid+'"><div id="content"><div id="header" class="hh3"><div class="dtitle w2 hh3 hp" style="text-transform:capitalize;"><span class="thmtxth">'+settings.title+'</span></div><span class="icon-remove hh3 hp thmtxt"></span></div><div id="holder_'+o.windowcounter+'" class="app_holder"><iframe src="'+appurl+'" frameborder="0" scrolling="auto"></iframe><div class="clear"></div></div></div></div>');
|
||||
var whtml =$('<div id="app_frame_'+o.windowcounter+'" class="thmc2 app_frame" data-app="'+settings.appid+'"><div id="content"><div id="header" class="hh3"><div class="dtitle w2 hh3 hp" style="text-transform:capitalize;"><span class="thmtxth">'+settings.title+'</span></div><span class="icon-remove hh3 hp thmtxt"></span></div><div id="holder_'+o.windowcounter+'" class="app_holder"><iframe src="'+appurl+'" frameborder="0" scrolling="auto"></iframe><div class="clear"></div></div></div></div>');
|
||||
$(o.contentHolder).append(whtml);
|
||||
var parentwindow = $(o.contentHolder).find("div#app_frame_"+o.windowcounter);
|
||||
var app_holder_height = parentwindow.height() - 72;
|
||||
|
|
|
@ -117,6 +117,8 @@ class DesktopController< ApplicationController
|
|||
jsfile = []
|
||||
cssfile = ""
|
||||
shape = "w1 h1"
|
||||
fullsize = false
|
||||
link = ""
|
||||
if tile.data_category == "widget"
|
||||
widge = DesktopWidget.find(tile.desktop_widget_id.to_s)
|
||||
# data_content = widge.widget_layout.file
|
||||
|
@ -125,11 +127,21 @@ class DesktopController< ApplicationController
|
|||
cssfile = widge.css_default.file.as_json[:file]
|
||||
shape = widge.shape
|
||||
title = widge.name
|
||||
# binding.pry
|
||||
if not widge.fullsize.nil?
|
||||
fullsize = widge.fullsize
|
||||
end
|
||||
else
|
||||
data_content = tile.data_content
|
||||
title = tile.title
|
||||
case data_content
|
||||
when "envocab"
|
||||
link = "http://www.english-vocabulary.eu/"
|
||||
when "wikibooks"
|
||||
link = "http://www.wikibooks.org"
|
||||
end
|
||||
gr << {"id"=>tile.id,"data_category"=>tile.data_category,"data_content"=>data_content,"js"=>jsfile,"css"=>cssfile,"shape"=>shape,"position"=>tile.position,"title"=>title}
|
||||
end
|
||||
gr << {"id"=>tile.id,"data_category"=>tile.data_category,"data_content"=>data_content,"js"=>jsfile,"css"=>cssfile,"shape"=>shape,"position"=>tile.position,"title"=>title,"fullsize"=>fullsize,"link"=>link}
|
||||
end
|
||||
# gr << a
|
||||
end
|
||||
|
|
|
@ -6,6 +6,7 @@ class DesktopWidget
|
|||
field :name
|
||||
field :author
|
||||
field :shape
|
||||
field :fullsize, :type => Boolean
|
||||
field :version, :type => String
|
||||
|
||||
has_one :css_default, as: :css, :autosave => true, :dependent => :destroy
|
||||
|
@ -13,7 +14,7 @@ class DesktopWidget
|
|||
has_many :images, as: :imgs, :autosave => true, :dependent => :destroy
|
||||
has_many :javascripts, as: :js, :autosave => true, :dependent => :destroy
|
||||
has_and_belongs_to_many :desktops, :autosave => true
|
||||
belongs_to :tiles, :autosave => true
|
||||
has_many :tiles, :autosave => true
|
||||
|
||||
accepts_nested_attributes_for :images, :allow_destroy => true
|
||||
accepts_nested_attributes_for :javascripts, :allow_destroy => true
|
||||
|
|
|
@ -6,9 +6,10 @@ class Tile
|
|||
field :data_content
|
||||
field :position, type: Integer
|
||||
field :shape
|
||||
field :fullsize, type: Boolean
|
||||
field :title
|
||||
|
||||
belongs_to :group
|
||||
has_one :desktop_widget
|
||||
belongs_to :desktop_widget
|
||||
|
||||
end
|
||||
|
|
|
@ -69,9 +69,9 @@ def cache_dir
|
|||
|
||||
|
||||
def manipulate!
|
||||
cache_stored_file! if !cached?
|
||||
# cache_stored_file! if !cached?
|
||||
#raise File.extname(current_path.to_s).to_s
|
||||
image = ::MiniMagick::Image.open(current_path)
|
||||
# image = ::MiniMagick::Image.open(current_path)
|
||||
# image = yield(image)
|
||||
# image.write(current_path)
|
||||
# ::MiniMagick::Image.open(current_path)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div id="side">
|
||||
<div id="rwidget" class="wh2 thmc4">
|
||||
<ul class="docklist">
|
||||
<li class="d_cate"><a callback-method='initializeDesktop' href="desktop/" class="widget_fn wh2 hh2" id='d_desktop' onclick="return false;"><span class="widget_icon"><img src="" alt="Home" id="home_icon" width="30" height="30"/></span></a>
|
||||
<li class="d_cate"><a callback-method='initializeDesktop' href="desktop/" class="widget_fn wh2 hh2" id='home' onclick="return false;"><span class="widget_icon"><img src="" alt="Home" id="home_icon" width="30" height="30"/></span></a>
|
||||
<ul class="dock_child hh2 thmc4" style="width: 180px;">
|
||||
<li class="dock_item"><a callback-method='initializeAppSearch' href="<%= desktop_app_manager_path %>" class="widget_fn wh2 hh2" id="d_app_manager" onclick="return false;"><span class="widget_icon"><img src="" alt="App Manager" id="app_manager_icon" width="30" height="30"/></span></a></li>
|
||||
<li class="dock_item"><a callback-method='initializeSectionsManager' href="<%= desktop_allsections_path %>" class="widget_fn wh2 hh2" id="d_sections" custom-load="sections" onclick="return false;"><span class="widget_icon"><img src="" alt="All Sections" id="sections_icon" width="30" height="30"/></span></a></li>
|
||||
|
|
Reference in New Issue