features and widgets added
Conflicts: app/assets/javascripts/orbitdesktop.js
This commit is contained in:
1 parent
c8aa50ee87
commit
793d739726
9 files changed
+193
-62
No files matched your search
@@ -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(){
|
||||
@@ -114,7 +181,32 @@ var orbitDesktop = function(dom){
|
||||
o.loadIconCache();
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
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;
|
||||
|
||||
Reference in new issue
Block a user