From 7488341836272838e379463f88d08ca38d4423e7 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Fri, 25 May 2012 15:41:07 +0800 Subject: [PATCH] Commit for app window.. --- app/assets/javascripts/orbitdesktop.js | 17 ++++- app/assets/javascripts/orbitdesktopAPI.js | 74 ++++++++++++++++++- app/assets/stylesheets/desktopmain.css | 12 +-- .../4fa78197c88514014d7c59c4/index.html.erb | 2 +- .../4fba4bf36f4fea8095e389eb.js | 11 +++ .../4fba4bf36f4fea8095e389eb/index.html.erb | 9 +++ 6 files changed, 115 insertions(+), 10 deletions(-) create mode 100644 public/desktop_widgets/4fba4bf36f4fea8095e389eb/4fba4bf36f4fea8095e389eb.js create mode 100644 public/desktop_widgets/4fba4bf36f4fea8095e389eb/index.html.erb diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index 88b34239..3dd51128 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -123,6 +123,14 @@ var orbitDesktop = function(dom){ var ww = $(window).width(); $("img#thmbackground").attr({"width":ww}); if( $('.tinycanvas') ){ $('.tinycanvas').tinyscrollbar_update(); } + if($(o.contentHolder).find("div.app_frame").length > 0){ + $(o.contentHolder).find("div.app_frame").each(function(){ + var app_holder_height = $(this).height() - 72; + var app_holder_width = $(this).width(); + $(this).find("div.app_holder").height(app_holder_height); + $(this).find("div.app_holder iframe").attr({"height":app_holder_height,"width":app_holder_width}); + }) + } }); var $widget_fn = $('.widget_fn'),$fn_des = $('.fn_des'); $widget_fn.hover(function(){ @@ -231,7 +239,12 @@ var orbitDesktop = function(dom){ $(this).removeClass('thmc2'); }); } - + $("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(); @@ -285,7 +298,7 @@ var orbitDesktop = function(dom){ if(j==0)$group.attr("id",tile.group_id); if(tile.data_category == "app") - $li = $('
  • '+tile.title+'

  • '); + $li = $('
  • '+tile.title+'

  • '); else $li = $('
  • '+tile.title+'

    Loading...
  • '); diff --git a/app/assets/javascripts/orbitdesktopAPI.js b/app/assets/javascripts/orbitdesktopAPI.js index de093973..2d91dbbb 100644 --- a/app/assets/javascripts/orbitdesktopAPI.js +++ b/app/assets/javascripts/orbitdesktopAPI.js @@ -2,7 +2,12 @@ //Harry Bomrah var orbitDesktopAPI = function(){ o = this; + this.windowcounter = 0; this.notify = function(msg,type,time){ + //takes 3 arguments + //msg (string) : message to display + //type (string : success, imp, alert + //time (int) : duration for notification in seconds var $notify = $("#orbitnote"); var img, n_height; if(!type)type=""; @@ -31,12 +36,19 @@ var orbitDesktopAPI = function(){ .animate({top:-n_height,opacity:0},200); }; this.executeFunc = function(func,callbackFn){ + //takes 2 arguments + //func (object Function) : the function which has to be executed + //callbackFn (object function) : the function for callback func.call(this); if(callbackFn){ callbackFn.call(this,func); } }; this.sortJSON = function(field, reverse, primer){ + //takes 3 arguments + //field (string): it is the field on which sorting has to be done + //reverse (boolean): this is for asc or desc + //primer (method): for example pass parseInt for converting the field attribute in integer var key = function (x) {return primer ? primer(x[field]) : x[field]}; return function (a,b) { var A = key(a), B = key(b); @@ -44,6 +56,8 @@ var orbitDesktopAPI = function(){ } }; this.rgb2hex = function(rgb) { + // takes 1 parameter + // rgb (string) : pass rgb string to convert rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); var hex = function(x) { return ("0" + parseInt(x).toString(16)).slice(-2); @@ -51,10 +65,18 @@ var orbitDesktopAPI = function(){ return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]); }; this.changeWallpaper = function(wallpaper){ + //takes 1 parameter + //wallpaper (string): takes wallpaper and sets the wallpaper $("img#thmbackground").attr("src",o.wallpaperPath+wallpaper); o.saveWallpaper(wallpaper); }; this.confirm = function(settings,callbackfn){ + //takes set of arguments in array + //settings.buttons (array string) : name of buttons to be displayed + //settings.highlighted (integer) : takes either 1 or 2.. will highlight the button which is passed + //settings.message (string) : takes a string and message to be displayed on the confirmbox + //callbackfn (object function) : function to callback + if(!settings.buttons)settings.buttons=["Ok","Cancel"]; if(settings.highlighted!=1 && settings.highlighted!=2)settings.highlighted=2; if(!settings.message)settings.message = "Are you sure?" @@ -80,12 +102,62 @@ var orbitDesktopAPI = function(){ $confirm.stop(1,1).fadeIn(); }; this.getArrayfromJson = function(tjson,key){ + // returns array and takes json object and key + //json (json object) : json object from which the key has to be extracted + // key (string) : key which has to be extracted var tempArray = new Array; $.each(tjson,function(i,val){ tempArray.push(val[key]); }) return tempArray; - } + }; + this.appWindow = function(settings,callbackfn){ + //takes set of arguments as array and gives callback + //settings.method (string) : like open and close + //settings.title (string) : the window title + //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 = {}; + if(!settings.appid){ + o.notify("Invalid AppID.","imp",3); + return; + } + if(!settings.method)settings.method = "open"; + 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.url){ + if(settings.url.substr(0,3)!="http")settings.url = "http://"+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; + else{ + o.notify("Invalid URL","alert",3); + return; + } + } + else{ + o.notify("Invalid URL","alert",3); + return; + } + } + var whtml =$('
    '); + $(o.contentHolder).append(whtml); + var parentwindow = $(o.contentHolder).find("div#app_frame_"+o.windowcounter); + var app_holder_height = parentwindow.height() - 72; + var app_holder_width = parentwindow.width(); + parentwindow.find("iframe").attr({"height":app_holder_height,"width":app_holder_width}); + parentwindow.find("div.app_holder").height(app_holder_height); + parentwindow.find("span.icon-remove").click(function(){ + parentwindow.remove(); + }) + } + if(typeof callbackfn=="function"){ + callbackfn.call(this); + } + }; }; orbitDesktopAPI.prototype.notifyImgPath = "temp"; orbitDesktopAPI.prototype.wallpaperPath = "temp"; diff --git a/app/assets/stylesheets/desktopmain.css b/app/assets/stylesheets/desktopmain.css index 9cfa6b92..72f29096 100644 --- a/app/assets/stylesheets/desktopmain.css +++ b/app/assets/stylesheets/desktopmain.css @@ -74,7 +74,7 @@ a:focus { outline: none; } position: absolute; top: 120px; left: 0; - z-index: 9; + z-index: 10; } #holder { /*overflow: hidden; @@ -692,7 +692,7 @@ a:focus { outline: none; } #paper_add label { margin-right: 0; } /* App */ -#app_frame { +.app_frame { margin: 48px 96px 48px 158px; min-width: 800px; min-height: 588px; @@ -703,15 +703,15 @@ a:focus { outline: none; } bottom: 0; z-index: 9; } -#app_frame .holder { +.app_frame .app_holder { background-color: #fff; position: absolute; width: 100%; } -#app_frame #header .icon-remove { +.app_frame #header .icon-remove { display: block; - float: left; + float: right; line-height: 60px; font-size: 20px; cursor: pointer; -} \ No newline at end of file +} diff --git a/public/desktop_widgets/4fa78197c88514014d7c59c4/index.html.erb b/public/desktop_widgets/4fa78197c88514014d7c59c4/index.html.erb index 522c6ad5..26a3bbe4 100644 --- a/public/desktop_widgets/4fa78197c88514014d7c59c4/index.html.erb +++ b/public/desktop_widgets/4fa78197c88514014d7c59c4/index.html.erb @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/public/desktop_widgets/4fba4bf36f4fea8095e389eb/4fba4bf36f4fea8095e389eb.js b/public/desktop_widgets/4fba4bf36f4fea8095e389eb/4fba4bf36f4fea8095e389eb.js new file mode 100644 index 00000000..726eee23 --- /dev/null +++ b/public/desktop_widgets/4fba4bf36f4fea8095e389eb/4fba4bf36f4fea8095e389eb.js @@ -0,0 +1,11 @@ +var openURL = function(){ + $("div[data-content=4fba4bf36f4fea8095e389eb] form#browse_url_4fba4bf36f4fea8095e389eb").submit(function(){ + var urlToOpen = $(this).find("input").val(); + o.appWindow({ + title: "Browser", + appid: "extURL", + url: urlToOpen + }); + return false; + }) +} \ No newline at end of file diff --git a/public/desktop_widgets/4fba4bf36f4fea8095e389eb/index.html.erb b/public/desktop_widgets/4fba4bf36f4fea8095e389eb/index.html.erb new file mode 100644 index 00000000..cc1c1c70 --- /dev/null +++ b/public/desktop_widgets/4fba4bf36f4fea8095e389eb/index.html.erb @@ -0,0 +1,9 @@ +
    +
    +
    + +
    +
    + \ No newline at end of file