2012-07-04 09:55:30 +00:00
// JavaScript Document
//harry
//Inititialize function will initialize desktop
2012-11-15 03:18:55 +00:00
2012-11-22 08:31:37 +00:00
//callback-method will be called after desktop controlled ajax call
2012-11-20 09:20:05 +00:00
//container=true is the area where the view will be loaded
2013-03-06 11:04:33 +00:00
//load = true is used to load the submenu item by default
2012-11-22 08:31:37 +00:00
//response-type = "json"|"script"|"xml|html" default is json
2013-04-22 04:24:09 +00:00
//autocomplete = "url" this will automatically convert textarea or input to autocomplete.
//autocomplete-format = "--:[text,email]" first one is seperator which will be put on between every field.
2013-03-01 09:49:58 +00:00
//ajax-remote="get/delete/post/false" this will automatically bind the <a> with remote ajax call. By default if the resposne is html, it ll be inserted in container=true, false option will not make any calls and also stop page refresh
2012-12-27 10:25:54 +00:00
// content-holder = "jquery dom", the returned html of server will be put inside the dom mentioned in content-holder of a tag. this can be used in a tags as attributes
//confirm-message ="Some message", this will prompt user with a confirm box and show the message before ajax call is made.
2013-03-01 09:49:58 +00:00
//"toggle-onclick" = "classes to get toggle" this will toggle classes on toggle when a tags are clicked.
2013-03-06 11:04:33 +00:00
//"delete-item" = "true" this will remove its respective item from the list.
2013-03-14 06:00:04 +00:00
//"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.
2012-11-20 09:20:05 +00:00
2013-02-27 10:55:26 +00:00
//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
//per-column="5" this option is only for datalist layout.. this ll specify number of enteries per column.. default is 4
//column="true" this option is only for column layout... the columns will be formed on this column=true attribute and it should be a div
2013-03-01 09:49:58 +00:00
//item=true this attribute should be present in the li tag. li with this attribute are considered as a separate item.
2013-02-27 10:55:26 +00:00
2012-11-08 09:01:59 +00:00
2012-07-04 09:55:30 +00:00
$ . extend ( $ . expr [ ':' ] , {
2012-11-15 03:18:55 +00:00
'containsi' : function ( elem , i , match , array ) {
return ( elem . textContent || elem . innerText || '' ) . toLowerCase ( ) . indexOf ( ( match [ 3 ] || "" ) . toLowerCase ( ) ) >= 0 ;
}
2012-07-04 09:55:30 +00:00
} ) ;
$ . fn . sort = function ( c ) {
2012-11-15 03:18:55 +00:00
return this . pushStack ( [ ] . sort . apply ( this , arguments ) , [ ] ) ;
} ;
2012-07-04 09:55:30 +00:00
var sortAscending = function ( a , b ) {
2012-11-15 03:18:55 +00:00
return $ ( a ) . find ( "h1" ) . text ( ) > $ ( b ) . find ( "h1" ) . text ( ) ? 1 : - 1 ;
2012-07-04 09:55:30 +00:00
} ;
var sortDescending = function ( a , b ) {
2012-11-15 03:18:55 +00:00
return $ ( a ) . find ( "h1" ) . text ( ) < $ ( b ) . find ( "h1" ) . text ( ) ? 1 : - 1 ;
2012-07-04 09:55:30 +00:00
} ;
2013-05-14 09:18:05 +00:00
Array . prototype . indexOfObject = function ( object ) {
for ( i = 0 ; i < this . length ; i ++ ) {
2013-06-14 08:08:30 +00:00
if ( this [ i ] === object )
2013-05-14 09:18:05 +00:00
break ;
}
return i ;
2013-06-14 08:08:30 +00:00
}
2013-05-14 09:18:05 +00:00
2013-03-25 10:44:06 +00:00
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 ) ;
2012-07-04 09:55:30 +00:00
var orbitDesktop = function ( dom ) {
2012-11-15 03:18:55 +00:00
orbitDesktopAPI . apply ( this ) ;
// o = this;
this . contentHolder = dom ;
this . themesettings = "" ;
2013-07-25 09:18:24 +00:00
this . theme = null ;
2013-04-10 03:16:06 +00:00
this . transitionTime = 1000 ;
2013-04-16 07:48:14 +00:00
this . currenthtml = "home" ;
2012-11-15 03:18:55 +00:00
this . currentface = "home" ;
this . desktopData = { } ;
this . tp = "" ;
this . sectionList ;
this . data _method ;
2013-02-23 09:12:02 +00:00
this . gridvar = null ;
2013-03-12 03:18:32 +00:00
this . lastlink = null ;
this . tinyscrollbar = null ;
2013-03-25 10:44:06 +00:00
this . locationdata = { } ;
2012-11-15 03:18:55 +00:00
this . initialize = function ( ) {
var theme = o . theme ;
var custom = false ;
2013-03-25 10:44:06 +00:00
o . getlocation ( ) ;
2013-07-25 09:18:24 +00:00
o . minimizeBarManager ( ) ;
2012-11-15 03:18:55 +00:00
$ . getJSON ( "/desktop/get_desktop_settings" , { "get" : "desktop" , "desktopid" : o . desktopId } , function ( desktopSettings ) {
if ( desktopSettings ) {
2013-07-25 09:18:24 +00:00
if ( desktopSettings . theme == "custom" ) {
2012-11-15 03:18:55 +00:00
custom = true ;
}
2013-07-25 09:18:24 +00:00
theme = desktopSettings . theme ;
2012-11-15 03:18:55 +00:00
o . theme = theme ;
loadTheme ( desktopSettings . customtheme , desktopSettings . wallpaper ) ;
} else { loadTheme ( ) ; }
2013-04-10 03:16:06 +00:00
} ) ;
2012-11-15 03:18:55 +00:00
var loadTheme = function ( customtheme , customwallpaper ) { //This function will load the theme from database
2013-07-25 09:18:24 +00:00
$ . getJSON ( "/desktop_themes/settings" , { "id" : theme } , function ( ts ) {
o . themesettings = ts ;
$ ( 'head' ) . append ( $ ( '<link rel="stylesheet" id="dyn_css" type="text/css" />' ) . attr ( 'href' , o . themesettings . css ) ) ;
2012-11-15 03:18:55 +00:00
if ( custom ) {
$ ( "head" ) . find ( "#dyn_css" ) . remove ( ) ;
$ ( "head" ) . append ( customtheme ) ;
}
$ ( document ) . ready ( function ( ) {
o . loadWallpaper ( customwallpaper ) ;
o . bindDesktopEvents ( ) ;
o . loadIconCache ( ) ;
2012-11-28 10:11:49 +00:00
var custom _load = window . location . hash ;
if ( ! custom _load ) {
$ ( o . contentHolder ) . empty ( ) . load ( "/desktop/desktop" , function ( ) {
o . desktopData [ "d_desktop" ] = "" ;
o . initializeDesktop ( "d_desktop" , "" , false ) ;
2013-06-14 08:08:30 +00:00
} )
2012-11-28 10:11:49 +00:00
} else {
o . customPage ( custom _load ) ;
}
2012-11-15 03:18:55 +00:00
} ) ;
2013-06-14 08:08:30 +00:00
} )
2013-04-10 03:16:06 +00:00
} ;
} ;
2012-11-28 10:11:49 +00:00
this . customPage = function ( customload ) {
customload = customload . replace ( "#" , "" ) ;
2013-06-14 08:08:30 +00:00
if ( customload . search ( "-" ) != - 1 ) {
2012-11-28 10:11:49 +00:00
customload = customload . split ( "-" ) ;
o . menu _item ( $ ( ".docklist a[custom-load=" + customload [ 0 ] + "]" ) , true , customload [ 1 ] ) ;
} else {
o . menu _item ( $ ( ".docklist a[custom-load=" + customload + "]" ) , true ) ;
}
2013-04-10 03:16:06 +00:00
} ;
2012-11-15 03:18:55 +00:00
this . changeTheme = function ( theme ) { // this function is used for changing theme
o . theme = theme ;
2013-07-25 09:18:24 +00:00
$ . getJSON ( "/desktop_themes/settings" , { "id" : theme } , function ( ts ) {
o . themesettings = ts ;
2012-11-15 03:18:55 +00:00
$ ( 'head' ) . find ( "#dyn_css" ) . remove ( ) ;
2013-07-25 09:18:24 +00:00
$ ( 'head' ) . append ( $ ( '<link rel="stylesheet" id="dyn_css" type="text/css" />' ) . attr ( 'href' , o . themesettings . css ) ) ;
2012-11-15 03:18:55 +00:00
o . loadWallpaper ( ) ;
o . loadIconCache ( ) ;
2013-06-14 08:08:30 +00:00
} )
2012-11-15 03:18:55 +00:00
} ;
2013-03-25 10:44:06 +00:00
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 ;
2013-04-10 03:16:06 +00:00
} ) ;
2013-03-25 10:44:06 +00:00
o . locationdata . formatted _address = data . results [ 0 ] . formatted _address ;
2013-04-10 03:16:06 +00:00
} ) ;
2013-06-14 08:08:30 +00:00
}
2013-03-25 10:44:06 +00:00
var locationError = function ( ) {
o . notify ( "Unable to find your location!" , "alert" ) ;
2013-06-14 08:08:30 +00:00
}
2013-03-25 10:44:06 +00:00
if ( navigator . geolocation ) {
navigator . geolocation . getCurrentPosition ( locationSuccess , locationError ) ;
}
else {
o . notify ( "Your browser does not support Geolocation!" , "alert" ) ;
}
2013-06-14 08:08:30 +00:00
}
2013-03-25 10:44:06 +00:00
2012-11-15 03:18:55 +00:00
this . bindDesktopEvents = function ( ) { //this function will bind the global handlers to thd desktop, for example doc
$ ( ".docklist a" ) . click ( function ( ) {
2012-11-28 10:11:49 +00:00
o . menu _item ( $ ( this ) ) ;
2012-11-15 03:18:55 +00:00
return false ;
2013-04-10 03:16:06 +00:00
} ) ;
2012-11-20 09:20:05 +00:00
2012-11-15 03:18:55 +00:00
$ ( 'body' ) . on ( {
click : function ( ) {
2012-11-29 08:46:33 +00:00
if ( ! $ ( this ) . hasClass ( 'active' ) ) {
o . sub _menu _item ( $ ( this ) ) ;
}
2012-11-15 03:18:55 +00:00
return false ;
} ,
mouseenter : function ( ) {
if ( ! $ ( this ) . hasClass ( 'active' ) ) {
$ ( this ) . switchClass ( 'admtxt' , 'thmc1 thmtxt' , 0 ) ;
}
} ,
mouseleave : function ( ) {
var t = $ ( this ) . hasClass ( 'active' ) ? '' : 'thmc1 thmtxt' ;
$ ( this ) . switchClass ( t , 'admtxt' , 0 ) ;
}
2012-11-20 09:20:05 +00:00
} , '*[content-type=menu] a' ) ;
2012-11-21 09:11:18 +00:00
$ ( "body" ) . on ( "submit" , "form[form-type=ajax_form]" , function ( ) {
2012-11-20 09:20:05 +00:00
var callback _method = $ ( this ) . attr ( "callback-method" ) ;
2012-11-22 08:31:37 +00:00
var dt = null ;
dt = $ ( this ) . attr ( "response-type" ) ;
if ( dt == null ) {
dt = "json" ;
}
2012-11-20 09:20:05 +00:00
var options = {
2012-11-22 08:31:37 +00:00
dataType : dt ,
2012-11-20 09:20:05 +00:00
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 ) ;
}
}
2012-11-22 08:31:37 +00:00
} ,
error : function ( ) {
o . notify ( "Please try again later!" , "imp" ) ;
2012-11-20 09:20:05 +00:00
}
2013-06-14 08:08:30 +00:00
}
2012-11-20 09:20:05 +00:00
$ ( this ) . ajaxSubmit ( options ) ;
return false ;
2013-04-10 03:16:06 +00:00
} ) ;
2012-11-20 09:20:05 +00:00
2012-12-27 10:25:54 +00:00
$ ( "body" ) . on ( "click" , "*[ajax-remote]" , function ( ) {
var $e = $ ( this ) ;
2013-03-01 06:45:20 +00:00
var t = $e . attr ( "ajax-remote" ) ;
var classes _to _toggle = $e . attr ( "toggle-onclick" ) ;
2013-03-06 03:32:53 +00:00
var exe = $e . attr ( "callback-method" ) ; // (typeof $e.attr("callback-method") == "function"? $e.attr("callback-method") : "");
2013-03-01 06:45:20 +00:00
if ( classes _to _toggle ) {
2013-04-10 03:16:06 +00:00
$e . toggleClass ( classes _to _toggle ) ;
}
2013-03-01 06:45:20 +00:00
if ( t == "false" ) {
2013-03-06 03:32:53 +00:00
if ( exe ) {
window . o [ o . data _method ] [ exe ] ( null , $e ) ;
}
2013-03-01 06:45:20 +00:00
return false ;
}
2012-12-27 10:25:54 +00:00
var ca = $e . attr ( "content-holder" ) ;
var a = function ( ) {
2013-03-01 06:45:20 +00:00
2012-12-27 10:25:54 +00:00
$ . ajax ( {
2013-03-01 06:45:20 +00:00
type : t ,
2012-12-27 10:25:54 +00:00
url : $e . attr ( "href" ) ,
success : function ( data ) {
2013-03-06 11:04:33 +00:00
if ( typeof data == "string" ) {
2013-06-14 08:08:30 +00:00
if ( ca )
2013-03-06 11:04:33 +00:00
$ ( ca ) . html ( data ) ;
2013-06-14 08:08:30 +00:00
else {
2013-03-06 11:04:33 +00:00
o . layout _data ( data ) ;
// $("div[container=true]").html(data);
}
}
2013-06-14 08:08:30 +00:00
if ( exe )
2013-03-06 11:04:33 +00:00
window . o [ o . data _method ] [ exe ] ( data , $e ) ;
if ( t == "delete" ) {
if ( $e . attr ( "delete-item" ) == "true" ) {
var li _to _delete = $e . parentsUntil ( "li[item=true]" ) . find ( "li[item=true]" ) ;
li _to _delete . slideUp ( ) ;
}
2013-02-27 10:55:26 +00:00
}
2012-12-27 10:25:54 +00:00
}
} ) ;
2013-06-14 08:08:30 +00:00
}
2012-12-27 10:25:54 +00:00
if ( $e . attr ( "confirm-message" ) ) {
o . confirm ( {
buttons : [ "Yes" , "No" ] ,
highlighted : 2 ,
message : $e . attr ( "confirm-message" )
} , function ( value ) {
if ( value ) {
a ( ) ;
}
2013-06-14 08:08:30 +00:00
} )
2012-12-27 10:25:54 +00:00
} else {
a ( ) ;
}
return false ;
2013-04-10 03:16:06 +00:00
} ) ;
2012-12-27 10:25:54 +00:00
2012-11-15 03:18:55 +00:00
$ ( window ) . resize ( function ( ) {
2013-06-14 08:08:30 +00:00
// var ww = $(window).width();
// $("img#thmbackground").attr({"width":ww});
// if( $('.tinycanvas').length > 0 ){
$ ( '.tinycanvas' ) . tinyscrollbar _update ( 'relative' ) ;
// }
2012-11-15 03:18:55 +00:00
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 } ) ;
2013-04-10 03:16:06 +00:00
} ) ;
2012-11-15 03:18:55 +00:00
}
} ) ;
2012-11-27 07:55:32 +00:00
2012-11-15 03:18:55 +00:00
var $widget _fn = $ ( '.widget_fn' ) , $fn _des = $ ( '.fn_des' ) ;
$widget _fn . hover ( function ( ) {
var fn _name = $ ( this ) . find ( 'img' ) . attr ( 'alt' ) , nth = $ ( this ) . parents ( '.d_cate' ) . index ( ) , des _left = $ ( '.dock_child' ) . eq ( nth ) . width ( ) ;
$ ( this ) . addClass ( 'thmc1' ) ;
$fn _des . text ( fn _name ) . css ( { 'top' : nth * 60 , 'left' : des _left + 60 } ) . stop ( true , true ) . fadeIn ( ) ;
} , function ( ) {
$ ( this ) . removeClass ( 'thmc1' ) ;
$fn _des . stop ( true , true ) . fadeOut ( ) ;
} ) ;
2012-11-27 07:55:32 +00:00
var split = function ( val ) {
return val . split ( /,\s*/ ) ;
2013-06-14 08:08:30 +00:00
}
2012-11-27 07:55:32 +00:00
var extractLast = function ( term ) {
return split ( term ) . pop ( ) ;
2013-06-14 08:08:30 +00:00
}
2012-11-27 07:55:32 +00:00
2013-04-22 04:24:09 +00:00
// $("body").on("keydown","*[autocomplete]", function( event ) {
// var autocompleteList = $(this).attr("autocomplete-list");
// console.log($(this));
// });
//
2012-11-15 03:18:55 +00:00
} ;
2013-03-12 03:18:32 +00:00
2013-02-27 10:55:26 +00:00
this . layout _data = function ( h ) {
2013-04-16 07:48:14 +00:00
var $e ;
var column _container , layout , base _width , no _of _entries = 0 , pagination _link , pagination _variable , gutter , total _width ;
2013-03-12 03:18:32 +00:00
o . paging = true ;
2013-03-25 08:23:07 +00:00
gutter = ( ! isNaN ( gutter ) ) ? gutter : 12 ;
2013-03-12 03:18:32 +00:00
this . layout _data . generate _layout _html = function ( l ) {
$e = $ ( "<div></div>" ) ;
$e . html ( l ) ;
2013-04-24 05:46:36 +00:00
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" ) ;
2013-03-12 03:18:32 +00:00
var temp _div = $ ( "<div></div>" ) ;
2013-03-25 10:44:06 +00:00
var entries = [ ] ;
2013-03-12 03:18:32 +00:00
switch ( layout ) {
2013-05-20 09:54:39 +00:00
case "simple" :
2013-03-12 03:18:32 +00:00
total _columns ++ ;
temp _div . append ( column _container . html ( ) ) ;
2013-04-16 07:48:14 +00:00
total _width = "auto" ;
2013-03-12 03:18:32 +00:00
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 ;
2013-03-25 10:44:06 +00:00
entries = column _container . find ( "li[item=true]" ) , x = 0 ;
2013-03-14 09:48:45 +00:00
if ( entries . length != 0 ) {
entries . each ( function ( i , li ) {
if ( x == 0 ) {
2013-03-25 08:23:07 +00:00
column = $ ( "<div class='column type_datalist' style='width:" + base _width + "px;margin-right:" + gutter + "px;padding-right:" + gutter + "px;'><ul></ul></div" ) ;
2013-03-14 09:48:45 +00:00
total _columns ++ ;
}
2013-03-25 08:23:07 +00:00
$ ( li ) . wrapInner ( '<div class="inner"/>' ) . addClass ( "datalist_item" ) . height ( height _percentage + "%" ) ;
2013-03-14 09:48:45 +00:00
column . find ( "ul" ) . eq ( 0 ) . append ( li ) ;
x ++ ;
if ( x == no _of _entries ) {
x = 0 ;
2013-03-29 09:50:21 +00:00
temp _div . append ( column ) ;
}
2013-06-14 08:08:30 +00:00
} )
2013-04-16 07:48:14 +00:00
if ( x != 0 ) {
temp _div . append ( column ) ;
}
2013-03-12 03:18:32 +00:00
}
2013-03-25 08:23:07 +00:00
total _width = ( ! isNaN ( base _width ) ) ? ( base _width + gutter * 2 + 1 ) * total _columns : null ;
2013-03-12 03:18:32 +00:00
break ;
case "column" :
2013-03-25 10:44:06 +00:00
entries = column _container . find ( "div[column=true]" ) , x = 0 , column ;
2013-03-14 09:48:45 +00:00
if ( entries . length != 0 ) {
entries . each ( function ( i , ul ) {
2013-04-16 07:48:14 +00:00
column = $ ( "<div class='column type_column' style='width:" + base _width + "px;margin-right:" + gutter + "px;padding-right:" + gutter + "px;'></div" ) ;
2013-03-12 03:18:32 +00:00
total _columns ++ ;
column . append ( ul ) ;
x ++ ;
temp _div . append ( column ) ;
2013-06-14 08:08:30 +00:00
} )
2013-04-16 07:48:14 +00:00
total _width = ( ! isNaN ( base _width ) ) ? ( base _width + gutter * 2 + 1 ) * total _columns : null ;
2013-03-14 09:48:45 +00:00
}
2013-03-12 03:18:32 +00:00
break ;
2013-03-25 10:44:06 +00:00
default :
break ;
2013-03-12 03:18:32 +00:00
}
2013-03-25 08:23:07 +00:00
// total_width = (!isNaN(base_width) ? ( base_width + 12 ) * total_columns : null);
2013-04-24 05:46:36 +00:00
return {
2013-06-14 08:08:30 +00:00
"markup" : temp _div . html ( ) ,
2013-04-24 05:46:36 +00:00
"width" : total _width ,
"total" : entries . length
} ;
2013-06-14 08:08:30 +00:00
}
2013-04-17 09:53:35 +00:00
var check _container = $ ( "<div></div>" ) . html ( h ) . find ( "div[container=true]" ) ;
if ( check _container . length > 0 ) {
2013-04-24 05:46:36 +00:00
$ ( "div[container=true]" )
. html ( check _container . html ( ) )
. find ( "div.overview" )
. wrap ( '<div class="tinycanvas"><div class="viewport"></div></div>' ) ;
2013-04-17 09:53:35 +00:00
} else {
2013-04-24 05:46:36 +00:00
$ ( "div[container=true]" )
. html ( h )
. find ( "div.overview" )
. wrap ( '<div class="tinycanvas"><div class="viewport"></div></div>' ) ;
2013-04-17 09:53:35 +00:00
}
2013-04-24 05:46:36 +00:00
$ ( "div[container=true]" )
. find ( "div.tinycanvas" )
2013-05-20 09:54:39 +00:00
. prepend ( '<div class="scrollbar sb_h"><div class="track"><div class="thumb thmc2"><div class="end"></div></div></div></div>' ) ;
2013-06-14 08:08:30 +00:00
var f = o . layout _data . generate _layout _html ( h )
2013-03-12 03:18:32 +00:00
$ ( "div[container=true] div.overview" ) . html ( f . markup ) ;
var settings = { main : ".tinycanvas" } ;
var tsettings = { } ;
if ( f . width ) {
settings . fill = f . width ;
}
if ( pagination _variable ) {
var page _no = 1 ;
tsettings . onMove = function ( x ) {
if ( x < 50 ) {
if ( ! pagination _link )
pagination _link = o . lastlink ;
if ( o . paging ) {
page _no ++ ;
o . paging = false ;
o . pagination ( pagination _link , pagination _variable , page _no ) ;
}
}
2013-06-14 08:08:30 +00:00
}
2013-03-07 11:15:30 +00:00
}
2013-04-22 09:59:33 +00:00
// call other functions here
2013-03-12 03:18:32 +00:00
o . tinyscrollbar _ext ( settings , tsettings ) ;
2013-04-22 09:59:33 +00:00
o . simple _drop _down ( ) ;
2013-04-22 04:24:09 +00:00
o . autocomplete ( ) ;
o . use _select2 ( ) ;
2013-05-20 09:54:39 +00:00
o . check _simple _layout ( ) ;
2013-06-14 08:08:30 +00:00
}
2013-03-12 03:18:32 +00:00
this . paging = true ;
this . pagination = function ( link , variable , page _no ) {
var retvalue = null ;
$ . ajax ( {
url : link + "?" + variable + "=" + page _no ,
type : "get" ,
success : function ( html ) {
var f = o . layout _data . generate _layout _html ( html ) ;
// console.log(f.total)
if ( f . total > 0 ) {
2013-04-10 03:16:06 +00:00
$ ( "div[container=true] .overview" ) . append ( f . markup ) ;
2013-03-12 03:18:32 +00:00
if ( f . width ) {
2013-04-10 03:16:06 +00:00
var w = $ ( "div[container=true] .overview" ) . width ( ) ;
$ ( "div[container=true] .overview" ) . width ( w + f . width ) ;
2013-03-12 03:18:32 +00:00
}
o . tinyscrollbar . tinyscrollbar _update ( "relative" ) ;
o . paging = true ;
2013-04-10 03:16:06 +00:00
} else {
o . paging = false ;
}
2013-03-12 03:18:32 +00:00
}
2013-04-10 03:16:06 +00:00
} ) ;
2013-06-14 08:08:30 +00:00
}
2013-03-12 03:18:32 +00:00
2013-03-07 11:15:30 +00:00
this . insert _new _column = function ( index ) {
2013-04-10 03:16:06 +00:00
var column _container = $ ( "div[container=true] .overview" ) , layout = column _container . attr ( "content-layout" ) , base _width = parseInt ( column _container . attr ( "base-width" ) ) , column ;
2013-03-07 11:15:30 +00:00
var i = ( index == 0 ? 0 : index - 1 ) ;
var previous _column = column _container . find ( ".column" ) . eq ( i ) ;
if ( previous _column . length == 0 ) return false ;
switch ( layout ) {
case "datalist" :
column = $ ( "<div class='column type_column' style='width:" + base _width + "px'></div" ) ;
2013-06-14 08:08:30 +00:00
break ;
2013-03-07 11:15:30 +00:00
case "column" :
column = $ ( "<div class='column type_column' style='width:" + base _width + "px'></div" ) ;
2013-06-14 08:08:30 +00:00
break ;
2013-03-07 11:15:30 +00:00
default :
return false ;
2013-06-14 08:08:30 +00:00
break ;
2013-03-07 11:15:30 +00:00
}
if ( index == 0 ) {
2013-06-14 08:08:30 +00:00
column . insertBefore ( previous _column )
2013-03-07 11:15:30 +00:00
} else {
column . insertAfter ( previous _column ) ;
}
var total _columns = column _container . find ( ".column" ) . length ;
o . tinyscrollbar _ext ( {
main : ".tinycanvas" ,
fill : base _width * total _columns
2013-06-14 08:08:30 +00:00
} )
2013-03-07 11:15:30 +00:00
return column ;
2013-06-14 08:08:30 +00:00
}
2013-03-07 11:15:30 +00:00
this . remove _column = function ( index ) {
2013-04-10 03:16:06 +00:00
var column _container = $ ( "div[container=true] .overview" ) , layout = column _container . attr ( "content-layout" ) , column = column _container . find ( ".column" ) . eq ( index ) , base _width = parseInt ( column _container . attr ( "base-width" ) ) ;
2013-06-14 08:08:30 +00:00
if ( column . length == 0 ) return false ;
2013-03-07 11:15:30 +00:00
switch ( layout ) {
case "datalist" :
case "column" :
2013-06-14 08:08:30 +00:00
break ;
2013-03-07 11:15:30 +00:00
default :
return false ;
2013-06-14 08:08:30 +00:00
break ;
2013-03-07 11:15:30 +00:00
}
column . remove ( ) ;
var total _columns = column _container . find ( ".column" ) . length ;
o . tinyscrollbar _ext ( {
main : ".tinycanvas" ,
fill : base _width * total _columns
2013-06-14 08:08:30 +00:00
} )
2013-03-07 11:15:30 +00:00
return column ;
2013-06-14 08:08:30 +00:00
}
2013-03-07 11:15:30 +00:00
2012-11-28 10:11:49 +00:00
this . menu _item = function ( dom , customload , submenuitem ) {
if ( ! customload ) customload = false ;
var target = dom . attr ( "id" ) ;
var url = dom . attr ( "href" ) ;
2013-03-25 10:44:06 +00:00
if ( ! url ) return false ;
2013-07-25 09:18:24 +00:00
2012-11-28 10:11:49 +00:00
o . data _method = dom . attr ( "callback-method" ) ;
if ( o . currenthtml != target ) {
2013-04-10 03:16:06 +00:00
if ( o . desktopData [ o . currentface ] == "undefined" ) {
2012-11-28 10:11:49 +00:00
o . desktopData [ o . currentface ] = "" ;
2013-04-10 03:16:06 +00:00
}
2012-11-28 10:11:49 +00:00
o . desktopData [ o . currentface ] = $ ( o . contentHolder ) . html ( ) ;
if ( customload ) {
$ ( o . contentHolder ) . html ( "<div id='content'></div>" ) ;
}
2013-04-10 03:16:06 +00:00
$ ( "#content > #holder" ) . toggle ( "drop" , { easing : "easeInOutQuint" } , o . transitionTime , function ( ) {
2012-11-28 10:11:49 +00:00
o . currenthtml = target ;
o . currentface = target ;
var cache = false ;
if ( ! o . desktopData [ o . currentface ] ) {
2013-03-06 11:04:33 +00:00
$ ( o . contentHolder ) . empty ( ) . load ( url , function ( data ) {
2012-11-28 10:11:49 +00:00
if ( typeof o . data _method != "undefined" ) {
2013-04-10 03:16:06 +00:00
if ( o . data _method != "" ) {
2012-11-28 10:11:49 +00:00
window . o [ o . data _method ] ( target , url , cache ) ;
2013-04-10 03:16:06 +00:00
}
2012-11-28 10:11:49 +00:00
}
2013-04-10 03:16:06 +00:00
try {
if ( ! customload ) {
2013-03-06 11:04:33 +00:00
o . sub _menu _item ( $ ( o . contentHolder ) . find ( "*[content-type=menu] a[load=true]" ) , data ) ;
2013-04-10 03:16:06 +00:00
} else {
if ( submenuitem ) {
o . sub _menu _item ( $ ( o . contentHolder ) . find ( "*[content-type=menu] a[custom-load=" + submenuitem + "]" ) ) ;
} else {
o . sub _menu _item ( $ ( o . contentHolder ) . find ( "*[content-type=menu] a[load=true]" ) , data ) ;
2012-12-06 09:43:19 +00:00
}
2013-04-10 03:16:06 +00:00
}
} catch ( EX ) { }
header _ani ( ) ;
} ) ;
2012-12-06 09:43:19 +00:00
} else {
$ ( o . contentHolder ) . html ( o . desktopData [ o . currentface ] ) ;
2013-04-10 09:27:34 +00:00
try {
if ( ! customload ) {
2013-04-16 08:17:37 +00:00
o . sub _menu _item ( $ ( o . contentHolder ) . find ( "*[content-type=menu] a[load=true]" ) , o . desktopData [ o . currentface ] ) ;
2013-04-10 09:27:34 +00:00
} else {
if ( submenuitem )
2013-04-16 08:17:37 +00:00
o . sub _menu _item ( $ ( o . contentHolder ) . find ( "*[content-type=menu] a[custom-load=" + submenuitem + "]" ) , o . desktopData [ o . currentface ] ) ;
2013-04-10 09:27:34 +00:00
else
2013-04-16 08:17:37 +00:00
o . sub _menu _item ( $ ( o . contentHolder ) . find ( "*[content-type=menu] a[load=true]" ) , o . desktopData [ o . currentface ] ) ;
2013-04-10 09:27:34 +00:00
}
} catch ( EX ) { }
2013-07-25 09:18:24 +00:00
cache = ( o . lastlink == "/desktop/app_manager" ? false : true ) ;
2012-11-28 10:11:49 +00:00
if ( typeof o . data _method != "undefined" ) {
2013-04-10 03:16:06 +00:00
if ( o . data _method != "" ) {
window . o [ o . data _method ] ( target , url , cache ) ;
}
2012-11-28 10:11:49 +00:00
}
2013-04-24 05:46:36 +00:00
header _ani ( ) ;
2012-11-28 10:11:49 +00:00
}
} ) ;
2013-04-10 03:16:06 +00:00
$ ( '#header' )
. delay ( 600 )
. effect ( 'drop' , {
easing : 'easeInOutQuint' ,
direction : 'down'
} , 300 ) ;
}
var header _ani = function ( ) {
$ ( '#header' ) . hide ( ) . toggle ( 'drop' , { easing : 'easeInOutQuint' , direction : 'down' } ) ;
$ ( '#header > *' ) . each ( function ( i ) {
$ ( this ) . hide ( ) . delay ( i * 100 ) . fadeIn ( 600 , 'easeInOutQuint' ) ;
} ) ;
2012-11-28 10:11:49 +00:00
}
2013-07-25 09:18:24 +00:00
o . lastlink = url ;
2012-11-28 10:11:49 +00:00
}
2013-03-06 11:04:33 +00:00
this . sub _menu _item = function ( dom , data ) {
2013-04-10 09:27:34 +00:00
var sub _data _method = dom . attr ( 'callback-method' ) ;
if ( sub _data _method ) {
o . lastlink = dom . attr ( "href" ) ;
$ . ajax ( {
url : dom . attr ( "href" ) ,
type : "get" ,
success : function ( data ) {
o . layout _data ( data ) ;
if ( typeof o . data _method != "undefined" ) {
if ( o . data _method != "" ) {
if ( typeof sub _data _method != "undefined" ) {
if ( sub _data _method != "" ) {
window . o [ o . data _method ] [ sub _data _method ] ( ) ;
2012-11-20 09:20:05 +00:00
}
}
2013-04-10 09:27:34 +00:00
}
2012-11-20 09:20:05 +00:00
}
2013-04-10 09:27:34 +00:00
}
} )
o . highlight _sub _menu _item ( dom ) ;
}
if ( dom . length == 0 )
o . layout _data ( data ) ;
2013-06-14 08:08:30 +00:00
// $('*[content-type=menu] a').removeClass('thmc1 thmtxt active');
// dom.addClass('thmc1 thmtxt active');
2013-03-04 09:44:55 +00:00
}
2012-11-15 03:18:55 +00:00
this . initializeDesktop = function ( target , url , cache ) { //this is for initializing main desktops that are sections and tiles
2013-04-10 03:16:06 +00:00
target = ( ! target ) ? 'desktop' : target ;
2012-11-15 03:18:55 +00:00
var bindHandlers = function ( ) { // this function will bind all the handlers in the desktop
2013-02-26 03:47:05 +00:00
var dragged = null , draggable , lastpos = [ ] ;
2013-06-14 08:08:30 +00:00
/* Hotfix - Part 1 */
// var items = $(".gridster ul li");
// items.detach();
2013-05-20 09:54:39 +00:00
2013-04-10 03:16:06 +00:00
o . gridvar = $ ( ".grid ul" ) . find ( "> li " )
. mousedown ( function ( e ) {
2013-02-26 03:47:05 +00:00
! draggable ;
dragged = $ ( this ) ;
lastpos = [ ] ;
$ ( ".grid ul li" ) . each ( function ( ) {
2013-04-10 03:16:06 +00:00
lastpos . push ( { "col" : $ ( this ) . attr ( "data-col" ) , "row" : $ ( this ) . attr ( "data-row" ) } ) ;
} ) ;
} )
. end ( )
. gridster ( {
2013-05-20 09:54:39 +00:00
max _rows : 4 ,
shift _larger _widgets _down : false ,
2013-04-10 03:16:06 +00:00
widget _margins : [ 6 , 6 ] ,
widget _base _dimensions : [ 120 , 120 ] ,
2013-05-06 06:54:42 +00:00
serialize _params : function ( $w , wgd ) { return { col : wgd . col , row : wgd . row , id : $w . data ( "id" ) } } ,
2013-04-10 03:16:06 +00:00
draggable : {
start : function ( event , ui ) {
dragged . addClass ( "noClick" ) ;
} ,
stop : function ( event , ui ) {
2013-06-14 08:08:30 +00:00
// for (var i = 1; i <= 30; i++) {
// // var celement = $(".grid ul .widget[data-col="+i+"]:last");
// $(".grid ul .widget[data-col="+i+"]").each(function(){
// var pos = $(this).position();
// if(pos && (pos.top + $(this).height() + 6) > 550){
// revertbacktiles();
// }
// });
// }
2013-05-21 06:44:14 +00:00
$ ( '.tinycanvas' ) . tinyscrollbar _update ( 'relative' ) ;
2013-05-20 09:54:39 +00:00
var newpos = o . gridvar . serialize ( ) ;
$ . post ( "/desktop/newpositions" , { "newpositions" : newpos } ) ;
2013-02-26 03:47:05 +00:00
}
2013-04-10 03:16:06 +00:00
}
} )
. data ( 'gridster' ) ;
2013-05-20 09:54:39 +00:00
2013-06-14 08:08:30 +00:00
/* Hotfix - Part 2 */
// $.each(items , function (i, e) {
// var item = $(this);
// var columns = parseInt(item.attr("data-sizex"));
// var rows = parseInt(item.attr("data-sizey"));
// var col = parseInt(item.attr("data-col"));
// var row = parseInt(item.attr("data-row"));
// o.gridvar.add_widget(item, columns, rows, col, row);
// });
2013-02-26 03:47:05 +00:00
var revertbacktiles = function ( ) {
lastpos . push ( { "col" : "" , "row" : "" } ) ;
$ ( ".grid ul li" ) . each ( function ( i ) {
$ ( this ) . attr ( { "data-col" : lastpos [ i ] . col , "data-row" : lastpos [ i ] . row } ) ;
2013-04-10 03:16:06 +00:00
} ) ;
2013-02-27 03:47:41 +00:00
}
var remove _empty _columns = function ( ) {
for ( var i = 1 ; i <= 30 ; i ++ ) {
2013-06-14 08:08:30 +00:00
// var celement = $(".grid ul .widget[data-col="+i+"]:last");
2013-02-27 03:47:41 +00:00
$ ( ".grid ul .widget[data-col=" + i + "]" ) . each ( function ( ) {
2013-04-10 03:16:06 +00:00
} ) ;
2013-02-27 03:47:41 +00:00
break ;
}
2013-02-26 03:47:05 +00:00
}
2013-04-10 03:16:06 +00:00
$ ( ".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" ) ;
2013-03-25 10:44:06 +00:00
2013-04-10 03:16:06 +00:00
} ) ;
2013-06-14 08:08:30 +00:00
o . appname _substr ( '.gridster li' ) ;
2013-04-10 03:16:06 +00:00
o . simple _drop _down ( ) ;
o . tinyscrollbar _ext ( {
main : '.tinycanvas'
} ) ;
2013-03-25 10:44:06 +00:00
}
var loadTiles = function ( id ) { //This will load tiles for a specific desktop .. id of section has to be passed here to load tiles
2013-04-10 03:16:06 +00:00
$ ( "#desktop #group_wrapper" ) . empty ( ) ;
2013-03-25 10:44:06 +00:00
$ . getJSON ( "/desktop/getgroups" , { sectionid : id } , function ( tiles ) {
2013-04-16 07:48:14 +00:00
// tiles.sort(o.sortJSON("position",true,parseInt));
2013-07-25 09:18:24 +00:00
var tilecolors = ( o . themesettings . tilecolor ? o . themesettings . tilecolor : [ "thmc1" , "thmc2" , "thmc3" , "thmc4" ] ) ;
2013-03-25 10:44:06 +00:00
var totaltiles _in _a _row = 4 ;
var opacity = [ "op07" , "op08" , "op09" , "" ] ;
2013-04-16 07:48:14 +00:00
var row = 0 , col = 1 , x = 1 , y = 1 , total _x = 0 , prev _y = 0 ;
2013-03-25 10:44:06 +00:00
var $group = $ ( '<div class="grid gridster"></div>' ) ;
2013-04-10 03:16:06 +00:00
var $ul = $ ( '<ul></ul>' ) ;
2013-03-25 10:44:06 +00:00
$ . each ( tiles , function ( i , tile ) {
2013-04-10 03:16:06 +00:00
var shape = tile . shape . split ( " " ) ;
2013-06-14 08:08:30 +00:00
// if(tile.title == "Weather")console.log("Big - row : " + tile.row + ", col : "+ tile.column);
// if(tile.title == "Google Scholar")console.log("Scholar - row : " + tile.row + ", col : "+ tile.column);
2013-04-16 07:48:14 +00:00
2013-06-14 08:08:30 +00:00
// if(total_x % 2 != 0)
// row = row - y;
// if(i == 7)tile.row = null;
2013-04-16 07:48:14 +00:00
if ( tile . row ) {
row = tile . row ;
col = tile . column ;
x = parseInt ( shape [ 0 ] . substr ( 1 , 1 ) ) ;
y = parseInt ( shape [ 1 ] . substr ( 1 , 1 ) ) ;
} else {
x = parseInt ( shape [ 0 ] . substr ( 1 , 1 ) ) ;
if ( total _x % 2 == 0 ) {
row = row + y ;
} else if ( x == 1 ) {
col ++ ;
}
y = parseInt ( shape [ 1 ] . substr ( 1 , 1 ) ) ;
total _x = total _x + ( x * y ) ;
prev _y = y ;
if ( total _x > 8 ) {
row = 1 ;
total _x = 0 ;
col ++ ;
}
}
2013-03-25 10:44:06 +00:00
var tilecolor = tilecolors [ Math . floor ( Math . random ( ) * tilecolors . length ) ] ;
var op = opacity [ Math . floor ( Math . random ( ) * opacity . length ) ] ;
var f = ( tile . fullsize ? "fullsize" : null ) ;
2013-04-10 03:16:06 +00:00
if ( tile . data _category == "app" ) {
2013-06-14 08:08:30 +00:00
$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="' + tile . icon + '" alt="" ></a><h1 class="appname thmtxt">' + tile . title + '</h1></li>' ) ;
2013-04-10 03:16:06 +00:00
} else {
2013-06-14 08:08:30 +00:00
$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><h1 class="appname thmtxt">' + tile . title + '</h1></li>' ) ;
2013-04-10 03:16:06 +00:00
}
2013-04-08 10:07:46 +00:00
2013-04-16 07:48:14 +00:00
2013-03-25 10:44:06 +00:00
$ul . append ( $li ) ;
2013-04-10 03:16:06 +00:00
} ) ;
2013-03-25 10:44:06 +00:00
$group . append ( $ul ) ;
2013-04-10 03:16:06 +00:00
$ ( "#desktop #group_wrapper" ) . append ( $group ) ;
2013-03-25 10:44:06 +00:00
2013-04-10 03:16:06 +00:00
bindHandlers ( ) ;
o . initializeWidgets ( ) ;
} ) ;
2012-11-15 03:18:55 +00:00
}
var loadSectionList = function ( ) { //This will load the section list from the db
$ . getJSON ( "/desktop/getsectionlist" , { desktopid : o . desktopId } , function ( sectionlist ) {
2013-07-25 09:18:24 +00:00
o . sectionList = s ectionlist ;
2012-11-15 03:18:55 +00:00
$ . each ( sectionlist , function ( i , section ) {
var tempstyle = "" ;
if ( i == 0 ) {
tempstyle = "style='display:none;'" ;
$ ( "#desktop #section_heading" ) . text ( section . name ) ;
}
2013-04-10 03:16:06 +00:00
$ ( "#desktop #section_list" ) . append ( $ ( '<li class="section_name" ' + tempstyle + '><a class="admtxt hp hh1" onclick="return false;" href="' + section . _id + '" >' + section . name + '</a></li>' ) ) ;
} ) ;
2012-11-15 03:18:55 +00:00
bindSecondaryHandlers ( ) ;
2013-04-10 03:16:06 +00:00
o . simple _drop _down ( ) ;
2012-11-15 03:18:55 +00:00
} )
}
var bindSecondaryHandlers = function ( ) { //This is the secondary bind handler function which is used to bind events which are repeatative
2013-04-10 03:16:06 +00:00
$ ( "#desktop #section_list .section_name" ) . click ( function ( ) {
$ ( "#desktop .section_name" ) . show ( ) ;
2012-11-15 03:18:55 +00:00
$ ( this ) . hide ( ) ;
$ ( "#desktop #section_heading" ) . text ( $ ( this ) . text ( ) ) ;
o . sectionId = $ ( this ) . find ( "a" ) . attr ( "href" ) ;
loadTiles ( o . sectionId ) ;
2013-04-10 03:16:06 +00:00
} ) ;
2012-11-15 03:18:55 +00:00
}
if ( cache ) {
2013-06-14 08:08:30 +00:00
bindHandlers ( ) ;
o . initializeWidgets ( ) ;
2013-04-10 03:16:06 +00:00
$ ( "#desktop #section_list" ) . empty ( ) ;
2012-11-15 03:18:55 +00:00
$ . each ( o . sectionList , function ( i , section ) {
var tempstyle = "" ;
if ( section . _id == o . sectionId ) {
tempstyle = "style='display:none;'" ;
2013-04-10 03:16:06 +00:00
$ ( "#desktop #section_heading" ) . text ( section . name ) ;
2012-11-15 03:18:55 +00:00
}
2013-04-10 09:05:12 +00:00
$ ( "#desktop #section_list" ) . append ( $ ( '<li class="section_name" ' + tempstyle + '><a class="admtxt hp hh1" onclick="return false;" href="' + section . _id + '" >' + section . name + '</a></li>' ) ) ;
2013-04-10 03:16:06 +00:00
} ) ;
2013-06-14 08:08:30 +00:00
bindSecondaryHandlers ( ) ;
o . simple _drop _down ( ) ;
2012-11-15 03:18:55 +00:00
} else {
2013-04-10 03:16:06 +00:00
loadSectionList ( ) ;
2012-11-15 03:18:55 +00:00
loadTiles ( o . sectionId ) ;
}
2013-04-10 03:16:06 +00:00
}
2012-11-15 03:18:55 +00:00
this . tempFunc = function ( th ) {
$ . post ( "desktop/twitter" , function ( ) { } ) ;
} ;
2013-04-24 05:48:17 +00:00
this . initializeAppManager = function ( target , url , cache ) { //this is application search ie is app manager initialization
2013-05-02 08:45:33 +00:00
var searchArray , allApps ;
2012-11-15 03:18:55 +00:00
var bindHandlers = function ( ) { // bind handler for app manager page
2013-04-29 07:13:36 +00:00
// var gn = $('.g_col').length,
// gw = $('.g_col').outerWidth(true);
// $("#app_manager #group_wrapper").css("width",gn*gw);
2012-11-15 03:18:55 +00:00
// $("div#app_manager .group_search").css("width",$(window).width()-200);
2013-04-29 07:13:36 +00:00
//for textbox search
var $elements = $ ( "#app_manager .element" ) ,
2013-05-02 08:45:33 +00:00
$result = $ ( "#app_manager .search_result" ) ,
$appinfo = $ ( "#app_info" ) ,
2013-05-20 09:54:39 +00:00
$applist = $ ( "#app_list" ) ,
$apptitle = $appinfo . find ( ".app_info_name" ) ,
$appicon = $appinfo . find ( ".app_info_icon" ) ,
$appinfolist = $appinfo . find ( ".app_info_list" ) ,
$canvas = $result . parents ( '.overview' ) ,
current _width = $canvas . css ( 'width' ) ;
2013-05-02 08:45:33 +00:00
2013-04-29 07:13:36 +00:00
$ ( "#app_manager #searchbox" )
. focus ( function ( ) {
$ ( this ) . val ( "" ) ;
} )
. keyup ( function ( e ) {
2013-05-20 09:54:39 +00:00
var query = $ ( this ) . val ( ) ;
if ( query ) {
$appinfo . hide ( ) . attr ( 'style' , '' ) ;
$result . empty ( ) . show ( ) ;
$applist . hide ( ) ;
2013-06-14 08:08:30 +00:00
// searchArray = $elements.filter(":containsi("+$(this).val()+")").clone(1,1);
// searchArray = $('#app_list').find('[data-title*="'+query+'"]').clone(1,1);
2013-05-20 09:54:39 +00:00
searchArray = $elements . filter ( function ( ) {
var matcher = new RegExp ( query , "i" ) ;
2013-06-14 08:08:30 +00:00
return matcher . test ( $ ( this ) . attr ( 'data-title' ) ) ;
2013-05-20 09:54:39 +00:00
} ) . clone ( 1 , 1 ) ;
2013-04-29 07:13:36 +00:00
if ( searchArray . length > 0 ) {
2013-06-14 08:08:30 +00:00
// searchArray.each(function(){
// $(this).hide("fold","fast");
// })
// $("#app_manager #seperator").show();
2013-05-20 09:54:39 +00:00
var i = 0 , c = 1 ; // c for numbers of columns
2013-04-29 07:13:36 +00:00
var $column ;
searchArray . each ( function ( ) {
i ++ ;
if ( i == 1 ) {
$column = $ ( '<div class="g_col g_col_w1"></div>' ) ;
}
2013-05-02 08:45:33 +00:00
$column . append ( $ ( this ) ) ;
$ ( this ) . show ( ) ;
2013-04-29 07:13:36 +00:00
if ( i == 4 ) {
$result . append ( $column ) ;
i = 0 ;
2013-05-20 09:54:39 +00:00
c ++ ;
2013-04-29 07:13:36 +00:00
}
2013-05-20 09:54:39 +00:00
} ) ;
2013-04-29 07:13:36 +00:00
if ( i != 0 ) {
$result . append ( $column ) ;
2013-05-20 09:54:39 +00:00
c *= 132 ;
searchArray
. eq ( 0 )
. parents ( '.overview' )
. animate ( {
'width' : c
} , 0 , function ( ) {
$ ( this )
. parents ( '.tinycanvas' )
. tinyscrollbar _update ( ) ;
} ) ;
2013-04-24 06:22:24 +00:00
}
2013-04-29 07:13:36 +00:00
} else {
2013-05-20 09:54:39 +00:00
var $no _result = $ ( '<div class="w2 h1 thmtxt thmc2 vp hp message"><span class="tile"></span>No result for <b></b></div>' ) ;
$no _result
. find ( 'b' )
. text ( '"' + $ ( this ) . val ( ) + '"' )
. end ( )
. show ( )
. appendTo ( $result ) ;
$canvas . animate ( {
'width' : 252
} , 0 , function ( ) {
$ ( this )
. parents ( '.tinycanvas' )
. tinyscrollbar _update ( ) ;
} ) ;
2013-04-24 06:22:24 +00:00
}
2013-05-20 09:54:39 +00:00
} else if ( query == "" ) {
info _close ( ) ;
2013-04-29 07:13:36 +00:00
$result . empty ( ) ;
2013-05-20 09:54:39 +00:00
$applist . show ( ) ;
$canvas . css ( 'width' , current _width ) ;
2012-11-15 03:18:55 +00:00
}
2013-04-29 07:13:36 +00:00
} )
. blur ( function ( ) {
2013-05-20 09:54:39 +00:00
if ( $ ( this ) . val ( ) == "" ) {
$ ( this ) . val ( "Search" ) ;
}
2013-04-29 07:13:36 +00:00
} ) ;
2012-11-15 03:18:55 +00:00
//for Alphabet sorting
2013-04-10 03:16:06 +00:00
$ ( "#app_manager #alphabet_sort_btn" ) . click ( function ( ) {
2012-11-15 03:18:55 +00:00
switch ( $ ( this ) . attr ( "href" ) ) {
case "ascending" :
$ ( this ) . attr ( "href" , "descending" ) . find ( ".thmtxt" ) . text ( "Alphabet [Z-A]" ) ;
2013-05-02 08:45:33 +00:00
allApps = $ ( "div#app_manager .element" ) . sort ( sortAscending ) ;
2012-11-15 03:18:55 +00:00
break ;
case "descending" :
$ ( this ) . attr ( "href" , "ascending" ) . find ( ".thmtxt" ) . text ( "Alphabet [A-Z]" ) ;
2013-05-02 08:45:33 +00:00
allApps = $ ( "#app_manager .element" ) . sort ( sortDescending ) ;
2012-11-15 03:18:55 +00:00
break ;
}
2013-04-10 03:16:06 +00:00
$ ( "#app_manager #app_list" ) . empty ( ) ;
2012-11-15 03:18:55 +00:00
var count = 0 , colindex = 0 ;
$ ( '#app_list' ) . append ( '<div class="g_col g_col_w1 col' + colindex + '"/>' ) ;
$ . each ( allApps , function ( i , app ) {
count ++ ;
if ( count > 4 ) {
count = 1 , colindex += 1 ;
$ ( '#app_list' ) . append ( '<div class="g_col g_col_w1 col' + colindex + '"/>' ) ;
$ ( '.g_col.col' + colindex ) . append ( app ) ;
} else {
$ ( '.g_col.col' + colindex ) . append ( app ) ;
}
2013-04-10 03:16:06 +00:00
} ) ;
2013-05-02 08:45:33 +00:00
elementSetting ( ) ;
2012-11-15 03:18:55 +00:00
return false ;
2013-04-10 03:16:06 +00:00
} ) ;
2013-05-02 08:45:33 +00:00
var elementSetting = function ( ) { // for element setting load
2013-05-20 09:54:39 +00:00
$elements . click ( function ( ) {
var $e = $ ( this ) ;
2013-05-02 08:45:33 +00:00
$apptitle . text ( $e . data ( "title" ) ) ;
$appicon . attr ( "src" , $e . find ( "img" ) . attr ( "src" ) ) ;
2013-05-20 09:54:39 +00:00
$appinfolist . find ( "[info=app_version]" ) . text ( $e . data ( "version" ) ) ;
2013-05-02 08:45:33 +00:00
var dt = new Date ( $e . data ( "update" ) ) ;
2013-05-20 09:54:39 +00:00
$appinfolist . find ( "[info=app_last_update]" ) . text ( dt . toUTCString ( ) ) ;
$appinfolist . find ( "[info=app_author]" ) . text ( $e . data ( "author" ) ) ;
$appinfo
. find ( ".app_info_header" )
. attr ( 'style' , '' )
. css ( {
"background-color" : $e . data ( "background" ) ,
"color" : $e . data ( "text-color" )
} ) ;
2013-05-02 08:45:33 +00:00
var sections = elementSettingsData [ $e . data ( "id" ) ] . sections ;
var sectionids = new Array ( ) ;
$ . each ( sections , function ( i , sec ) {
sectionids . push ( sec . id ) ;
} )
2013-05-20 09:54:39 +00:00
$appinfolist . find ( "[info=app_section_activation]" ) . empty ( ) ;
2013-05-02 08:45:33 +00:00
$ . each ( o . sectionList , function ( i , sec ) {
var present = $ . inArray ( sec . _id , sectionids ) ;
if ( present == - 1 ) {
2013-05-14 09:18:05 +00:00
$sectionswitch = $ ( '<div class="s_grid_row"><label class="s_grid s_grid_3">' + sec . name + '</label><div class="s_grid s_grid_6 s_switch"><div class="s_switch_status" status-off="Off" status-on="On">Off</div><label class="s_switch_switcher admbg2"><input type="checkbox" data-widget="' + $e . data ( "id" ) + '" data-section="' + sec . _id + '" data-type="' + $e . data ( "type" ) + '"><span class="s_switch_toggle"></span></label></div></div>' ) ;
2013-05-02 08:45:33 +00:00
} else {
2013-05-14 09:18:05 +00:00
$sectionswitch = $ ( '<div class="s_grid_row"><label class="s_grid s_grid_3">' + sec . name + '</label><div class="s_grid s_grid_6 s_switch"><div class="s_switch_status" status-on="On" status-off="Off">On</div><label class="s_switch_switcher thmc2"><input type="checkbox" checked="checked" data-widget="' + $e . data ( "id" ) + '" data-section="' + sec . _id + '" data-type="' + $e . data ( "type" ) + '"><span class="s_switch_toggle"></span></label></div></div>' ) ;
2013-05-02 08:45:33 +00:00
}
2013-05-20 09:54:39 +00:00
$appinfolist . find ( "[info=app_section_activation]" ) . append ( $sectionswitch ) ;
} ) ;
info _open ( ) ;
2013-05-02 08:45:33 +00:00
o . simple _switch ( function ( dom ) {
var options = {
"status" : dom . is ( ":checked" ) ,
2013-05-14 09:18:05 +00:00
"id" : dom . data ( "widget" ) ,
"section_id" : dom . data ( "section" ) ,
"type" : dom . data ( "type" )
2013-05-02 08:45:33 +00:00
}
var sectionDetails = o . sectionList . filter ( function ( o ) { return ( o . _id == dom . data ( "section" ) ) } ) [ 0 ] ;
$ . ajax ( {
url : "/desktop/appactivation" ,
type : "post" ,
datatype : "json" ,
data : options ,
success : function ( data ) {
if ( data . success == "true" ) {
2013-05-14 09:18:05 +00:00
if ( dom . is ( ":checked" ) ) { console . log ( "true" ) ;
elementSettingsData [ $e . data ( "id" ) ] . sections . push ( { "id" : dom . data ( "section" ) , "name" : sectionDetails . name } ) ;
2013-05-02 08:45:33 +00:00
o . notify ( "Added to " + sectionDetails . name , "success" ) ;
2013-05-14 09:18:05 +00:00
} else {
var index = elementSettingsData [ $e . data ( "id" ) ] . sections . indexOfObject ( elementSettingsData [ $e . data ( "id" ) ] . sections . filter ( function ( a ) { return a . id == dom . data ( "section" ) } ) [ 0 ] ) ;
elementSettingsData [ $e . data ( "id" ) ] . sections . splice ( index , 1 ) ;
2013-05-02 08:45:33 +00:00
o . notify ( "Removed from " + sectionDetails . name , "success" ) ;
2013-05-14 09:18:05 +00:00
}
2013-05-02 08:45:33 +00:00
}
}
2013-05-20 09:54:39 +00:00
} ) ;
2013-05-02 08:45:33 +00:00
} ) ;
2013-05-20 09:54:39 +00:00
return false ;
} ) ;
2013-05-02 08:45:33 +00:00
}
$appinfo . find ( "a.panel_close" ) . click ( function ( ) {
2013-05-20 09:54:39 +00:00
info _close ( ) ;
2013-05-02 08:45:33 +00:00
return false ;
2013-05-20 09:54:39 +00:00
} ) ;
var info _open = function ( ) {
if ( $appinfo . is ( ":hidden" ) ) {
$ ( '.overview' ) . stop ( ) . animate ( { 'width' : '+=480' } , 0 , function ( ) {
$ ( '.tinycanvas' ) . tinyscrollbar _update ( ) ;
} ) ;
$appinfo
. css ( {
'display' : 'block' ,
'margin-left' : - 480
} )
. delay ( 300 )
. animate ( {
'margin-left' : 0
} , 500 , 'easeInOutQuint' ) ;
} else {
$ ( '.tinycanvas' ) . tinyscrollbar _update ( ) ;
}
}
var info _close = function ( ) {
if ( $appinfo . is ( ":visible" ) ) {
$appinfo
. stop ( )
. animate ( {
'margin-left' : - 480
} , 500 , 'easeInOutQuint' , function ( ) {
$ ( '.overview' ) . animate ( { 'width' : '-=480' } , 0 , function ( ) {
$ ( '.tinycanvas' ) . tinyscrollbar _update ( ) ;
} ) ;
$ ( this ) . attr ( "style" , "" ) ;
} ) ;
} else {
$ ( '.tinycanvas' ) . tinyscrollbar _update ( ) ;
}
}
$ ( window ) . on ( 'keydown' , function ( ) {
if ( $ ( '#searchbox' ) . val ( ) == 'Search' ) {
$ ( '#searchbox' ) . focus ( ) ;
}
} ) ;
2013-05-02 08:45:33 +00:00
elementSetting ( ) ;
2013-06-14 08:08:30 +00:00
o . appname _substr ( '#group_wrapper .element' ) ;
2013-05-20 09:54:39 +00:00
o . check _simple _layout ( ) ;
2012-11-15 03:18:55 +00:00
}
2013-05-02 08:45:33 +00:00
var elementSettingsData = { } ;
var loadApps = function ( ) { //this load apps for sorting and searching
2013-05-20 09:54:39 +00:00
$ ( '#app_info' ) . attr ( 'style' , '' ) ;
$ ( '.search_result' ) . hide ( ) . text ( "" ) ;
$ ( '#app_list' ) . empty ( ) . show ( ) ;
2013-05-02 08:45:33 +00:00
$ . getJSON ( "/desktop/getapplistforManager" , { desktopid : o . desktopId } , function ( apps ) {
2013-05-20 09:54:39 +00:00
var count = 0 ,
colindex = 0 ,
apps _sum = apps . length ,
col _sum ;
col _sum = ( apps _sum - ( apps _sum % 4 ) ) / 4 + 1 ;
$ ( '#app_list' )
. css ( 'width' , col _sum * 132 )
. append ( '<div class="g_col g_col_w1 col' + colindex + '"/>' ) ;
$ . each ( apps , function ( i , app ) {
var $app ;
count ++ ;
elementSettingsData [ app . id ] = { "sections" : app . sections } ;
2013-06-14 08:08:30 +00:00
$app = $ ( '<div class="element w1 h1 thmc2" data-type="' + app . data _category + '" data-title="' + app . title + '" data-author="' + app . author + '" data-version="' + app . version + '" data-update="' + app . last _update + '" data-id="' + app . id + '" data-text-color="' + app . text _color + '" data-background="' + app . background + '" ><span class="tile thmc2"></span><a href="' + app . id + '" class="appicon"><img src="' + app . icon + '" alt="" onclick="return false;"></a><h1 class="appname thmtxt">' + app . title + '</h1></div>' ) ;
2013-05-20 09:54:39 +00:00
if ( count > 4 ) {
count = 1 , colindex += 1 ;
$ ( '#app_list' ) . append ( '<div class="g_col g_col_w1 col' + colindex + '"/>' ) ;
$ ( '.g_col.col' + colindex ) . append ( $app ) ;
} else {
$ ( '.g_col.col' + colindex ) . append ( $app ) ;
}
} ) ;
2012-11-15 03:18:55 +00:00
bindHandlers ( ) ;
2013-04-10 03:16:06 +00:00
} ) ;
2012-11-15 03:18:55 +00:00
}
2013-05-02 08:45:33 +00:00
// if(cache){
// bindHandlers();
// } else {
2012-11-15 03:18:55 +00:00
loadApps ( ) ;
2013-05-02 08:45:33 +00:00
// }
2012-11-15 03:18:55 +00:00
} ;
2013-06-14 08:08:30 +00:00
2012-11-15 03:18:55 +00:00
this . initializeSettings = function ( target , url , cache ) { //this is to initialize setting page
2012-12-03 04:23:56 +00:00
this . initializeSettings . account = function ( data ) { }
this . initializeSettings . passwordUpdate = function ( data ) {
if ( data . success ) {
o . notify ( data . msg , "success" ) ;
} else {
o . notify ( data . msg , "alert" ) ;
}
}
2012-11-28 10:11:49 +00:00
2012-11-15 03:18:55 +00:00
this . initializeSettings . sections = function ( ) { // this load section page in setting page
var bindHandlers = function ( ) { // binding handlers in section page
2013-03-07 11:15:30 +00:00
2013-04-10 03:16:06 +00:00
$ ( "#name_save_btn" ) . click ( function ( ) {
2012-11-15 03:18:55 +00:00
var desktopnm = new Array ;
$ ( "#desktop_names input" ) . each ( function ( ) {
desktopnm . push ( $ ( this ) . val ( ) ) ;
} )
$ . post ( "/desktop/save_desktop_settings" , { "save" : "desktopnames" , "desktopid" : o . desktopId , "desktopnms" : desktopnm } , function ( result , status ) {
if ( result [ 0 ] . success == "true" ) {
o . notify ( "Names Saved!!" , "success" , 2 ) ;
} else
o . notify ( "Name saving failed!!" , "imp" , 2 ) ;
} )
$ . each ( o . sectionList , function ( i , sec ) {
sec . name = desktopnm [ i ] ;
} )
} )
}
$ . getJSON ( "/desktop/get_desktop_settings" , { "get" : "sectionnames" , "desktopid" : o . desktopId } , function ( sectionnames ) {
$ ( "#desktop_names input" ) . each ( function ( i ) {
$ ( this ) . val ( sectionnames [ i ] ) ;
} )
bindHandlers ( ) ;
2012-11-17 19:07:50 +00:00
} )
2012-11-15 03:18:55 +00:00
}
this . initializeSettings . themes = function ( ) { // this opens themes page in setting page
var bindHandlers = function ( ) { // binding handlers in themes page
// live change theme
$ ( ".theme_list > .ssl_item" ) . click ( function ( ) {
o . changeTheme ( $ ( this ) . attr ( "id" ) ) ;
// $(".theme_list > li").removeClass('thmc1').data('clicked',null).find('.theme_name').removeClass('thmtxt');
// $(this).addClass('thmc1').data('clicked',true).find('.theme_name').addClass('thmtxt');
$ . post ( "/desktop/save_desktop_settings" , { "save" : "theme" , "desktopid" : o . desktopId , "theme" : $ ( this ) . attr ( "id" ) } , function ( result , status ) {
if ( result [ 0 ] . success == "true" ) {
o . notify ( "Theme Saved!!" , "success" , 2 ) ;
loadthmc ( ) ;
} else {
o . notify ( "Theme saving failed!!" , "imp" , 2 ) ;
}
} ) ;
} ) ;
2013-06-14 08:08:30 +00:00
o . single _select ( ) ;
o . simple _tab ( ) ;
2012-11-15 03:18:55 +00:00
$ ( '.color-picker' ) . miniColors ( {
change : function ( hex ) {
var changewhat = $ ( this ) . attr ( "for" ) ;
var previewarea = $ ( "#theme_preview_area" ) ;
switch ( changewhat ) {
case "thmtxt" :
case "thmtxth" :
previewarea . find ( "." + changewhat ) . css ( { "color" : hex } ) ;
break ;
case "g_sep" :
previewarea . find ( "." + changewhat ) . css ( { "border-color" : hex } ) ;
break ;
case "background" :
previewarea . css ( { "background-color" : hex } ) ;
break ;
default :
previewarea . find ( "." + changewhat ) . css ( { "background-color" : hex } ) ;
break ;
}
}
} ) ;
2013-04-10 03:16:06 +00:00
$ ( "#theme_submit" ) . click ( function ( ) {
2012-11-15 03:18:55 +00:00
o . confirm ( {
message : "Are you sure that you want to save custom theme?" ,
highlighted : 1 ,
buttons : [ "Yes" , "No" ]
} , 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 ( result [ 0 ] . success == "true" )
o . notify ( "Custom theme saved!!" , "success" , 2 ) ;
else
o . notify ( "Custom theme saving failed!!" , "imp" , 2 ) ;
} )
}
} )
} ) ;
$ ( ".stock_wallpaper .ssl_item" ) . click ( function ( ) {
var wallpapername = $ ( this ) . find ( "img" ) . attr ( "alt" ) ;
o . changeWallpaper ( wallpapername ) ;
2013-06-14 08:08:30 +00:00
} )
2012-11-15 03:18:55 +00:00
}
var loadthmc = function ( ) { // a general function to load the themecolor in color selector
$ ( '.color-picker' ) . each ( function ( ) {
var cc = $ ( this ) . attr ( 'for' ) , hex , color ;
switch ( cc ) {
case 'thmtxt' :
case 'thmtxth' :
hex = 'color' ;
break ;
case 'g_sep' :
hex = 'border-left-color' ;
break ;
default :
hex = 'background-color' ;
break ;
}
if ( cc == "background" )
color = $ ( "#theme_preview_area" ) . css ( "background-color" ) ;
else
color = $ ( '#theme_preview_area .' + cc ) . css ( hex ) ;
$ ( this ) . miniColors ( "value" , o . rgb2hex ( color ) ) ;
} ) ;
2013-06-14 08:08:30 +00:00
}
2012-11-15 03:18:55 +00:00
$ . getJSON ( "/desktop/get_desktop_settings" , { "get" : "theme" , "desktopid" : o . desktopId } , function ( theme ) {
$ ( '#st1 .theme_list [id=' + theme + ']' )
2013-06-14 08:08:30 +00:00
. addClass ( "thmc1 active" , 300 )
. find ( "span" )
. addClass ( "thmtxt" ) ;
bindHandlers ( ) ;
loadthmc ( ) ;
} )
2012-11-15 03:18:55 +00:00
}
this . initializeSettings . connection = function ( ) {
var bindHandlers = function ( ) {
$ ( "#connection_setting ul a" ) . click ( function ( ) {
var what = $ ( this ) . attr ( "for" ) ,
type = $ ( this ) . attr ( "href" ) ,
$ul = $ ( "#" + type + "_connection" ) ,
usernm = $ul . find ( "input[type=text]" ) . val ( ) ,
pwd = $ul . find ( "input[type=password]" ) . val ( ) ;
switch ( what ) {
case "save" :
case "new" :
if ( usernm != "" && pwd != "" ) {
$ul . find ( "input[type=text]" ) . replaceWith ( "<div class='c_info usrnm'>" + usernm + "</div>" )
$ul . find ( "input[type=password]" ) . replaceWith ( "<div class='c_info pwd'>••••••</div>" ) ;
$ ( this ) . text ( "Edit" ) . attr ( "for" , "edit" ) ;
$ ( this ) . parent ( ) . find ( "a[for=delete]" ) . show ( ) ;
$ul . find ( "span.c_status" ) . text ( "Connected" ) . addClass ( "c_status_on" ) ;
if ( what == "save" )
what = "edit" ;
saveaccount ( usernm , pwd , type , what ) ;
}
break ;
case "edit" :
var un = $ul . find ( "div.usrnm" ) . text ( ) ;
$ul . find ( "div.usrnm" ) . replaceWith ( '<input type="text" value="' + un + '">' ) ;
$ul . find ( "div.pwd" ) . replaceWith ( '<input type="password">' ) ;
$ ( this ) . text ( "Save" ) . attr ( "for" , "save" ) ;
break ;
case "delete" :
var $this = $ ( this ) ;
o . confirm ( {
message : "Are you sure that you want to remove this account?" ,
buttons : [ "Yes" , "No" ] ,
highlighted : 2
} , function ( reply ) {
if ( reply ) {
$this . hide ( ) ;
$ul . find ( "div.usrnm" ) . replaceWith ( '<input type="text">' ) ;
$ul . find ( "div.pwd" ) . replaceWith ( '<input type="password">' ) ;
$ul . find ( "span.c_status" ) . text ( "No Connection" ) . removeClass ( "c_status_on" ) ;
$this . parent ( ) . find ( "a[for=edit]" ) . text ( "Connect" ) . attr ( "for" , "new" ) ;
saveaccount ( "" , "" , type , what ) ;
}
} )
break ;
}
} )
var $conlist = $ ( '.s_form' ) ,
conlist _w = $conlist . length * $conlist . outerWidth ( true ) + ( $conlist . length - 1 ) * 25 ;
$ ( '#connection_setting' ) . width ( conlist _w ) ;
}
var saveaccount = function ( usernm , pwd , type , what ) {
$ . post ( "/desktop/save_account_info" , { email : usernm , password : pwd , account : type , dowhat : what } , function ( result ) {
if ( what != "delete" ) {
if ( result [ 0 ] . success == "true" )
o . notify ( type + " account connected!!" , "success" , 2 ) ;
else
o . notify ( type + " account connection failed!!" , "imp" , 2 ) ;
} else {
if ( result [ 0 ] . success == "true" )
o . notify ( type + " account removed!!" , "success" , 2 ) ;
else
o . notify ( type + " account removal failed!!" , "imp" , 2 ) ;
}
} )
}
2013-06-14 08:08:30 +00:00
// $.getJSON("/otheraccounts/getaccounts",function(accounts){
// $.each(accounts,function(i,account){
// $ul = $("#"+account.type+"_connection");
// $ul.find("input[type=text]").replaceWith("<div class='c_info usrnm'>"+account.email+"</div>")
// $ul.find("input[type=password]").replaceWith("<div class='c_info pwd'>••••••</div>");
// $ul.find("a[for=new]").text("Edit").attr("for","edit");
// $ul.find("a[for=delete]").show();
// $ul.find(".c_status").text("Connected").addClass("c_status_on");
// })
// bindHandlers();
// })
2012-11-15 03:18:55 +00:00
}
} ;
this . initializeOrbitTimeline = function ( target , url , cache ) {
var timeline = new orbitTimeline ( "#timeline" ) ;
timeline . initialize ( ) ;
} ;
2012-11-21 07:35:23 +00:00
2012-11-15 03:18:55 +00:00
this . initializeAppstore = function ( target , url , cache ) {
this . initializeAppstore . widgets = function ( ) {
var bindHandlers = function ( ) {
$ ( "#widget_list a" ) . click ( function ( ) {
var sectionid = $ ( this ) . attr ( "for" ) ;
var widgetid = $ ( this ) . parent ( ) . parent ( ) . attr ( "for" ) ;
switch ( $ ( this ) . attr ( "href" ) ) {
case "addthis" :
$this = $ ( this ) ;
o . confirm ( {
message : "Are you sure you want to add this widget?" ,
buttons : [ 'Yes' , 'No' ] ,
highlighted : 1
} , function ( reply ) {
if ( reply ) {
$ . post ( "desktop_appstore/widgets_settings" , { section : sectionid , widget : widgetid , what : "add" } , function ( result ) {
if ( result [ 0 ] . success ) {
$this . attr ( "href" , "removethis" ) ;
$targetDom = $this . parent ( ) . parent ( ) . find ( "div.status" ) ;
$parentDom = $this . parent ( ) ;
if ( $targetDom . find ( "a" ) . length == 0 )
$targetDom . html ( "Status : Installed on" ) ;
$targetDom . append ( " " ) . append ( $this ) ;
if ( $parentDom . find ( "a" ) . length == 0 )
$parentDom . empty ( ) ;
o . desktopData [ "home" ] = "" ;
o . notify ( "Widget added." , "success" , 2 ) ;
} else {
o . notify ( result [ 0 ] . error , "imp" , 2 ) ;
}
} )
}
} )
break ;
case "removethis" :
$this = $ ( this ) ;
o . confirm ( {
message : "Are you sure you want to remove this widget?" ,
buttons : [ 'Yes' , 'No' ] ,
highlighted : 2
} , function ( reply ) {
if ( reply ) {
$ . post ( "desktop_appstore/widgets_settings" , { section : sectionid , widget : widgetid , what : "remove" } , function ( result ) {
if ( result [ 0 ] . success ) {
$this . attr ( "href" , "addthis" ) ;
$targetDom = $this . parent ( ) . parent ( ) . find ( "div.not_status" ) ;
$parentDom = $this . parent ( ) ;
if ( $targetDom . html ( ) == "" )
$targetDom . html ( "Install on" ) ;
$targetDom . append ( " " ) . append ( $this ) ;
if ( $parentDom . find ( "a" ) . length == 0 )
$parentDom . html ( "Status : Downloaded" ) ;
o . desktopData [ "home" ] = "" ;
o . notify ( "Widget removed." , "success" , 2 ) ;
}
} )
}
} )
break ;
}
return false ;
} ) ;
o . tinyscrollbar _ext ( {
main : '.tinycanvas' ,
fill : '.list_t'
} )
}
$ . getJSON ( "/desktop_appstore/getuserwidgets" , function ( userwidgets ) {
var column = $ ( '<div class="g_col list_t"><ul></ul></div>' ) ,
counter = 1 ,
li ;
$ . each ( userwidgets , function ( i , widge ) {
if ( ! widge . status ) widge . status = "Downloaded" ;
var brick = widge . shape . split ( ' ' ) ,
bw = parseInt ( brick [ 0 ] . substr ( 1 ) ) ,
bh = parseInt ( brick [ 1 ] . substr ( 1 ) ) ,
shp = bw + " X " + bh ;
li = $ ( '<li class="list_t_item" for="' + widge . _id + '"><div class="list_t_title">' + widge . name + '</div><div class="list_t_des">Author : ' + widge . author + '</div><div class="list_t_des">Shape : ' + shp + '</div><div class="list_t_des status">Status : ' + widge . status + '</div><div class="list_t_des not_status"></div></li>' ) ;
var cur _section _names = new Array ( ) ;
var section _names = new Array ( ) ;
var section _links = new Array ( ) ;
if ( widge . section ) {
var s _name _list = "" ;
$ . each ( widge . section , function ( x , sec ) {
$ . each ( o . sectionList , function ( j , s ) {
if ( s . _id == sec ) {
cur _section _names . push ( s . name ) ;
s _name _list += "<a href='removethis' for='" + s . _id + "' style='text-decoration:underline;'>" + s . name + "</a> " ;
}
} )
} )
var section _names = o . getArrayfromJson ( o . sectionList , "name" ) ;
var section _links = o . getArrayfromJson ( o . sectionList , "_id" ) ;
var s _name _list _not = "" ;
$ . each ( section _names , function ( j , sec _name ) {
if ( $ . inArray ( sec _name , cur _section _names ) == - 1 ) {
var sec _link = section _links [ j ] ;
s _name _list _not += "<a href='addthis' for='" + sec _link + "' style='text-decoration:underline;'>" + sec _name + "</a> " ;
}
} )
2013-04-10 03:16:06 +00:00
li . find ( ".status" ) . html ( "Status : Installed on " + s _name _list ) ;
2012-11-15 03:18:55 +00:00
if ( s _name _list _not )
2013-04-10 03:16:06 +00:00
li . find ( ".not_status" ) . html ( "Install on " + s _name _list _not ) ;
2012-11-15 03:18:55 +00:00
} else {
2013-04-10 03:16:06 +00:00
li . find ( ".not_status" ) . html ( "Install on <a href='addthis' for='" + o . sectionList [ 0 ] . _id + "' style='text-decoration:underline;'>" + o . sectionList [ 0 ] . name + "</a> <a href='addthis' for='" + o . sectionList [ 1 ] . _id + "' style='text-decoration:underline;'>" + o . sectionList [ 1 ] . name + "</a> <a href='addthis' for='" + o . sectionList [ 2 ] . _id + "' style='text-decoration:underline;'>" + o . sectionList [ 2 ] . name + "</a> <a href='addthis' for='" + o . sectionList [ 3 ] . _id + "' style='text-decoration:underline;'>" + o . sectionList [ 3 ] . name ) + "</a>" ;
2012-11-15 03:18:55 +00:00
}
2013-06-14 08:08:30 +00:00
//console.log(section_names);
2012-11-15 03:18:55 +00:00
column . find ( "ul" ) . append ( li ) ;
if ( counter % 4 == 0 ) {
2013-04-10 03:16:06 +00:00
$ ( "#apps_store #widget_list" ) . append ( column ) ;
2012-11-15 03:18:55 +00:00
column = $ ( '<div class="g_col list_t" style="width:350px;"><ul></ul></div>' ) ;
}
counter ++ ;
} )
2013-04-10 03:16:06 +00:00
$ ( "#apps_store #widget_list" ) . append ( column ) ;
2012-11-15 03:18:55 +00:00
} )
}
this . initializeAppstore . onlinestore = function ( ) {
var bindHandlers = function ( ) {
}
bindHandlers ( ) ;
}
this . initializeAppstore . onlinestore ( ) ;
bindHandlers ( ) ;
}
2012-12-27 10:25:54 +00:00
2012-11-15 03:18:55 +00:00
this . loadWallpaper = function ( wallpaper ) { // this is to load new wallpaper
2013-03-25 08:23:07 +00:00
if ( ! wallpaper ) {
2013-07-25 09:18:24 +00:00
$ ( "#thmbackground" ) . attr ( "src" , o . themesettings . background ) ;
2013-03-25 08:23:07 +00:00
} else {
2013-06-14 08:08:30 +00:00
$ ( "#thmbackground" ) . attr ( "src" , o . wallpaperPath + wallpaper ) ;
2013-03-25 08:23:07 +00:00
}
2012-11-15 03:18:55 +00:00
} ;
this . loadIconCache = function ( ) { // this function load or refresh icon cache for the theme
2013-04-10 03:16:06 +00:00
var imgs = $ ( ".docklist img" ) ;
2012-11-15 03:18:55 +00:00
$ . each ( imgs , function ( ) {
var setting _name = $ ( this ) . attr ( "id" ) . replace ( "_icon" , "" ) ;
2013-07-25 09:18:24 +00:00
$ ( this ) . attr ( "src" , "/assets/desktop/icons/" + o . themesettings . icons [ setting _name ] )
2012-11-15 03:18:55 +00:00
} )
} ;
this . initializeWidgets = function ( ) { // this function will initialize all the widgets in the desktop
2013-04-10 03:16:06 +00:00
var elements = $ ( "#group_wrapper .widget" ) ,
loading = '<div class="thmtxt o-loading"><i class="icon-spin icon-spinner"></i> Loading</div>' ;
2012-11-15 03:18:55 +00:00
$ . each ( elements , function ( ) {
2013-04-10 03:16:06 +00:00
var widget = $ ( this ) ,
2013-06-14 08:08:30 +00:00
widget _holder = $ ( this ) . find ( '.appholder' )
// widget_style = (widget.find('.widget_style').length > 0) ? '' : '<link class="widget_style" rel="stylesheet" href="'+widget.attr("css-link")+'" type="text/css" />';
2012-11-15 03:18:55 +00:00
if ( widget . attr ( "data-category" ) == "widget" ) {
2013-04-10 03:16:06 +00:00
var widgetname = widget . attr ( "data-content" ) ;
2013-06-14 08:08:30 +00:00
// widget_holder.before(widget_style).empty();
2013-04-10 03:16:06 +00:00
$ . getScript ( widget . attr ( "js-link" ) ) . done ( function ( ) {
// widget.find(".appholder").load(widget.attr("data-content"));
$ . ajax ( {
url : widgetname ,
beforeSend : function ( ) {
widget _holder . html ( loading ) ;
} ,
success : function ( html ) {
widget _holder
. css ( 'top' , '100%' )
. html ( html ) ;
} ,
complete : function ( ) {
widget _holder
. delay ( 300 )
. animate ( { top : '0' } , 500 , 'easeInOutQuint' ) ;
}
} ) ;
2012-11-15 03:18:55 +00:00
} ) ;
2013-04-10 03:16:06 +00:00
// $(this).find(".appholder").append( '<link rel="stylesheet" href="'+widget.attr("css-link")+'" type="text/css" />');
2012-11-15 03:18:55 +00:00
}
2013-04-10 03:16:06 +00:00
} ) ;
2012-11-15 03:18:55 +00:00
} ;
this . saveWallpaper = function ( wallpaper ) { // this function saves wallpaper in db
$ . post ( "/desktop/save_desktop_settings" , { "save" : "wallpaper" , "wallpapernm" : wallpaper , "desktopid" : o . desktopId } , function ( result ) {
if ( result [ 0 ] . success == "true" )
o . notify ( "Wallpaper saved!!" , "success" , 2 ) ;
else
o . notify ( "Wallpaper saving failed!!" , "imp" , 2 ) ;
} )
} ;
this . tinyscrollbar _ext = function ( target , tinysettings ) {
//main : dom on which tinyscrollbar has to be applied
//fill : number or object for width
//height : height for the target element
//tinysettings : tinyscrollbar settings
if ( typeof target . main == "undefined" ) {
2013-03-12 03:18:32 +00:00
o . notify ( 'Tinyscrollbar: target undefined' , 'imp' , 2 ) ;
2012-11-15 03:18:55 +00:00
return ;
} else {
target . main = $ ( target . main ) ;
}
2013-03-12 03:18:32 +00:00
var settings = { "axis" : "x" } ;
2013-03-12 07:23:38 +00:00
if ( typeof tinysettings != "undefined" )
$ . map ( tinysettings , function ( val , i ) { settings [ i ] = val } )
2012-11-15 03:18:55 +00:00
var count , baseWidth , fillArray , pxs ;
2013-02-27 10:55:26 +00:00
2012-11-15 03:18:55 +00:00
if ( typeof target . fill == 'string' ) {
2013-03-05 01:39:01 +00:00
// fillArray = target.main.find(target.fill);
// count = fillArray.length;
// baseWidth = $(target.fill).eq(1).outerWidth(true);
// target.main.find('.overview').width( baseWidth * count);
2012-11-15 03:18:55 +00:00
} else if ( typeof target . fill == 'number' ) {
target . main . find ( '.overview' ) . width ( target . fill ) ;
} else if ( typeof target . fill == 'undefined' ) {
} else {
2013-03-12 03:18:32 +00:00
o . notify ( 'Tinyscrollbar: setting width failed' , 'imp' , 2 ) ;
2012-11-15 03:18:55 +00:00
}
2013-03-05 01:39:01 +00:00
if ( target . height ) {
2012-11-15 03:18:55 +00:00
target . main . height ( target . height ) ;
2013-03-05 01:39:01 +00:00
}
2012-11-15 03:18:55 +00:00
2013-03-12 03:18:32 +00:00
o . tinyscrollbar = target . main . tinyscrollbar ( settings ) ;
2012-11-15 03:18:55 +00:00
} ;
2013-05-20 09:54:39 +00:00
this . check _simple _layout = function ( ) {
// use for various width of columns inside canvas(.overview)
// only count width for visible element which has "s_column" class
// then set width to canvas
// ** not sure to update canvas here ( $.tinyscrollbar_update() )
var sw = 0 ,
$simple _layout = $ ( '#content .overview[content-layout=simple]' ) ;
if ( $simple _layout . find ( ".s_column" ) . length > 0 ) {
$simple _layout . each ( function ( ) {
$ ( this ) . find ( ".s_column" ) . filter ( ":visible" ) . each ( function ( ) {
sw += $ ( this ) . outerWidth ( ) ;
} ) ;
$simple _layout . css ( 'width' , sw ) ;
} ) ;
}
2013-06-14 08:08:30 +00:00
// if($simple_layout.find(".s_column").length > 0){
// $simple_layout.css('width',sw);
// }
2013-05-20 09:54:39 +00:00
} ;
2012-11-15 03:18:55 +00:00
this . simple _drop _down = function ( ) {
// simple dropdown menu
2013-04-03 07:38:59 +00:00
var $sdm = $ ( '.sdm' ) ;
if ( $sdm . find ( '.sdm_o' ) ) {
$sdm . find ( 'a' ) . andSelf ( ) . on ( {
mouseenter : function ( ) {
$ ( this ) . addClass ( 'thmc2 thmtxt' ) ;
} ,
mouseleave : function ( ) {
$ ( this ) . removeClass ( 'thmc2 thmtxt' ) ;
}
2012-11-15 03:18:55 +00:00
} ) ;
}
2013-04-03 07:38:59 +00:00
2012-11-15 03:18:55 +00:00
} ;
this . simple _tab = function ( ) {
// tab
2013-06-14 08:08:30 +00:00
var $anchor = $ ( '.s_tab a[href*=#]' ) ,
$tabcontent = $ ( '.st_c' ) ;
$anchor . each ( function ( ) {
$ ( this ) . click ( function ( ) {
var target = $ ( this ) . attr ( 'href' ) ;
$anchor . removeClass ( 'thmc2 thmtxt admtxt admbg' ) . addClass ( 'admtxt admbg' ) ;
$ ( this ) . toggleClass ( 'thmc2 thmtxt admtxt admbg' ) ;
$tabcontent . hide ( ) ;
$ ( target ) . show ( ) ;
if ( $ ( '.tinycanvas' ) . length > 0 ) {
$ ( '.tinycanvas' ) . tinyscrollbar _update ( ) ;
}
return false ;
2012-11-15 03:18:55 +00:00
} ) ;
} ) ;
} ;
2013-05-02 08:45:33 +00:00
this . simple _switch = function ( func ) {
2013-04-29 07:13:36 +00:00
$ ( '.s_switch' ) . each ( function ( ) {
2013-06-14 08:08:30 +00:00
var $switcher = $ ( this ) . find ( '.s_switch_switcher' ) ,
$checkbox = $ ( this ) . find ( 'input[type=checkbox]' ) ,
$status = $ ( this ) . find ( '.s_switch_status' ) ,
2013-04-29 07:13:36 +00:00
toggle = '<span class="s_switch_toggle"></span>' ,
2013-06-14 08:08:30 +00:00
status _on = $status . attr ( 'status-on' ) ,
status _off = $status . attr ( 'status-off' ) ,
2013-04-29 07:13:36 +00:00
ini , set ;
2013-06-14 08:08:30 +00:00
ini = ( $switcher . hasClass ( 'admbg2' ) ) ? null : $switcher . addClass ( 'admbg2' ) ;
ini = ( $switcher . find ( '.s_switch_toggle' ) . length < 1 ) ? $checkbox . after ( toggle ) : null ;
set = ( $checkbox . is ( ':checked' ) ) ? $status . text ( status _on ) : $status . text ( status _off ) ;
$checkbox . unbind ( ) . change ( function ( ) {
2013-04-29 07:13:36 +00:00
var v = $ ( this ) . attr ( 'checked' ) ;
switch ( v ) {
case 'checked' :
2013-06-14 08:08:30 +00:00
$switcher . switchClass ( 'admbg2' , 'thmc2' ) ;
$status . text ( status _on ) ;
2013-04-29 07:13:36 +00:00
break ;
case undefined :
2013-06-14 08:08:30 +00:00
$switcher . switchClass ( 'thmc2' , 'admbg2' ) ;
$status . text ( status _off ) ;
2013-04-29 07:13:36 +00:00
break ;
}
2013-05-20 09:54:39 +00:00
if ( typeof func == "function" ) {
2013-05-02 08:45:33 +00:00
func . call ( this , $ ( this ) ) ;
2013-05-20 09:54:39 +00:00
}
2013-04-29 07:13:36 +00:00
} ) ;
} ) ;
} ;
2013-05-02 08:45:33 +00:00
2012-11-15 03:18:55 +00:00
this . single _select = function ( ) {
// single select
$ ( '.ssl .ssl_item' ) . each ( function ( ) {
var $des = $ ( this ) . find ( '.ssl_des' ) ;
$ ( this ) . on ( {
click : function ( ) {
$ ( this ) . switchClass ( '' , 'thmc1 active' , 0 ) ;
$ ( this ) . siblings ( '.thmc1' ) . switchClass ( 'thmc1 active' , '' , 0 ) ;
if ( $des . length > 0 ) {
$ ( this ) . parents ( '.ssl' ) . find ( '.ssl_des' ) . removeClass ( 'thmtxt' ) ;
$des . addClass ( 'thmtxt' ) ;
}
} ,
mouseenter : function ( ) {
if ( ! $ ( this ) . hasClass ( 'active' ) ) {
$ ( this ) . addClass ( 'thmc1' ) ;
if ( $des . length > 0 ) {
$des . addClass ( 'thmtxt' ) ;
}
}
} ,
mouseleave : function ( ) {
if ( ! $ ( this ) . hasClass ( 'active' ) ) {
$ ( this ) . removeClass ( 'thmc1' ) ;
if ( $des . length > 0 ) {
$des . removeClass ( 'thmtxt' ) ;
}
}
}
} ) ;
} ) ;
}
2013-04-24 05:48:17 +00:00
this . highlight _sub _menu _item = function ( no ) {
$ ( '*[content-type=menu] a' ) . removeClass ( 'thmc1 thmtxt active' ) ;
var dom ;
if ( typeof no == "number" ) {
dom = $ ( '*[content-type=menu] a' ) . eq ( no ) ;
dom . addClass ( 'thmc1 thmtxt active' ) ;
} else if ( typeof no == "object" ) {
dom = no ;
dom . addClass ( 'thmc1 thmtxt active' ) ;
}
return dom ;
}
2013-04-16 07:48:14 +00:00
this . use _select2 = function ( ) {
$ ( 'select:not(.select2-offscreen)' ) . select2 ( {
minimumResultsForSearch : - 1
// minimumInputLength: -1
} ) ;
}
2013-04-22 04:24:09 +00:00
this . autocomplete = function ( ) {
$ ( "*[autocomplete]" ) . each ( function ( ) {
$e = $ ( this ) ;
var options = {
multiple : true ,
minimumInputLength : - 1 ,
width : "off" ,
ajax : {
url : $e . attr ( "autocomplete" ) ,
dataType : 'json' ,
quietMillis : 100 ,
tokenSeparators : [ "," ] ,
data : function ( search , page ) {
return { q : search } ;
} ,
results : function ( data , page ) {
return { results : data . results } ;
}
}
}
var format = $e . attr ( "autocomplete-format" ) ;
if ( format ) {
format = format . split ( ":" ) ;
var seperator = format [ 0 ] ;
var fields = format [ 1 ] ;
fields = fields . replace ( "]" , "" ) ;
fields = fields . replace ( "[" , "" ) ;
fields = fields . split ( "," ) ;
2013-06-14 08:08:30 +00:00
2013-04-22 04:24:09 +00:00
options . formatResult = function ( data ) {
var markup = "" ;
var x = 0 ;
2013-06-14 08:08:30 +00:00
for ( i = 0 ; i < fields . length ; i ++ ) {
if ( i > 0 ) markup += " " + seperator + " " ;
2013-04-22 04:24:09 +00:00
if ( data [ fields [ i ] ] )
markup += data [ fields [ i ] ] ;
else
markup += fields [ i ] + " not available" ;
}
2013-06-14 08:08:30 +00:00
2013-04-22 04:24:09 +00:00
return markup ;
}
}
$e . select2 ( options ) ;
} )
}
2013-04-16 07:48:14 +00:00
this . appname _substr = function ( target , length ) {
var $target = $ ( target ) ,
length = ( length && typeof length == 'number' ) ? length : 12 ,
wrapper = '<span class="text_wrapper"/>' ,
w1 , w2 ;
if ( ! $target && $target . find ( '.text_wrapper' ) . length > 0 ) {
return ;
} else {
for ( i = 0 ; i < $target . length ; i ++ ) {
var $this = $target . eq ( i ) ;
if ( $this . find ( '.appname' ) . text ( ) . length > length + 1 ) {
$this . find ( '.appname' ) . wrapInner ( wrapper ) ;
w1 = $this . find ( '.appname' ) . width ( ) - 24
w2 = $this . find ( '.text_wrapper' ) . width ( ) ;
if ( w2 > w1 ) {
var text = $this . find ( '.text_wrapper' ) . text ( ) ;
slice = text . substr ( 0 , length ) ;
$this . find ( '.text_wrapper' ) . attr ( 'title' , text ) . text ( slice + '...' ) ;
}
}
}
}
}
2013-07-25 09:18:24 +00:00
this . minimizeBarManager = function ( ) {
var minimizedApps = [ ] ,
minimizeBar = $ ( "#minimizebar" ) ;
this . minimizeBarManager . minimize = function ( win ) {
minimizedApps . push ( win . attr ( "id" ) ) ;
var $e = generateMiniBar ( win . attr ( "id" ) ) ;
$e . find ( "span[for=title]" ) . text ( win . data ( 'title' ) ) ;
$e . one ( "click" , function ( ) {
o . minimizeBarManager . maximize ( win ) ;
} ) ;
$e . find ( "span.icon-remove" ) . one ( "click" , function ( e ) {
o . appWindow . close ( win ) ;
e . stopPropagation ( ) ;
} ) ;
minimizeBar . append ( $e ) ;
win . hide ( ) ;
// var minimizeOffset = minimizeBar.offset();
// win.animate({"left":minimizeOffset.left + "px","top":minimizeOffset.top + "px","height":"25px","width":"200px"},function(){
// });
}
this . minimizeBarManager . maximize = function ( win ) {
var position = minimizedApps . indexOf ( win . attr ( "id" ) ) ;
minimizedApps . splice ( position , 1 ) ;
getMiniBar ( position ) . remove ( ) ;
win . show ( ) ;
updatePositions ( ) ;
}
var getMiniBar = function ( position ) {
return minimizeBar . find ( "div[data-position=" + position + "]" ) ;
}
var generateMiniBar = function ( id ) {
var position = minimizedApps . indexOf ( id ) ,
template = '<div id="mini_' + id + '" data-app-id="' + id + '" data-position="' + position + '" style="height:25px; width:200px; bottom:0; margin:3px 3px 3px 3px; float:right; cursor:pointer;" class="minimize thmc2"><span class="thmtxth" style="font-size:18px;margin 3px 3px;" for="title"></span><span class="icon-remove hh2 hp thmtxt" style="float:right;cursor:pointer;"></span></div>' ,
$e = $ ( template ) ;
return $e ;
}
var updatePositions = function ( ) {
minimizeBar . find ( "div.minimize" ) . each ( function ( ) {
$ ( this ) . attr ( "data-position" , minimizedApps . indexOf ( $ ( this ) . data ( "app-id" ) ) ) ;
} )
}
}
2012-11-15 03:18:55 +00:00
o . initialize ( ) ;
2012-07-04 09:55:30 +00:00
}
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" ;
orbitDesktop . prototype . currentUsername = "Harry" ;
var uselessfunction = function ( ) {
2012-11-15 03:18:55 +00:00
$ . post ( "/desktop/temp_func" , { sectionid : "4f83e7bbbd98eb041600001d" } ) ;
2012-07-05 08:42:00 +00:00
}
2012-11-05 15:04:54 +00:00