diff --git a/Gemfile b/Gemfile
index c572899f8..d33409841 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,55 +1,55 @@
-source 'http://rubygems.org'
-gem 'rails', '>=3.1.0', '<3.2.0'
-
-gem "brakeman"
-
-gem 'bson_ext'
-gem 'carrierwave'
-gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
-gem 'devise', '1.5.3'
-gem 'exception_notification' # Send error trace
-gem 'execjs'
-gem 'jquery-rails'
-
-gem 'kaminari', :git => 'git://github.com/amatsuda/kaminari.git'
-
-gem 'mini_magick'
-gem 'mongoid'
-gem "mongo_session_store-rails3"
-gem 'nokogiri'
-gem 'radius'
-gem 'rake'
-gem 'ruby-debug19'
-gem 'rubyzip'
-gem 'sinatra'
-#gem 'sinatra-contrib'
-gem 'sprockets'
-gem 'tinymce-rails'
-gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux")
-gem 'mongoid-encryptor', :require => 'mongoid/encryptor'
-#gem 'contacts'
-
-# Gems used only for assets and not required
-# in production environments by default.
-group :assets do
- gem 'sass-rails'
- gem 'coffee-rails'
- gem 'uglifier'
-end
-
-
-group :test, :development do
- gem 'spork'
- gem 'database_cleaner' #Strategies for cleaning databases. Can be used to ensure a clean state for testing.
- gem "rspec", "~> 2.0"
- gem "rspec-rails", "~> 2.0"
- gem "factory_girl_rails"
- gem "shoulda-matchers"
- gem "simplecov"
- gem "delorean"
- gem "watchr"
- gem "spork"
- # gem "capybara"
- # gem 'yard'
- # gem "bluecloth"
-end
+source 'http://rubygems.org'
+gem 'rails', '>=3.1.0', '<3.2.0'
+
+gem "brakeman"
+
+gem 'bson_ext'
+gem 'carrierwave'
+gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
+gem 'devise', '1.5.3'
+gem 'exception_notification' # Send error trace
+gem 'execjs'
+gem 'jquery-rails'
+
+gem 'kaminari'
+
+gem 'mini_magick'
+gem 'mongoid'
+gem "mongo_session_store-rails3"
+gem 'nokogiri'
+gem 'radius'
+gem 'rake'
+gem 'ruby-debug19'
+gem 'rubyzip'
+gem 'sinatra'
+#gem 'sinatra-contrib'
+gem 'sprockets'
+gem 'tinymce-rails'
+gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux")
+gem 'mongoid-encryptor', :require => 'mongoid/encryptor'
+#gem 'contacts'
+
+# Gems used only for assets and not required
+# in production environments by default.
+group :assets do
+ gem 'sass-rails'
+ gem 'coffee-rails'
+ gem 'uglifier'
+end
+
+
+group :test, :development do
+ #gem 'spork'
+ gem 'database_cleaner' #Strategies for cleaning databases. Can be used to ensure a clean state for testing.
+ gem "rspec", "~> 2.0"
+ gem "rspec-rails", "~> 2.0"
+ gem "factory_girl_rails"
+ gem "shoulda-matchers"
+ gem "simplecov"
+ gem "delorean"
+ gem "watchr"
+ #gem "spork"
+ # gem "capybara"
+ # gem 'yard'
+ # gem "bluecloth"
+end
diff --git a/Gemfile.lock b/Gemfile.lock
index 339bae0f1..5d5b90ff9 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,280 +1,267 @@
-GIT
- remote: git://github.com/amatsuda/kaminari.git
- revision: 118927a42e57d6608c10d85b8a62acfc7c175974
- specs:
- kaminari (0.13.0)
- actionpack (>= 3.0.0)
- activesupport (>= 3.0.0)
- railties (>= 3.0.0)
-
-GEM
- remote: http://rubygems.org/
- specs:
- actionmailer (3.1.4)
- actionpack (= 3.1.4)
- mail (~> 2.3.0)
- actionpack (3.1.4)
- activemodel (= 3.1.4)
- activesupport (= 3.1.4)
- builder (~> 3.0.0)
- erubis (~> 2.7.0)
- i18n (~> 0.6)
- rack (~> 1.3.6)
- rack-cache (~> 1.1)
- rack-mount (~> 0.8.2)
- rack-test (~> 0.6.1)
- sprockets (~> 2.0.3)
- activemodel (3.1.4)
- activesupport (= 3.1.4)
- builder (~> 3.0.0)
- i18n (~> 0.6)
- activerecord (3.1.4)
- activemodel (= 3.1.4)
- activesupport (= 3.1.4)
- arel (~> 2.2.3)
- tzinfo (~> 0.3.29)
- activeresource (3.1.4)
- activemodel (= 3.1.4)
- activesupport (= 3.1.4)
- activesupport (3.1.4)
- multi_json (~> 1.0)
- archive-tar-minitar (0.5.2)
- arel (2.2.3)
- bcrypt-ruby (3.0.1)
- bcrypt-ruby (3.0.1-x86-mingw32)
- brakeman (1.5.1)
- activesupport
- erubis (~> 2.6)
- haml (~> 3.0)
- i18n
- ruby2ruby (~> 1.2)
- ruport (~> 1.6)
- sass (~> 3.0)
- bson (1.6.1)
- bson_ext (1.6.1)
- bson (~> 1.6.1)
- builder (3.0.0)
- carrierwave (0.5.8)
- activesupport (~> 3.0)
- carrierwave-mongoid (0.1.3)
- carrierwave (>= 0.5.6)
- mongoid (~> 2.1)
- chronic (0.6.7)
- coffee-rails (3.1.1)
- coffee-script (>= 2.2.0)
- railties (~> 3.1.0)
- coffee-script (2.2.0)
- coffee-script-source
- execjs
- coffee-script-source (1.2.0)
- color (1.4.1)
- columnize (0.3.6)
- database_cleaner (0.7.1)
- delorean (1.2.0)
- chronic
- devise (1.5.3)
- bcrypt-ruby (~> 3.0)
- orm_adapter (~> 0.0.3)
- warden (~> 1.1)
- diff-lcs (1.1.3)
- encrypted_strings (0.3.3)
- erubis (2.7.0)
- exception_notification (2.5.2)
- actionmailer (>= 3.0.4)
- execjs (1.3.0)
- multi_json (~> 1.0)
- factory_girl (2.6.3)
- activesupport (>= 2.3.9)
- factory_girl_rails (1.7.0)
- factory_girl (~> 2.6.0)
- railties (>= 3.0.0)
- fastercsv (1.5.4)
- haml (3.1.4)
- hike (1.2.1)
- hoe (2.16.1)
- rake (~> 0.8)
- i18n (0.6.0)
- jquery-rails (1.0.19)
- railties (~> 3.0)
- thor (~> 0.14)
- json (1.6.5)
- linecache19 (0.5.12)
- ruby_core_source (>= 0.1.4)
- mail (2.3.3)
- i18n (>= 0.4.0)
- mime-types (~> 1.16)
- treetop (~> 1.4.8)
- mime-types (1.17.2)
- mini_magick (3.4)
- subexec (~> 0.2.1)
- mongo (1.6.1)
- bson (~> 1.6.1)
- mongo_session_store-rails3 (3.0.5)
- actionpack (>= 3.0)
- mongo
- mongoid (2.4.6)
- activemodel (~> 3.1)
- mongo (~> 1.3)
- tzinfo (~> 0.3.22)
- mongoid-encryptor (0.0.5)
- activesupport (~> 3.0)
- encrypted_strings (~> 0.3.3)
- mongoid (~> 2)
- multi_json (1.1.0)
- nokogiri (1.5.2)
- nokogiri (1.5.2-x86-mingw32)
- orm_adapter (0.0.6)
- pdf-writer (1.1.8)
- color (>= 1.4.0)
- transaction-simple (~> 1.3)
- polyglot (0.3.3)
- rack (1.3.6)
- rack-cache (1.2)
- rack (>= 0.4)
- rack-mount (0.8.3)
- rack (>= 1.0.0)
- rack-protection (1.2.0)
- rack
- rack-ssl (1.3.2)
- rack
- rack-test (0.6.1)
- rack (>= 1.0)
- radius (0.7.3)
- rails (3.1.4)
- actionmailer (= 3.1.4)
- actionpack (= 3.1.4)
- activerecord (= 3.1.4)
- activeresource (= 3.1.4)
- activesupport (= 3.1.4)
- bundler (~> 1.0)
- railties (= 3.1.4)
- railties (3.1.4)
- actionpack (= 3.1.4)
- activesupport (= 3.1.4)
- rack-ssl (~> 1.3.2)
- rake (>= 0.8.7)
- rdoc (~> 3.4)
- thor (~> 0.14.6)
- rake (0.9.2.2)
- rdoc (3.12)
- json (~> 1.4)
- rspec (2.8.0)
- rspec-core (~> 2.8.0)
- rspec-expectations (~> 2.8.0)
- rspec-mocks (~> 2.8.0)
- rspec-core (2.8.0)
- rspec-expectations (2.8.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.8.0)
- rspec-rails (2.8.1)
- actionpack (>= 3.0)
- activesupport (>= 3.0)
- railties (>= 3.0)
- rspec (~> 2.8.0)
- ruby-debug-base19 (0.11.25)
- columnize (>= 0.3.1)
- linecache19 (>= 0.5.11)
- ruby_core_source (>= 0.1.4)
- ruby-debug19 (0.11.6)
- columnize (>= 0.3.1)
- linecache19 (>= 0.5.11)
- ruby-debug-base19 (>= 0.11.19)
- ruby2ruby (1.3.1)
- ruby_parser (~> 2.0)
- sexp_processor (~> 3.0)
- ruby_core_source (0.1.5)
- archive-tar-minitar (>= 0.5.2)
- ruby_parser (2.3.1)
- sexp_processor (~> 3.0)
- rubyzip (0.9.6.1)
- ruport (1.6.3)
- fastercsv
- pdf-writer (= 1.1.8)
- sass (3.1.15)
- sass-rails (3.1.5)
- actionpack (~> 3.1.0)
- railties (~> 3.1.0)
- sass (~> 3.1.10)
- tilt (~> 1.3.2)
- sexp_processor (3.1.0)
- shoulda-matchers (1.0.0)
- simplecov (0.6.1)
- multi_json (~> 1.0)
- simplecov-html (~> 0.5.3)
- simplecov-html (0.5.3)
- sinatra (1.3.2)
- rack (~> 1.3, >= 1.3.6)
- rack-protection (~> 1.2)
- tilt (~> 1.3, >= 1.3.3)
- spork (0.9.0)
- spork (0.9.0-x86-mingw32)
- win32-process
- sprockets (2.0.3)
- hike (~> 1.2)
- rack (~> 1.0)
- tilt (~> 1.1, != 1.3.0)
- subexec (0.2.1)
- thor (0.14.6)
- tilt (1.3.3)
- tinymce-rails (3.4.8)
- railties (>= 3.1)
- transaction-simple (1.4.0)
- hoe (>= 1.1.7)
- treetop (1.4.10)
- polyglot
- polyglot (>= 0.3.1)
- tzinfo (0.3.32)
- uglifier (1.2.3)
- execjs (>= 0.3.0)
- multi_json (>= 1.0.2)
- warden (1.1.1)
- rack (>= 1.0)
- watchr (0.7)
- win32-api (1.4.8-x86-mingw32)
- win32-process (0.6.5)
- windows-pr (>= 1.1.2)
- windows-api (0.4.1)
- win32-api (>= 1.4.5)
- windows-pr (1.2.1)
- win32-api (>= 1.4.5)
- windows-api (>= 0.3.0)
-
-PLATFORMS
- ruby
- x86-mingw32
-
-DEPENDENCIES
- brakeman
- bson_ext
- carrierwave
- carrierwave-mongoid
- coffee-rails
- database_cleaner
- delorean
- devise (= 1.5.3)
- exception_notification
- execjs
- factory_girl_rails
- jquery-rails
- kaminari!
- mini_magick
- mongo_session_store-rails3
- mongoid
- mongoid-encryptor
- nokogiri
- radius
- rails (>= 3.1.0, < 3.2.0)
- rake
- rspec (~> 2.0)
- rspec-rails (~> 2.0)
- ruby-debug19
- rubyzip
- sass-rails
- shoulda-matchers
- simplecov
- sinatra
- spork
- sprockets
- tinymce-rails
- uglifier
- watchr
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.4)
+ actionpack (= 3.1.4)
+ mail (~> 2.3.0)
+ actionpack (3.1.4)
+ activemodel (= 3.1.4)
+ activesupport (= 3.1.4)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.6)
+ rack-cache (~> 1.1)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.3)
+ activemodel (3.1.4)
+ activesupport (= 3.1.4)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.4)
+ activemodel (= 3.1.4)
+ activesupport (= 3.1.4)
+ arel (~> 2.2.3)
+ tzinfo (~> 0.3.29)
+ activeresource (3.1.4)
+ activemodel (= 3.1.4)
+ activesupport (= 3.1.4)
+ activesupport (3.1.4)
+ multi_json (~> 1.0)
+ archive-tar-minitar (0.5.2)
+ arel (2.2.3)
+ bcrypt-ruby (3.0.1)
+ bcrypt-ruby (3.0.1-x86-mingw32)
+ brakeman (1.5.1)
+ activesupport
+ erubis (~> 2.6)
+ haml (~> 3.0)
+ i18n
+ ruby2ruby (~> 1.2)
+ ruport (~> 1.6)
+ sass (~> 3.0)
+ bson (1.6.1)
+ bson_ext (1.6.1)
+ bson (~> 1.6.1)
+ builder (3.0.0)
+ carrierwave (0.5.8)
+ activesupport (~> 3.0)
+ carrierwave-mongoid (0.1.3)
+ carrierwave (>= 0.5.6)
+ mongoid (~> 2.1)
+ chronic (0.6.7)
+ coffee-rails (3.1.1)
+ coffee-script (>= 2.2.0)
+ railties (~> 3.1.0)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.2.0)
+ color (1.4.1)
+ columnize (0.3.6)
+ database_cleaner (0.7.1)
+ delorean (1.2.0)
+ chronic
+ devise (1.5.3)
+ bcrypt-ruby (~> 3.0)
+ orm_adapter (~> 0.0.3)
+ warden (~> 1.1)
+ diff-lcs (1.1.3)
+ encrypted_strings (0.3.3)
+ erubis (2.7.0)
+ exception_notification (2.5.2)
+ actionmailer (>= 3.0.4)
+ execjs (1.3.0)
+ multi_json (~> 1.0)
+ factory_girl (2.6.3)
+ activesupport (>= 2.3.9)
+ factory_girl_rails (1.7.0)
+ factory_girl (~> 2.6.0)
+ railties (>= 3.0.0)
+ fastercsv (1.5.4)
+ haml (3.1.4)
+ hike (1.2.1)
+ hoe (2.16.1)
+ rake (~> 0.8)
+ i18n (0.6.0)
+ jquery-rails (1.0.19)
+ railties (~> 3.0)
+ thor (~> 0.14)
+ json (1.6.5)
+ kaminari (0.13.0)
+ actionpack (>= 3.0.0)
+ activesupport (>= 3.0.0)
+ railties (>= 3.0.0)
+ libv8 (3.3.10.4)
+ linecache19 (0.5.12)
+ ruby_core_source (>= 0.1.4)
+ mail (2.3.3)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.17.2)
+ mini_magick (3.4)
+ subexec (~> 0.2.1)
+ mongo (1.6.1)
+ bson (~> 1.6.1)
+ mongo_session_store-rails3 (3.0.5)
+ actionpack (>= 3.0)
+ mongo
+ mongoid (2.4.6)
+ activemodel (~> 3.1)
+ mongo (~> 1.3)
+ tzinfo (~> 0.3.22)
+ mongoid-encryptor (0.0.5)
+ activesupport (~> 3.0)
+ encrypted_strings (~> 0.3.3)
+ mongoid (~> 2)
+ multi_json (1.1.0)
+ nokogiri (1.5.2)
+ nokogiri (1.5.2-x86-mingw32)
+ orm_adapter (0.0.6)
+ pdf-writer (1.1.8)
+ color (>= 1.4.0)
+ transaction-simple (~> 1.3)
+ polyglot (0.3.3)
+ rack (1.3.6)
+ rack-cache (1.2)
+ rack (>= 0.4)
+ rack-mount (0.8.3)
+ rack (>= 1.0.0)
+ rack-protection (1.2.0)
+ rack
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ radius (0.7.3)
+ rails (3.1.4)
+ actionmailer (= 3.1.4)
+ actionpack (= 3.1.4)
+ activerecord (= 3.1.4)
+ activeresource (= 3.1.4)
+ activesupport (= 3.1.4)
+ bundler (~> 1.0)
+ railties (= 3.1.4)
+ railties (3.1.4)
+ actionpack (= 3.1.4)
+ activesupport (= 3.1.4)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
+ rspec (2.8.0)
+ rspec-core (~> 2.8.0)
+ rspec-expectations (~> 2.8.0)
+ rspec-mocks (~> 2.8.0)
+ rspec-core (2.8.0)
+ rspec-expectations (2.8.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.8.0)
+ rspec-rails (2.8.1)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec (~> 2.8.0)
+ ruby-debug-base19 (0.11.25)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby_core_source (>= 0.1.4)
+ ruby-debug19 (0.11.6)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby-debug-base19 (>= 0.11.19)
+ ruby2ruby (1.3.1)
+ ruby_parser (~> 2.0)
+ sexp_processor (~> 3.0)
+ ruby_core_source (0.1.5)
+ archive-tar-minitar (>= 0.5.2)
+ ruby_parser (2.3.1)
+ sexp_processor (~> 3.0)
+ rubyzip (0.9.6.1)
+ ruport (1.6.3)
+ fastercsv
+ pdf-writer (= 1.1.8)
+ sass (3.1.15)
+ sass-rails (3.1.5)
+ actionpack (~> 3.1.0)
+ railties (~> 3.1.0)
+ sass (~> 3.1.10)
+ tilt (~> 1.3.2)
+ sexp_processor (3.1.0)
+ shoulda-matchers (1.0.0)
+ simplecov (0.6.1)
+ multi_json (~> 1.0)
+ simplecov-html (~> 0.5.3)
+ simplecov-html (0.5.3)
+ sinatra (1.3.2)
+ rack (~> 1.3, >= 1.3.6)
+ rack-protection (~> 1.2)
+ tilt (~> 1.3, >= 1.3.3)
+ sprockets (2.0.3)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ subexec (0.2.1)
+ therubyracer (0.10.1)
+ libv8 (~> 3.3.10)
+ thor (0.14.6)
+ tilt (1.3.3)
+ tinymce-rails (3.4.8)
+ railties (>= 3.1)
+ transaction-simple (1.4.0)
+ hoe (>= 1.1.7)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.32)
+ uglifier (1.2.3)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
+ warden (1.1.1)
+ rack (>= 1.0)
+ watchr (0.7)
+
+PLATFORMS
+ ruby
+ x86-mingw32
+
+DEPENDENCIES
+ brakeman
+ bson_ext
+ carrierwave
+ carrierwave-mongoid
+ coffee-rails
+ database_cleaner
+ delorean
+ devise (= 1.5.3)
+ exception_notification
+ execjs
+ factory_girl_rails
+ jquery-rails
+ kaminari
+ mini_magick
+ mongo_session_store-rails3
+ mongoid
+ mongoid-encryptor
+ nokogiri
+ radius
+ rails (>= 3.1.0, < 3.2.0)
+ rake
+ rspec (~> 2.0)
+ rspec-rails (~> 2.0)
+ ruby-debug19
+ rubyzip
+ sass-rails
+ shoulda-matchers
+ simplecov
+ sinatra
+ sprockets
+ therubyracer
+ tinymce-rails
+ uglifier
+ watchr
diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js
index 31f800740..66cb2a4e8 100755
--- a/app/assets/javascripts/orbitdesktop.js
+++ b/app/assets/javascripts/orbitdesktop.js
@@ -1,1374 +1,1445 @@
-// JavaScript Document
-//harry
-//Inititialize function will initialize desktop
-$.extend($.expr[':'], {
- 'containsi': function (elem, i, match, array) {
- return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
- }
-});
-$.fn.sort = function(c) {
- return this.pushStack([].sort.apply(this, arguments), []);
- };
-var sortAscending = function(a, b) {
- return $(a).find("h1").text() > $(b).find("h1").text() ? 1 : -1;
-};
-var sortDescending = function(a, b) {
- return $(a).find("h1").text() < $(b).find("h1").text() ? 1 : -1;
-};
-var orbitDesktop = function(dom){
- orbitDesktopAPI.apply(this);
- o = this;
- this.contentHolder = dom;
- this.themesettings = "";
- this.theme = "4f8d3f493b67fcd05f086359";
- this.transitionTime = 500;
- this.currenthtml = "desktop.html";
- this.currentface = "home";
- this.desktopData = {"home":"","settings":"","work":"","favorite":"","apps_manager":"","sections":"","journal_p":"","appstore":"","orbit":""};
- this.tp = "";
- this.sectionList;
- this.initialize = function(){
- var theme = o.theme;
- var custom = false;
- $.getJSON("/desktop/get_desktop_settings",{"get":"desktop","desktopid":o.desktopId},function(desktopSettings){
- if(desktopSettings){
- if(desktopSettings.theme!="custom"){
- theme = desktopSettings.theme;
- }else{
- theme = "4f8d3f493b67fcd05f086359";
- custom = true;
- }
- o.theme = theme;
- loadTheme(desktopSettings.customtheme,desktopSettings.wallpaper);
- }else{loadTheme();}
- })
- var loadTheme = function(customtheme,customwallpaper){ //This function will load the theme from database
- $.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){
- o.themesettings = eval(ts);
- $('head').append( $(' ').attr('href', "/"+o.themefolder+"/"+theme+"/css/"+ts.css));
- if(custom){
- $("head").find("#dyn_css").remove();
- $("head").append(customtheme);
- }
- $(document).ready(function(){o.loadWallpaper(customwallpaper);o.bindDesktopEvents();o.loadIconCache();o.initializeDesktop();});
- })
- }
- }
- this.changeTheme = function(theme){ // this function is used for changing theme
- o.theme = theme;
- $.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){
- o.themesettings = eval(ts);
- $('head').find("#dyn_css").remove();
- $('head').append( $(' ').attr('href', "/"+o.themefolder+"/"+theme+"/css/"+ts.css));
- o.loadWallpaper();
- o.loadIconCache();
- })
- };
- this.bindDesktopEvents = function(){ //this function will bind the global handlers to thd desktop, for example doc
- $("a#d_app_manager").click(function(){
- var target = $(this).attr("href");
- if(o.currenthtml!=target){
- o.desktopData[o.currentface] = $(o.contentHolder).html();
- $("#content").hide("drop",o.transitionTime,function(){
- o.initializeAppSearch(target);
- });
- }
- });
- $("a#d_desktop").click(function(){
- var target = $(this).attr("href");
- if(o.currenthtml!=target){
- o.desktopData[o.currentface] = $(o.contentHolder).html();
- $("#content").hide("drop",o.transitionTime,function(){
- o.initializeDesktop(target);
- });
- }
- });
- $("a#d_sections").click(function(){
- var target = $(this).attr("href");
- if(o.currenthtml!=target){
- o.desktopData[o.currentface] = $(o.contentHolder).html();
- $("#content").hide("drop",o.transitionTime,function(){
- o.initializeSectionsManager(target);
- });
- }
- });
- $("#d_journal_p").click(function(){
- var target = $(this).attr("href");
- if(o.currenthtml!=target){
- o.desktopData[o.currentface] = $(o.contentHolder).html();
- $("#content").hide("drop",o.transitionTime,function(){
- o.initializeJournalPapers(target);
- });
- }
- });
- $("a#d_settings").click(function(){
- var target = $(this).attr("href");
- if(o.currenthtml!=target){
- o.desktopData[o.currentface] = $(o.contentHolder).html();
- $("#content").hide("drop",o.transitionTime,function(){
- o.initializeSettings(target);
- });
- }
- });
- $("a#d_appstore").click(function(){
- var target = $(this).attr("href");
- if(o.currenthtml!=target){
- o.desktopData[o.currentface] = $(o.contentHolder).html();
- $("#content").hide("drop",o.transitionTime,function(){
- o.initializeAppstore(target);
- });
- }
- });
- $("a#d_orbit").click(function(){
- var target = $(this).attr("href");
- if(o.currenthtml!=target){
- o.desktopData[o.currentface] = $(o.contentHolder).html();
- $("#content").hide("drop",o.transitionTime,function(){
- o.initializeOrbitTimeline(target);
- });
- }
- });
- $(window).resize(function(){
- 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(){
- 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();
- });
- };
-
- this.initializeDesktop = function(target){ //this is for initializing main desktops that are sections and tiles
- if(!target)target = "desktop";
- o.currenthtml = target;
- o.currentface = "home";
-
- var bindHandlers = function(){ // this function will bind all the handlers in the desktop
- var groupWrapperWidth = 0;
- $("div#desktop .group").each(function(){groupWrapperWidth+=$(this).outerWidth(true);});
- var grps = new Array;
- $("div#desktop #group_wrapper").css("width",groupWrapperWidth);
- var first = true;
- $("div#desktop .g_col").sortable({
- connectWith: ".g_col",
- tolerance: 'pointer' ,
- revert: 300,
- containment: '#group_wrapper',
- helper: 'clone',
- stop:function(){
- first = true;
- var grpwidth = 0;
- for(i in grps){
- var grp = grps[i];
- if(grp.find(".element").length == 0){
- grp.animate({"width":"0px"},500,function(){$(this).remove();});
- grpwidth+=225;
- }
- }
- grps = [];
- $("#group_wrapper").width($("#group_wrapper").width()-grpwidth);
- },
- start:function(){
- $("#group_wrapper").find("div.group").each(function(i,par){
- var nextnumber = $(this).find("ul").length;
- $newcol = $('
');
- $(this).append($newcol);
- $newcol.sortable({connectWith: '.g_col'});
- grps.push($newcol);
- $("#group_wrapper").width($("#group_wrapper").width()+225);
- });
- $("div#desktop .g_col").sortable('refresh');
- },
- update:function(){
- if(first){
- first = false;
- var newpostitions = new Array;
- var groupids = new Array;
- $.each($("div#desktop .group"),function(i,grp){
- var groupone = new Array;
- groupids.push($(grp).attr("id"));
- $ul = $(grp).find(".g_col .element");
- $.each($ul,function(){
- groupone.push($(this).attr("id"));
- })
- newpostitions.push(groupone);
- });
- $.post("/desktop/newpositions",{"sectionid":o.sectionId,"newpos":newpostitions,"groupids":groupids});
- }
- var s = $(this).find('.element').length;
- if(s!=0){
- last = $(this).find('.element').eq(s-1).position(),
- lasth = $(this).find('.element').eq(s-1).outerHeight(true);
- if ((last.top+lasth)>528){
- $(this).sortable('cancel');
- }
- }
- $("#group_wrapper ul").each(function(){
- if($(this).find('.element').length == 0)
- $(this).animate({"width":"0px"},500,function(){$(this).remove();});
- })
- },
- receive: function(event, ui){
- var s = $(this).find('.element').length,
- last = $(this).find('.element').eq(s-1).position(),
- lasth = $(this).find('.element').eq(s-1).outerHeight(true);
- if ((last.top+lasth)>528){
- $(ui.sender).sortable('cancel');
- }
- }
- });
- $('div#desktop .tinycanvas')
- .tinyscrollbar({ axis: 'x' })
- .find('.scrollbar')
- .delay(1500)
- .addClass('op00', 500);
- // simple dropdown menu
- var $sdm = $('.sdm');
-
- if( !$sdm.children('.sdm_o') ){
- return;
- } else {
- $sdm.hover(function(){
- $(this).addClass('thmc2');
- }, function(){
- $(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();
- $.getJSON("/desktop/getgroups",{sectionid:id},function(groups){
- var tilecolors = o.themesettings.tilecolor;
- var opacity = ["op05","op06","op07","op08","op09"];
- $.each(groups,function(i,group){
- group.sort(o.sortJSON("position",true,parseInt));
- // var $group = $(''),
- var colindex = 0,
- $group = $('
'),
- $col = $(''),
- $li,
- bdsum = 0,
- bwsum = 0,
- bhsum = 0,
- small = 0,
- single = false;
- $group.append($col);
- for(j=0;j 8 || bhsum > 6){
- bdsum = 0, bhsum = 0, colindex++,j--;
- $group.append('');
- }else{
- var tilecolor = tilecolors[Math.floor(Math.random()*tilecolors.length)];
- var op = opacity[Math.floor(Math.random()*opacity.length)];
- if(j==0)$group.attr("id",tile.group_id);
-
- if(tile.data_category == "app")
- $li = $(''+tile.title+' ');
- else
- $li = $(''+tile.title+' Loading...
');
-
- $group.find('.col'+colindex).append($li);
- }
- }
- $("div#desktop div#group_wrapper").append($group);
- })
- bindHandlers();
- o.initializeWidgets();
- })
- }
- var loadSectionList = function(){ //This will load the section list from the db
- $.getJSON("/desktop/getsectionlist",{desktopid:o.desktopId},function(sectionlist){
- o.sectionList = eval(sectionlist);
- $.each(sectionlist,function(i,section){
- var tempstyle="";
- if(i==0){
- tempstyle = "style='display:none;'";
- $("#desktop #section_heading").text(section.name);
- }
- $("div#desktop ul#section_list").append($(''+section.name+' '));
- })
- bindSecondaryHandlers();
- })
- }
- var bindSecondaryHandlers = function(){ //This is the secondary bind handler function which is used to bind events which are repeatative
- $("div#desktop ul#section_list li.section_name").click(function(){
- $("div#desktop li.section_name").show();
- $(this).hide();
- $("#desktop #section_heading").text($(this).text());
- o.sectionId = $(this).find("a").attr("href");
- loadTiles(o.sectionId);
- })
- }
-
- if(!o.desktopData[o.currentface]){
- $(o.contentHolder).empty().load("/desktop/"+target,function(){
- loadTiles(o.sectionId);
- loadSectionList();
- });
- }else{
- $(o.contentHolder).html(o.desktopData[o.currentface]);
- bindHandlers();
- o.initializeWidgets();
- bindSecondaryHandlers();
- $("div#desktop ul#section_list").empty();
- $.each(o.sectionList,function(i,section){
- var tempstyle="";
- if(section._id==o.sectionId){
- tempstyle = "style='display:none;'";
- $("div#desktop span#section_heading").text(section.name);
- }
- $("div#desktop ul#section_list").append($(''+section.name+' '));
- })
- bindSecondaryHandlers();
- }
- };
-
- this.tempFunc = function(th){
- $.post("desktop/twitter",function(){});
- };
-
- this.initializeAppSearch = function(target){ //this is application search ie is app manager initialization
- o.currenthtml = target;
- o.currentface = "apps_manager";
- var searchArray,allApps;
- var bindHandlers = function(){ // bind handler for app manager page
- var gn = $('.g_col').length,
- gw = $('.g_col').outerWidth(true);
- $("#app_manager #group_wrapper").css("width",gn*gw);
- // $("div#app_manager .group_search").css("width",$(window).width()-200);
- //for textbox search
- $("#app_manager #searchbox").focus(function(){$(this).val("");}).keyup(function(e){
- if($(this).val()){
- $("div#app_manager .search_result").empty();
- $("div#app_manager #seperator").hide();
- searchArray = $("div#app_manager .element:containsi("+$(this).val()+")");
- if(searchArray.length>0){
- $("div#app_manager #seperator").show();
- searchArray.each(function(){
- var $newelement = $(''+$(this).html()+'
');
- $("div#app_manager .search_result").prepend($newelement);
- })
- }
- }else{$("div#app_manager #seperator").hide();$("div#app_manager .search_result").empty();}
- }).blur(function(){$(this).val("Search");});
-
- //for Alphabet sorting
- $("div#app_manager a#alphabet_sort_btn").click(function(){
- switch ($(this).attr("href")){
- case "ascending":
- $(this).attr("href","descending").find(".thmtxt").text("Alphabet [Z-A]");
- allApps = $("div#app_manager .group_search .element").sort(sortAscending);
- break;
- case "descending":
- $(this).attr("href","ascending").find(".thmtxt").text("Alphabet [A-Z]");
- allApps = $("div#app_manager .group_search .element").sort(sortDescending);
- break;
- }
- $("div#app_manager #app_list").empty();
- var count = 0, colindex = 0;
- $('#app_list').append('
');
- $.each(allApps,function(i,app){
- count++;
- if( count > 4 ){
- count = 1, colindex+=1;
- $('#app_list').append('
');
- $('.g_col.col'+ colindex).append(app);
- } else {
- $('.g_col.col'+ colindex).append(app);
- }
- })
- return false;
- })
- $('.tinycanvas')
- .tinyscrollbar({ axis: 'x'})
- .find('.scrollbar')
- .delay(1500)
- .addClass('op00', 500);
- }
- var loadApps = function(){ //this load apps for sorting and searching
- $.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){
- var count = 0, colindex = 0;
- $('#app_list').append('
');
- $.each(appss,function(i,apps){
- $.each(apps,function(i,app){
- var $app;
- count++;
- $app = $(''+app.title+' ');
- if( count > 4 ){
- count = 1, colindex+=1;
- $('#app_list').append('
');
- $('.g_col.col'+ colindex).append($app);
- } else {
- $('.g_col.col'+ colindex).append($app);
- }
- })
- })
-
- bindHandlers();
- })
- }
- if(!o.desktopData[o.currentface]){
- $(o.contentHolder).empty().load("/desktop/"+target,function(){
- loadApps();
- });
- }else{
- $(o.contentHolder).html(o.desktopData[o.currentface]);
- bindHandlers();
- }
- };
- this.initializeSectionsManager = function(target){ // this is init function for section manager
- o.currenthtml = target;
- o.currentface = "sections";
- var elementParent,element,slabel;
- var bindHandlers = function(){ // this is bind handler for section manager page
- var groupWrapperWidth = 0;
- $("div#sections .group").width(400);
- $("div#sections .group").each(function(){groupWrapperWidth+=$(this).width();})
- groupWrapperWidth+=200;
- groupWrapperHeight = $(".group").height() + 20;
- $("#group_wrapper").width(groupWrapperWidth);
- $("div#sections #group_wrapper .grp").sortable({
- start:function(){
- slabel = $(this).siblings('.section_label');
- slabel.find('li:hidden').stop(1,1).fadeIn(500);
- },
- stop:function(){
- slabel.find('li:not(:nth-child(1))').stop(1,1).fadeOut(500);
- }
- });
- $("div#sections .section_label li:not(:nth-child(1))").droppable({
- drop:function(event, ui){
- elementParent = ui.draggable.parents('.group');
- var $item = $( this ),
- $list = $( '#'+$item.data("category") );
-
- if($list.children('.element').length>=24){
- o.notify("Section is full.","alert");
- }
- else{
- ui.draggable.hide('fast',function(){
- $(this).appendTo($list).fadeIn();
- });
- $.post("/desktop/save_desktop_settings",{"save":"appnewsection","appid":ui.draggable.attr("id"),"newsectionid":$(this).data("content"),"desktopid":o.desktopId});
- if(o.sectionId == $(this).data("content") || o.sectionId == elementParent.attr("id")){
- o.desktopData["home"]="";
- }
- }
- $(this).find('span.tile').addClass('op06',400);
- },
- over:function(){
- $(this).find('span.tile').removeClass('op06');
- },
- out:function(){
- $(this).find('span.tile').addClass('op06');
- },
- accept: '.to_drop'
- });
- $('.tinycanvas')
- .tinyscrollbar({ axis: 'x'})
- .find('.scrollbar')
- .delay(1500)
- .addClass('op00', 500);
-
- var $sdm = $('.sdm');
-
- if( !$sdm.children('.sdm_o') ){
- return;
- } else {
- $sdm.hover(function(){$(this).addClass('thmc2');}, function(){$(this).removeClass('thmc2');});
- }
- };
- var loadApps = function(){ // this loads apps from db to in each sections
- $.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){
- var $group,$lii,$li;
- var z=0;
- for(section in o.sectionList){
- $group = $('');
- for(x=0;x<4;x++){
- if(x==0){
- $li = $(''+o.sectionList[z].name+' ');
- $group.find("ul.section_grp").append($li);
- }
- if(z!=x){
- $lii = $(''+o.sectionList[x].name+' ');
- $group.find("ul.section_grp").append($lii);
- }
- }
- z++;
- $("div#group_wrapper").append($group);
- }
- var yy=1,y=0;
- $.each(appss,function(i,apps){
-
- $.each(apps,function(i,app){
- $li = $(''+app.title+' ');
- $("ul#section"+yy).append($li);
- })
- if(y==1){
- y=-1;
- yy++;
- }
- y++;
- })
- bindHandlers();
- })
- }
- if(!o.desktopData[o.currentface]){
- $(o.contentHolder).empty().load("/desktop/"+target,function(){
- loadApps();
- });
- }else{
- $(o.contentHolder).html(o.desktopData[o.currentface]);
- bindHandlers();
- }
-
- };
- this.initializeSettings = function(target){ //this is to initialize setting page
- o.currenthtml = target;
- o.currentface = "settings";
- var bindHandlers = function(){ // this is the bind handler function for setting page
- $("div#settings ul#setting_left_nav li a").on({
- click: function(){
- if(!$(this).data("clicked")){
- var tfunc = $(this).attr("href");
- switch(tfunc){
- case "themes":
- themes();
- break;
- case "sections":
- sections();
- break;
- case "connection":
- connection();
- break;
- }
- $("div#settings ul#setting_left_nav li a").removeClass('thmc1 thmtxt').data('clicked',null);
- $(this).addClass('thmc1 thmtxt').data('clicked',true);
- }
- },
- mouseenter: function(){
- $(this).removeClass('admtxt').addClass('thmc1 thmtxt');
- },
- mouseleave: function(){
- var t = $(this).data('clicked') ? '' : 'thmc1 thmtxt';
- $(this).removeClass(t).addClass('admtxt');
- }
- });
-
- }
- var sections = function(){ // this load section page in setting page
- var bindHandlers = function(){ // binding handlers in section page
- $('.tinycanvas').each(function(){
- var h = $(this).parent().height(),
- sh = $(this).siblings('.s_tab').height();
- $(this)
- .css({'height': h-sh-24})
- .tinyscrollbar({ axis: 'y'})
- .find('.scrollbar')
- .delay(1500)
- .addClass('op00', 500);
- });
-
- $("a#name_save_btn").click(function(){
- 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];
- })
- })
- }
- $("div#settings div#panel_r").load("/desktop/settingsections",function(){
- $.getJSON("/desktop/get_desktop_settings",{"get":"sectionnames","desktopid":o.desktopId},function(sectionnames){
- $("#desktop_names input").each(function(i){
- $(this).val(sectionnames[i]);
- })
- bindHandlers();
- })
- })
-
- }
- var 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);
- }
- });
- });
- // 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');
- }
- }
- }
- });
- });
-
- $('.tinycanvas').each(function(){
- var h = $(this).parent().height(),
- sh = $(this).siblings('.s_tab').height();
- $(this)
- .css({'height': h-sh-24})
- .tinyscrollbar({ axis: 'y'})
- .find('.scrollbar')
- .delay(1500)
- .addClass('op00', 500);
- });
-
- // tab
- 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();
- $('.tinycanvas').tinyscrollbar_update();
- return false;
- });
- });
-
- $('.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;
- }
- }
- });
-
- $("a#theme_submit").click(function(){
- 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 ="";
- $("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);
- })
- }
- 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));
- });
- }
-
- $("div#settings div#panel_r").load("/desktop/settingthemes",function(){
- $.getJSON("/desktop/get_desktop_settings",{"get":"theme","desktopid":o.desktopId},function(theme){
- $('#st1 .theme_list [id='+theme+']')
- .addClass("thmc1 active", 300)
- .find("span")
- .addClass("thmtxt");
-
- bindHandlers();
- loadthmc();
- })
- })
- }
-
- var 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(""+usernm+"
")
- $ul.find("input[type=password]").replaceWith("••••••
");
- $(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(' ');
- $ul.find("div.pwd").replaceWith(' ');
- $(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(' ');
- $ul.find("div.pwd").replaceWith(' ');
- $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);
-
- $('.tinycanvas')
- .tinyscrollbar({ axis: 'x'})
- .find('.scrollbar')
- .delay(1500)
- .addClass('op00', 500);
-
- }
- 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);
- }
- })
- }
- $("div#settings div#panel_r").load("/desktop/settingconnection",function(){
- $.getJSON("desktop/getaccounts",function(accounts){
- $.each(accounts,function(i,account){
- $ul = $("#"+account.type+"_connection");
- $ul.find("input[type=text]").replaceWith(""+account.email+"
")
- $ul.find("input[type=password]").replaceWith("••••••
");
- $ul.find("a[for=new]").text("Edit").attr("for","edit");
- $ul.find("a[for=delete]").show();
- $ul.find("span.c_status").text("Connected").addClass("c_status_on");
- })
- bindHandlers();
- })
-
- })
-
- }
-
- $(o.contentHolder).empty().load("/desktop/"+target,function(){
- bindHandlers();
- themes();
- });
- };
- this.initializeOrbitTimeline = function(target){
- o.currenthtml = target;
- o.currentface = "orbit";
- var bindHandlers = function(){
- var timeline = new orbitTimeline("timeline");
- timeline.initialize();
- $('.tinycanvas').tinyscrollbar({ axis: 'x'});
- }
- if(!o.desktopData[o.currentface]){
- $(o.contentHolder).empty().load("/desktop_orbit/"+target,function(){
- bindHandlers();
- });
- }else{
- $(o.contentHolder).html(o.desktopData[o.currentface]);
- bindHandlers();
- }
- };
- this.initializeJournalPapers = function(target){ // this init journal papers
- o.currenthtml = target;
- o.currentface = "journal_p";
- var bindHandlers = function(){ // bind handler for journal paper
- $('.s_menu a').on({
- click: function(){
- if(!$(this).hasClass('active')){
- var tfunc = $(this).attr('href');
- switch(tfunc){
- case 'list':
- list();
- break;
- case 'addpaper':
- addpaper();
- break;
- }
- $('.s_menu a').removeClass('thmc1 thmtxt active');
- $(this).addClass('thmc1 thmtxt active');
- }
- },
- 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);
- }
- });
- }
-
- var list = function(){ // to open list part in journal papers page
- var journalData;
- var bindHandlers = function(){ // to bind handlers for list page
- o.simple_drop_down();
-
- // fill width for tiny scroll bar
- var e = $('.list_t'),
- count = e.length,
- baseWidth = e.eq(1).outerWidth(true);
-
- e.parents('.overview').width( baseWidth * count );
-
- $('.tinycanvas')
- .tinyscrollbar({ axis: 'x'})
- .find('.scrollbar')
- .delay(1500)
- .addClass('op00', 500);
-
-
- $("#journal_p div.toolbar ul#journal_selection_options a").click(function(){
- switch($(this).attr("href")){
- case "all":
- $("#journal_p div#paper_list a.item_check_status").addClass("checked");
- break;
- case "none":
- $("#journal_p div#paper_list a.item_check_status").removeClass("checked");
- break;
- }
- return false;
- })
- $("#journal_p div.toolbar ul#journal_view_selection a").click(function(){
- switch($(this).attr("href")){
- case "journal":
- journalview();
- break;
- case "keywords":
- keywordsview();
- break;
- case "title":
- titleview();
- break;
- case "abstract":
- abstractview();
- break;
- }
- return false;
- })
- }
-
- var bindSecondaryHandlers = function(){
- $("#journal_p div#paper_list a").click(function(){
- if($(this).hasClass("item_check_status")){
- $(this).toggleClass("checked");
- }else if($(this).hasClass("icon-star")){
- $(this).removeClass("icon-star").addClass("icon-star-empty");
- }else if($(this).hasClass("icon-star-empty")){
- $(this).removeClass("icon-star-empty").addClass("icon-star");
- }
- return false;
- })
- }
-
- var journalview = function(){
- $("#journal_p div#paper_list div.overview").empty();
- var column = $(''),
- counter = 1,
- li;
- $.each(journalData,function(i,journal){
- $.each(journal.papers,function(j,paper){
- li = $(''+journal.title+'
'+paper.title+'
');
- column.find("ul").append(li);
- if(counter%5==0){
- $("#journal_p div#paper_list div.overview").append(column);
- column = $('');
- }
- counter++;
- })
- })
- $("#journal_p div#paper_list div.overview").append(column);
- bindSecondaryHandlers();
- }
-
- var keywordsview = function(){
- $("#journal_p div#paper_list div.overview").empty();
- var column = $(''),
- counter = 1,
- li;
- $.each(journalData,function(i,journal){
- $.each(journal.papers,function(j,paper){
- li = $(''+paper.title+'
'+paper.keywords+'
');
- column.find("ul").append(li);
- if(counter%5==0){
- $("#journal_p div#paper_list div.overview").append(column);
- column = $('');
- }
- counter++;
- })
- })
- $("#journal_p div#paper_list div.overview").append(column);
- bindSecondaryHandlers();
- }
-
- var titleview = function(){
- $("#journal_p div#paper_list div.overview").empty();
- var column = $(''),
- counter = 1,
- li;
- $.each(journalData,function(i,journal){
- $.each(journal.papers,function(j,paper){
- li = $(''+paper.title+'
');
- column.find("ul").append(li);
- if(counter%5==0){
- $("#journal_p div#paper_list div.overview").append(column);
- column = $('');
- }
- counter++;
- })
- })
- $("#journal_p div#paper_list div.overview").append(column);
- bindSecondaryHandlers();
- }
-
- var abstractview = function(){
- $("#journal_p div#paper_list div.overview").empty();
- var column = $(''),
- li;
- $.each(journalData,function(i,journal){
- $.each(journal.papers,function(j,paper){
- li = $(''+paper.title+'
'+paper.abstract+paper.abstract+'
');
- column.find("ul").append(li);
- $("#journal_p div#paper_list div.overview").append(column);
- column = $('');
- })
- })
- $("#journal_p div#paper_list div.overview").append(column);
- bindSecondaryHandlers();
- }
-
- $("div#journal_p div#panel_r").load("/desktop/journal_p_list",function(){
- $.getJSON("/desktop_publications/getjournals",function(journals){
- journalData = eval(journals);
- journalview();
- bindHandlers();
- })
- })
- }
-
- var addpaper = function(){ // to open add pages in journal papers page
- var bindHandlers = function(){ // to bind handlers for add page
- o.simple_drop_down();
-
- // fill width for tiny scroll bar
- var e = $('.s_grid_con'),
- count = e.length,
- baseWidth = e.eq(1).outerWidth(true);
-
- e.parents('.overview').width( baseWidth * count );
-
-
-
- $('.tinycanvas')
- .tinyscrollbar({ axis: 'x'})
- .find('.scrollbar')
- .delay(1500)
- .addClass('op00', 500);
- }
- $("div#journal_p div#panel_r").load("/desktop/journal_p_add",function(){
- bindHandlers();
- })
- }
-
- if(!o.desktopData[o.currentface]){
- $(o.contentHolder).empty().load("/desktop/"+target,function(){
- bindHandlers();
- list();
- });
- }else{
- $(o.contentHolder).html(o.desktopData[o.currentface]);
- bindHandlers();
- list();
- }
- };
- this.initializeAppstore = function(target){
- o.currenthtml = target;
- o.currentface = "appstore";
- var bindHandlers = function(){
- $('.s_menu a').on({
- click: function(){
- if(!$(this).hasClass('active')){
- var tfunc = $(this).attr('href');
- switch(tfunc){
- case 'widgets':
- widgets();
- break;
- }
- $('.s_menu a').removeClass('thmc1 thmtxt active');
- $(this).addClass('thmc1 thmtxt active');
- }
- },
- 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);
- }
- });
- }
- var 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;
- });
- // fill width for tiny scroll bar
- var e = $('.list_t'),
- count = e.length,
- baseWidth = e.eq(1).outerWidth(true);
-
- e.parents('.overview').width( baseWidth * count );
-
- $('.tinycanvas')
- .tinyscrollbar({ axis: 'x'})
- .find('.scrollbar')
- .delay(1500)
- .addClass('op00', 500);
- }
- $("div#apps_store div#panel_r").load("/desktop_appstore/widgets",function(){
-
- $.getJSON("/desktop_appstore/getuserwidgets",function(userwidgets){
- var column = $(''),
- 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 = $(''+widge.name+'
Author : '+widge.author+'
Shape : '+shp+'
Status : '+widge.status+'
');
- 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+= ""+s.name +" ";
- }
- })
- })
- 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+= ""+sec_name+" ";
- }
- })
- li.find("div.status").html("Status : Installed on "+s_name_list);
- if(s_name_list_not)
- li.find("div.not_status").html("Install on "+s_name_list_not);
- }else{
- li.find("div.not_status").html("Install on "+o.sectionList[0].name+" "+o.sectionList[1].name+" "+o.sectionList[2].name+" "+o.sectionList[3].name)+" ";
- }
- //console.log(section_names);
- column.find("ul").append(li);
- if(counter%4==0){
- $("#apps_store div#widget_list").append(column);
- column = $('');
- }
- counter++;
- })
- $("#apps_store div#widget_list").append(column);
- bindHandlers();
- })
- })
- }
-
- if(!o.desktopData[o.currentface]){
- $(o.contentHolder).empty().load("/desktop_appstore/"+target,function(){
- widgets();
- bindHandlers();
- });
- }else{
- $(o.contentHolder).html(o.desktopData[o.currentface]);
- widgets();
- bindHandlers();
- }
- }
- this.loadWallpaper = function(wallpaper){ // this is to load new wallpaper
- if(!wallpaper)wallpapernm = o.themesettings.background;else wallpapernm = wallpaper
- var ww = $(window).width();
- var wh = $(window).height();
- if(!wallpaper)
- $("img#thmbackground").attr({"src":"/"+o.themefolder+"/"+o.theme+"/images/"+wallpapernm,"width":ww}).css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","height":"auto"});
- else
- $("img#thmbackground").attr({"src":o.wallpaperPath+wallpaper,"width":ww}).css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","height":"auto"});
-
- $("div#bgover").css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","width":ww,"height":wh});
- };
-
- this.loadIconCache = function(){ // this function load or refresh icon cache for the theme
- var imgs = $("ul.docklist img");
- $.each(imgs,function(){
- var setting_name = $(this).attr("id").replace("_icon","");
- $(this).attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons[setting_name])
- })
- };
- this.initializeWidgets = function(){ // this function will initialize all the widgets in the desktop
- var elements = $("#group_wrapper li.element");
- $.each(elements,function(){
- var widget = $(this);
- if(widget.attr("data-category")=="widget"){
- var widgename = widget.attr("data-content");
- $.getScript("/desktop_widgets/"+widgename+"/"+widgename+".js",function(){
- widget.find("div.appholder").load("/desktop_widgets/"+widgename+"/index.html.erb");
- });
- // $(this).find("div.appholder").append( $(' ').attr('href', "/desktop_widgets/"+widgename+"/css/"+widgename+".css"));
- }
-
- })
- };
- 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.simple_drop_down = function(){
- // simple dropdown menu
- if( !$('.sdm').children('.sdm_o').length > 0 ){
- return;
- } else {
- $('.sdm').hover(function(){
- $(this).stop(1,1).toggleClass('thmc2 thmtxt');
- }, function(){
- $(this).stop(1,1).toggleClass('thmc2 thmtxt');
- });
- $('.sdm').find('a').hover(function(){
- $(this).stop(1,1).toggleClass('thmc2 thmtxt');
- }, function(){
- $(this).stop(1,1).toggleClass('thmc2 thmtxt');
- });
- }
- }
- o.initialize();
-}
-
-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(){
- $.post("/desktop/temp_func",{sectionid:"4f83e7bbbd98eb041600001d"});
-}
+// JavaScript Document
+//harry
+//Inititialize function will initialize desktop
+$.extend($.expr[':'], {
+ 'containsi': function (elem, i, match, array) {
+ return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
+ }
+});
+$.fn.sort = function(c) {
+ return this.pushStack([].sort.apply(this, arguments), []);
+ };
+var sortAscending = function(a, b) {
+ return $(a).find("h1").text() > $(b).find("h1").text() ? 1 : -1;
+};
+var sortDescending = function(a, b) {
+ return $(a).find("h1").text() < $(b).find("h1").text() ? 1 : -1;
+};
+var orbitDesktop = function(dom){
+ orbitDesktopAPI.apply(this);
+ o = this;
+ this.contentHolder = dom;
+ this.themesettings = "";
+ this.theme = "4f8d3f493b67fcd05f086359";
+ this.transitionTime = 500;
+ this.currenthtml = "desktop.html";
+ this.currentface = "home";
+ this.desktopData = {"home":"","settings":"","work":"","favorite":"","apps_manager":"","sections":"","journal_p":"","appstore":"","orbit":"","books":""};
+ this.tp = "";
+ this.sectionList;
+ this.initialize = function(){
+ var theme = o.theme;
+ var custom = false;
+ $.getJSON("/desktop/get_desktop_settings",{"get":"desktop","desktopid":o.desktopId},function(desktopSettings){
+ if(desktopSettings){
+ if(desktopSettings.theme!="custom"){
+ theme = desktopSettings.theme;
+ }else{
+ theme = "4f8d3f493b67fcd05f086359";
+ custom = true;
+ }
+ o.theme = theme;
+ loadTheme(desktopSettings.customtheme,desktopSettings.wallpaper);
+ }else{loadTheme();}
+ })
+ var loadTheme = function(customtheme,customwallpaper){ //This function will load the theme from database
+ $.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){
+ o.themesettings = eval(ts);
+ $('head').append( $(' ').attr('href', "/"+o.themefolder+"/"+theme+"/css/"+ts.css));
+ if(custom){
+ $("head").find("#dyn_css").remove();
+ $("head").append(customtheme);
+ }
+ $(document).ready(function(){o.loadWallpaper(customwallpaper);o.bindDesktopEvents();o.loadIconCache();o.initializeDesktop();});
+ })
+ }
+ }
+ this.changeTheme = function(theme){ // this function is used for changing theme
+ o.theme = theme;
+ $.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){
+ o.themesettings = eval(ts);
+ $('head').find("#dyn_css").remove();
+ $('head').append( $(' ').attr('href', "/"+o.themefolder+"/"+theme+"/css/"+ts.css));
+ o.loadWallpaper();
+ o.loadIconCache();
+ })
+ };
+ this.bindDesktopEvents = function(){ //this function will bind the global handlers to thd desktop, for example doc
+ $("a#d_app_manager").click(function(){
+ var target = $(this).attr("href");
+ if(o.currenthtml!=target){
+ o.desktopData[o.currentface] = $(o.contentHolder).html();
+ $("#content").hide("drop",o.transitionTime,function(){
+ o.initializeAppSearch(target);
+ });
+ }
+ });
+ $("a#d_desktop").click(function(){
+ var target = $(this).attr("href");
+ if(o.currenthtml!=target){
+ o.desktopData[o.currentface] = $(o.contentHolder).html();
+ $("#content").hide("drop",o.transitionTime,function(){
+ o.initializeDesktop(target);
+ });
+ }
+ });
+ $("a#d_sections").click(function(){
+ var target = $(this).attr("href");
+ if(o.currenthtml!=target){
+ o.desktopData[o.currentface] = $(o.contentHolder).html();
+ $("#content").hide("drop",o.transitionTime,function(){
+ o.initializeSectionsManager(target);
+ });
+ }
+ });
+ $("#d_journal_p").click(function(){
+ var target = $(this).attr("href");
+ if(o.currenthtml!=target){
+ o.desktopData[o.currentface] = $(o.contentHolder).html();
+ $("#content").hide("drop",o.transitionTime,function(){
+ o.initializeJournalPapers(target);
+ });
+ }
+ });
+ $("a#d_settings").click(function(){
+ var target = $(this).attr("href");
+ if(o.currenthtml!=target){
+ o.desktopData[o.currentface] = $(o.contentHolder).html();
+ $("#content").hide("drop",o.transitionTime,function(){
+ o.initializeSettings(target);
+ });
+ }
+ });
+ $("a#d_appstore").click(function(){
+ var target = $(this).attr("href");
+ if(o.currenthtml!=target){
+ o.desktopData[o.currentface] = $(o.contentHolder).html();
+ $("#content").hide("drop",o.transitionTime,function(){
+ o.initializeAppstore(target);
+ });
+ }
+ });
+ $("a#d_orbit").click(function(){
+ var target = $(this).attr("href");
+ if(o.currenthtml!=target){
+ o.desktopData[o.currentface] = $(o.contentHolder).html();
+ $("#content").hide("drop",o.transitionTime,function(){
+ o.initializeOrbitTimeline(target);
+ });
+ }
+ });
+ $("a#d_books").click(function(){
+ var target = $(this).attr("href");
+ if(o.currenthtml!=target){
+ o.desktopData[o.currentface] = $(o.contentHolder).html();
+ $("#content").hide("drop",o.transitionTime,function(){
+ o.initializeBooks(target);
+ });
+ }
+ });
+ $(window).resize(function(){
+ 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(){
+ 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();
+ });
+ };
+
+ this.initializeDesktop = function(target){ //this is for initializing main desktops that are sections and tiles
+ if(!target)target = "desktop";
+ o.currenthtml = target;
+ o.currentface = "home";
+
+ var bindHandlers = function(){ // this function will bind all the handlers in the desktop
+ var groupWrapperWidth = 0;
+ $("div#desktop .group").each(function(){groupWrapperWidth+=$(this).outerWidth(true);});
+ var grps = new Array;
+ $("div#desktop #group_wrapper").css("width",groupWrapperWidth);
+ var first = true;
+ $("div#desktop .g_col").sortable({
+ connectWith: ".g_col",
+ tolerance: 'pointer' ,
+ revert: 300,
+ containment: '#group_wrapper',
+ helper: 'clone',
+ stop:function(){
+ first = true;
+ var grpwidth = 0;
+ for(i in grps){
+ var grp = grps[i];
+ if(grp.find(".element").length == 0){
+ grp.animate({"width":"0px"},500,function(){$(this).remove();});
+ grpwidth+=225;
+ }
+ }
+ grps = [];
+ $("#group_wrapper").width($("#group_wrapper").width()-grpwidth);
+ },
+ start:function(){
+ $("#group_wrapper").find("div.group").each(function(i,par){
+ var nextnumber = $(this).find("ul").length;
+ $newcol = $('');
+ $(this).append($newcol);
+ $newcol.sortable({connectWith: '.g_col'});
+ grps.push($newcol);
+ $("#group_wrapper").width($("#group_wrapper").width()+225);
+ });
+ $("div#desktop .g_col").sortable('refresh');
+ },
+ update:function(){
+ if(first){
+ first = false;
+ var newpostitions = new Array;
+ var groupids = new Array;
+ $.each($("div#desktop .group"),function(i,grp){
+ var groupone = new Array;
+ groupids.push($(grp).attr("id"));
+ $ul = $(grp).find(".g_col .element");
+ $.each($ul,function(){
+ groupone.push($(this).attr("id"));
+ })
+ newpostitions.push(groupone);
+ });
+ $.post("/desktop/newpositions",{"sectionid":o.sectionId,"newpos":newpostitions,"groupids":groupids});
+ }
+ var s = $(this).find('.element').length;
+ if(s!=0){
+ last = $(this).find('.element').eq(s-1).position(),
+ lasth = $(this).find('.element').eq(s-1).outerHeight(true);
+ if ((last.top+lasth)>528){
+ $(this).sortable('cancel');
+ }
+ }
+ $("#group_wrapper ul").each(function(){
+ if($(this).find('.element').length == 0)
+ $(this).animate({"width":"0px"},500,function(){$(this).remove();});
+ })
+ },
+ receive: function(event, ui){
+ var s = $(this).find('.element').length,
+ last = $(this).find('.element').eq(s-1).position(),
+ lasth = $(this).find('.element').eq(s-1).outerHeight(true);
+ if ((last.top+lasth)>528){
+ $(ui.sender).sortable('cancel');
+ }
+ }
+ });
+ $('div#desktop .tinycanvas')
+ .tinyscrollbar({ axis: 'x' })
+ .find('.scrollbar')
+ .delay(1500)
+ .addClass('op00', 500);
+ // simple dropdown menu
+ var $sdm = $('.sdm');
+
+ if( !$sdm.children('.sdm_o') ){
+ return;
+ } else {
+ $sdm.hover(function(){
+ $(this).addClass('thmc2');
+ }, function(){
+ $(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();
+ $.getJSON("/desktop/getgroups",{sectionid:id},function(groups){
+ var tilecolors = o.themesettings.tilecolor;
+ var opacity = ["op05","op06","op07","op08","op09"];
+ $.each(groups,function(i,group){
+ group.sort(o.sortJSON("position",true,parseInt));
+ // var $group = $(''),
+ var colindex = 0,
+ $group = $('
'),
+ $col = $(''),
+ $li,
+ bdsum = 0,
+ bwsum = 0,
+ bhsum = 0,
+ small = 0,
+ single = false;
+ $group.append($col);
+ for(j=0;j 8 || bhsum > 6){
+ bdsum = 0, bhsum = 0, colindex++,j--;
+ $group.append('');
+ }else{
+ var tilecolor = tilecolors[Math.floor(Math.random()*tilecolors.length)];
+ var op = opacity[Math.floor(Math.random()*opacity.length)];
+ if(j==0)$group.attr("id",tile.group_id);
+
+ if(tile.data_category == "app")
+ $li = $(''+tile.title+' ');
+ else
+ $li = $(''+tile.title+' Loading...
');
+
+ $group.find('.col'+colindex).append($li);
+ }
+ }
+ $("div#desktop div#group_wrapper").append($group);
+ })
+ bindHandlers();
+ o.initializeWidgets();
+ })
+ }
+ var loadSectionList = function(){ //This will load the section list from the db
+ $.getJSON("/desktop/getsectionlist",{desktopid:o.desktopId},function(sectionlist){
+ o.sectionList = eval(sectionlist);
+ $.each(sectionlist,function(i,section){
+ var tempstyle="";
+ if(i==0){
+ tempstyle = "style='display:none;'";
+ $("#desktop #section_heading").text(section.name);
+ }
+ $("div#desktop ul#section_list").append($(''+section.name+' '));
+ })
+ bindSecondaryHandlers();
+ })
+ }
+ var bindSecondaryHandlers = function(){ //This is the secondary bind handler function which is used to bind events which are repeatative
+ $("div#desktop ul#section_list li.section_name").click(function(){
+ $("div#desktop li.section_name").show();
+ $(this).hide();
+ $("#desktop #section_heading").text($(this).text());
+ o.sectionId = $(this).find("a").attr("href");
+ loadTiles(o.sectionId);
+ })
+ }
+
+ if(!o.desktopData[o.currentface]){
+ $(o.contentHolder).empty().load("/desktop/"+target,function(){
+ loadTiles(o.sectionId);
+ loadSectionList();
+ });
+ }else{
+ $(o.contentHolder).html(o.desktopData[o.currentface]);
+ bindHandlers();
+ o.initializeWidgets();
+ bindSecondaryHandlers();
+ $("div#desktop ul#section_list").empty();
+ $.each(o.sectionList,function(i,section){
+ var tempstyle="";
+ if(section._id==o.sectionId){
+ tempstyle = "style='display:none;'";
+ $("div#desktop span#section_heading").text(section.name);
+ }
+ $("div#desktop ul#section_list").append($(''+section.name+' '));
+ })
+ bindSecondaryHandlers();
+ }
+ };
+
+ this.tempFunc = function(th){
+ $.post("desktop/twitter",function(){});
+ };
+
+ this.initializeAppSearch = function(target){ //this is application search ie is app manager initialization
+ o.currenthtml = target;
+ o.currentface = "apps_manager";
+ var searchArray,allApps;
+ var bindHandlers = function(){ // bind handler for app manager page
+ var gn = $('.g_col').length,
+ gw = $('.g_col').outerWidth(true);
+ $("#app_manager #group_wrapper").css("width",gn*gw);
+ // $("div#app_manager .group_search").css("width",$(window).width()-200);
+ //for textbox search
+ $("#app_manager #searchbox").focus(function(){$(this).val("");}).keyup(function(e){
+ if($(this).val()){
+ $("div#app_manager .search_result").empty();
+ $("div#app_manager #seperator").hide();
+ searchArray = $("div#app_manager .element:containsi("+$(this).val()+")");
+ if(searchArray.length>0){
+ $("div#app_manager #seperator").show();
+ searchArray.each(function(){
+ var $newelement = $(''+$(this).html()+'
');
+ $("div#app_manager .search_result").prepend($newelement);
+ })
+ }
+ }else{$("div#app_manager #seperator").hide();$("div#app_manager .search_result").empty();}
+ }).blur(function(){$(this).val("Search");});
+
+ //for Alphabet sorting
+ $("div#app_manager a#alphabet_sort_btn").click(function(){
+ switch ($(this).attr("href")){
+ case "ascending":
+ $(this).attr("href","descending").find(".thmtxt").text("Alphabet [Z-A]");
+ allApps = $("div#app_manager .group_search .element").sort(sortAscending);
+ break;
+ case "descending":
+ $(this).attr("href","ascending").find(".thmtxt").text("Alphabet [A-Z]");
+ allApps = $("div#app_manager .group_search .element").sort(sortDescending);
+ break;
+ }
+ $("div#app_manager #app_list").empty();
+ var count = 0, colindex = 0;
+ $('#app_list').append('
');
+ $.each(allApps,function(i,app){
+ count++;
+ if( count > 4 ){
+ count = 1, colindex+=1;
+ $('#app_list').append('
');
+ $('.g_col.col'+ colindex).append(app);
+ } else {
+ $('.g_col.col'+ colindex).append(app);
+ }
+ })
+ return false;
+ })
+ $('.tinycanvas')
+ .tinyscrollbar({ axis: 'x'})
+ .find('.scrollbar')
+ .delay(1500)
+ .addClass('op00', 500);
+ }
+ var loadApps = function(){ //this load apps for sorting and searching
+ $.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){
+ var count = 0, colindex = 0;
+ $('#app_list').append('
');
+ $.each(appss,function(i,apps){
+ $.each(apps,function(i,app){
+ var $app;
+ count++;
+ $app = $(''+app.title+' ');
+ if( count > 4 ){
+ count = 1, colindex+=1;
+ $('#app_list').append('
');
+ $('.g_col.col'+ colindex).append($app);
+ } else {
+ $('.g_col.col'+ colindex).append($app);
+ }
+ })
+ })
+
+ bindHandlers();
+ })
+ }
+ if(!o.desktopData[o.currentface]){
+ $(o.contentHolder).empty().load("/desktop/"+target,function(){
+ loadApps();
+ });
+ }else{
+ $(o.contentHolder).html(o.desktopData[o.currentface]);
+ bindHandlers();
+ }
+ };
+ this.initializeSectionsManager = function(target){ // this is init function for section manager
+ o.currenthtml = target;
+ o.currentface = "sections";
+ var elementParent,element,slabel;
+ var bindHandlers = function(){ // this is bind handler for section manager page
+ var groupWrapperWidth = 0;
+ $("div#sections .group").width(400);
+ $("div#sections .group").each(function(){groupWrapperWidth+=$(this).width();})
+ groupWrapperWidth+=200;
+ groupWrapperHeight = $(".group").height() + 20;
+ $("#group_wrapper").width(groupWrapperWidth);
+ $("div#sections #group_wrapper .grp").sortable({
+ start:function(){
+ slabel = $(this).siblings('.section_label');
+ slabel.find('li:hidden').stop(1,1).fadeIn(500);
+ },
+ stop:function(){
+ slabel.find('li:not(:nth-child(1))').stop(1,1).fadeOut(500);
+ }
+ });
+ $("div#sections .section_label li:not(:nth-child(1))").droppable({
+ drop:function(event, ui){
+ elementParent = ui.draggable.parents('.group');
+ var $item = $( this ),
+ $list = $( '#'+$item.data("category") );
+
+ if($list.children('.element').length>=24){
+ o.notify("Section is full.","alert");
+ }
+ else{
+ ui.draggable.hide('fast',function(){
+ $(this).appendTo($list).fadeIn();
+ });
+ $.post("/desktop/save_desktop_settings",{"save":"appnewsection","appid":ui.draggable.attr("id"),"newsectionid":$(this).data("content"),"desktopid":o.desktopId});
+ if(o.sectionId == $(this).data("content") || o.sectionId == elementParent.attr("id")){
+ o.desktopData["home"]="";
+ }
+ }
+ $(this).find('span.tile').addClass('op06',400);
+ },
+ over:function(){
+ $(this).find('span.tile').removeClass('op06');
+ },
+ out:function(){
+ $(this).find('span.tile').addClass('op06');
+ },
+ accept: '.to_drop'
+ });
+ $('.tinycanvas')
+ .tinyscrollbar({ axis: 'x'})
+ .find('.scrollbar')
+ .delay(1500)
+ .addClass('op00', 500);
+
+ var $sdm = $('.sdm');
+
+ if( !$sdm.children('.sdm_o') ){
+ return;
+ } else {
+ $sdm.hover(function(){$(this).addClass('thmc2');}, function(){$(this).removeClass('thmc2');});
+ }
+ };
+ var loadApps = function(){ // this loads apps from db to in each sections
+ $.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){
+ var $group,$lii,$li;
+ var z=0;
+ for(section in o.sectionList){
+ $group = $('');
+ for(x=0;x<4;x++){
+ if(x==0){
+ $li = $(''+o.sectionList[z].name+' ');
+ $group.find("ul.section_grp").append($li);
+ }
+ if(z!=x){
+ $lii = $(''+o.sectionList[x].name+' ');
+ $group.find("ul.section_grp").append($lii);
+ }
+ }
+ z++;
+ $("div#group_wrapper").append($group);
+ }
+ var yy=1,y=0;
+ $.each(appss,function(i,apps){
+
+ $.each(apps,function(i,app){
+ $li = $(''+app.title+' ');
+ $("ul#section"+yy).append($li);
+ })
+ if(y==1){
+ y=-1;
+ yy++;
+ }
+ y++;
+ })
+ bindHandlers();
+ })
+ }
+ if(!o.desktopData[o.currentface]){
+ $(o.contentHolder).empty().load("/desktop/"+target,function(){
+ loadApps();
+ });
+ }else{
+ $(o.contentHolder).html(o.desktopData[o.currentface]);
+ bindHandlers();
+ }
+
+ };
+ this.initializeSettings = function(target){ //this is to initialize setting page
+ o.currenthtml = target;
+ o.currentface = "settings";
+ var bindHandlers = function(){ // this is the bind handler function for setting page
+ $("div#settings ul#setting_left_nav li a").on({
+ click: function(){
+ if(!$(this).data("clicked")){
+ var tfunc = $(this).attr("href");
+ switch(tfunc){
+ case "themes":
+ themes();
+ break;
+ case "sections":
+ sections();
+ break;
+ case "connection":
+ connection();
+ break;
+ }
+ $("div#settings ul#setting_left_nav li a").removeClass('thmc1 thmtxt').data('clicked',null);
+ $(this).addClass('thmc1 thmtxt').data('clicked',true);
+ }
+ },
+ mouseenter: function(){
+ $(this).removeClass('admtxt').addClass('thmc1 thmtxt');
+ },
+ mouseleave: function(){
+ var t = $(this).data('clicked') ? '' : 'thmc1 thmtxt';
+ $(this).removeClass(t).addClass('admtxt');
+ }
+ });
+
+ }
+ var sections = function(){ // this load section page in setting page
+ var bindHandlers = function(){ // binding handlers in section page
+ $('.tinycanvas').each(function(){
+ var h = $(this).parent().height(),
+ sh = $(this).siblings('.s_tab').height();
+ $(this)
+ .css({'height': h-sh-24})
+ .tinyscrollbar({ axis: 'y'})
+ .find('.scrollbar')
+ .delay(1500)
+ .addClass('op00', 500);
+ });
+
+ $("a#name_save_btn").click(function(){
+ 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];
+ })
+ })
+ }
+ $("div#settings div#panel_r").load("/desktop/settingsections",function(){
+ $.getJSON("/desktop/get_desktop_settings",{"get":"sectionnames","desktopid":o.desktopId},function(sectionnames){
+ $("#desktop_names input").each(function(i){
+ $(this).val(sectionnames[i]);
+ })
+ bindHandlers();
+ })
+ })
+
+ }
+ var 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);
+ }
+ });
+ });
+ // 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');
+ }
+ }
+ }
+ });
+ });
+
+ $('.tinycanvas').each(function(){
+ var h = $(this).parent().height(),
+ sh = $(this).siblings('.s_tab').height();
+ $(this)
+ .css({'height': h-sh-24})
+ .tinyscrollbar({ axis: 'y'})
+ .find('.scrollbar')
+ .delay(1500)
+ .addClass('op00', 500);
+ });
+
+ // tab
+ 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();
+ $('.tinycanvas').tinyscrollbar_update();
+ return false;
+ });
+ });
+
+ $('.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;
+ }
+ }
+ });
+
+ $("a#theme_submit").click(function(){
+ 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 ="";
+ $("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);
+ })
+ }
+ 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));
+ });
+ }
+
+ $("div#settings div#panel_r").load("/desktop/settingthemes",function(){
+ $.getJSON("/desktop/get_desktop_settings",{"get":"theme","desktopid":o.desktopId},function(theme){
+ $('#st1 .theme_list [id='+theme+']')
+ .addClass("thmc1 active", 300)
+ .find("span")
+ .addClass("thmtxt");
+
+ bindHandlers();
+ loadthmc();
+ })
+ })
+ }
+
+ var 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(""+usernm+"
")
+ $ul.find("input[type=password]").replaceWith("••••••
");
+ $(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(' ');
+ $ul.find("div.pwd").replaceWith(' ');
+ $(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(' ');
+ $ul.find("div.pwd").replaceWith(' ');
+ $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);
+
+ $('.tinycanvas')
+ .tinyscrollbar({ axis: 'x'})
+ .find('.scrollbar')
+ .delay(1500)
+ .addClass('op00', 500);
+
+ }
+ 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);
+ }
+ })
+ }
+ $("div#settings div#panel_r").load("/desktop/settingconnection",function(){
+ $.getJSON("desktop/getaccounts",function(accounts){
+ $.each(accounts,function(i,account){
+ $ul = $("#"+account.type+"_connection");
+ $ul.find("input[type=text]").replaceWith(""+account.email+"
")
+ $ul.find("input[type=password]").replaceWith("••••••
");
+ $ul.find("a[for=new]").text("Edit").attr("for","edit");
+ $ul.find("a[for=delete]").show();
+ $ul.find("span.c_status").text("Connected").addClass("c_status_on");
+ })
+ bindHandlers();
+ })
+
+ })
+
+ }
+
+ $(o.contentHolder).empty().load("/desktop/"+target,function(){
+ bindHandlers();
+ themes();
+ });
+ };
+ this.initializeOrbitTimeline = function(target){
+ o.currenthtml = target;
+ o.currentface = "orbit";
+ var bindHandlers = function(){
+ var timeline = new orbitTimeline("timeline");
+ timeline.initialize();
+ $('.tinycanvas').tinyscrollbar({ axis: 'x'});
+ }
+ if(!o.desktopData[o.currentface]){
+ $(o.contentHolder).empty().load("/desktop_orbit/"+target,function(){
+ bindHandlers();
+ });
+ }else{
+ $(o.contentHolder).html(o.desktopData[o.currentface]);
+ bindHandlers();
+ }
+ };
+ this.initializeJournalPapers = function(target){ // this init journal papers
+ o.currenthtml = target;
+ o.currentface = "journal_p";
+ var bindHandlers = function(){ // bind handler for journal paper
+ $('.s_menu a').on({
+ click: function(){
+ if(!$(this).hasClass('active')){
+ var tfunc = $(this).attr('href');
+ switch(tfunc){
+ case 'list':
+ list();
+ break;
+ case 'addpaper':
+ addpaper();
+ break;
+ }
+ $('.s_menu a').removeClass('thmc1 thmtxt active');
+ $(this).addClass('thmc1 thmtxt active');
+ }
+ },
+ 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);
+ }
+ });
+ }
+
+ var list = function(){ // to open list part in journal papers page
+ var journalData;
+ var bindHandlers = function(){ // to bind handlers for list page
+ o.simple_drop_down();
+
+ // fill width for tiny scroll bar
+ var e = $('.list_t'),
+ count = e.length,
+ baseWidth = e.eq(1).outerWidth(true);
+
+ e.parents('.overview').width( baseWidth * count );
+
+ $('.tinycanvas')
+ .tinyscrollbar({ axis: 'x'})
+ .find('.scrollbar')
+ .delay(1500)
+ .addClass('op00', 500);
+
+
+ $("#journal_p div.toolbar ul#journal_selection_options a").click(function(){
+ switch($(this).attr("href")){
+ case "all":
+ $("#journal_p div#paper_list a.item_check_status").addClass("checked");
+ break;
+ case "none":
+ $("#journal_p div#paper_list a.item_check_status").removeClass("checked");
+ break;
+ }
+ return false;
+ })
+ $("#journal_p div.toolbar ul#journal_view_selection a").click(function(){
+ switch($(this).attr("href")){
+ case "journal":
+ journalview();
+ break;
+ case "keywords":
+ keywordsview();
+ break;
+ case "title":
+ titleview();
+ break;
+ case "abstract":
+ abstractview();
+ break;
+ }
+ return false;
+ })
+ }
+
+ var bindSecondaryHandlers = function(){
+ $("#journal_p div#paper_list a").click(function(){
+ if($(this).hasClass("item_check_status")){
+ $(this).toggleClass("checked");
+ }else if($(this).hasClass("icon-star")){
+ $(this).removeClass("icon-star").addClass("icon-star-empty");
+ }else if($(this).hasClass("icon-star-empty")){
+ $(this).removeClass("icon-star-empty").addClass("icon-star");
+ }
+ return false;
+ })
+ }
+
+ var journalview = function(){
+ $("#journal_p div#paper_list div.overview").empty();
+ var column = $(''),
+ counter = 1,
+ li;
+ $.each(journalData,function(i,journal){
+ $.each(journal.papers,function(j,paper){
+ li = $(''+journal.title+'
'+paper.title+'
');
+ column.find("ul").append(li);
+ if(counter%5==0){
+ $("#journal_p div#paper_list div.overview").append(column);
+ column = $('');
+ }
+ counter++;
+ })
+ })
+ $("#journal_p div#paper_list div.overview").append(column);
+ bindSecondaryHandlers();
+ }
+
+ var keywordsview = function(){
+ $("#journal_p div#paper_list div.overview").empty();
+ var column = $(''),
+ counter = 1,
+ li;
+ $.each(journalData,function(i,journal){
+ $.each(journal.papers,function(j,paper){
+ li = $(''+paper.title+'
'+paper.keywords+'
');
+ column.find("ul").append(li);
+ if(counter%5==0){
+ $("#journal_p div#paper_list div.overview").append(column);
+ column = $('');
+ }
+ counter++;
+ })
+ })
+ $("#journal_p div#paper_list div.overview").append(column);
+ bindSecondaryHandlers();
+ }
+
+ var titleview = function(){
+ $("#journal_p div#paper_list div.overview").empty();
+ var column = $(''),
+ counter = 1,
+ li;
+ $.each(journalData,function(i,journal){
+ $.each(journal.papers,function(j,paper){
+ li = $(''+paper.title+'
');
+ column.find("ul").append(li);
+ if(counter%5==0){
+ $("#journal_p div#paper_list div.overview").append(column);
+ column = $('');
+ }
+ counter++;
+ })
+ })
+ $("#journal_p div#paper_list div.overview").append(column);
+ bindSecondaryHandlers();
+ }
+
+ var abstractview = function(){
+ $("#journal_p div#paper_list div.overview").empty();
+ var column = $(''),
+ li;
+ $.each(journalData,function(i,journal){
+ $.each(journal.papers,function(j,paper){
+ li = $(''+paper.title+'
'+paper.abstract+paper.abstract+'
');
+ column.find("ul").append(li);
+ $("#journal_p div#paper_list div.overview").append(column);
+ column = $('');
+ })
+ })
+ $("#journal_p div#paper_list div.overview").append(column);
+ bindSecondaryHandlers();
+ }
+
+ $("div#journal_p div#panel_r").load("/desktop/journal_p_list",function(){
+ $.getJSON("/desktop_publications/getjournals",function(journals){
+ journalData = eval(journals);
+ journalview();
+ bindHandlers();
+ })
+ })
+ }
+
+ var addpaper = function(){ // to open add pages in journal papers page
+ var bindHandlers = function(){ // to bind handlers for add page
+ o.simple_drop_down();
+
+ // fill width for tiny scroll bar
+ var e = $('.s_grid_con'),
+ count = e.length,
+ baseWidth = e.eq(1).outerWidth(true);
+
+ e.parents('.overview').width( baseWidth * count );
+
+
+
+ $('.tinycanvas')
+ .tinyscrollbar({ axis: 'x'})
+ .find('.scrollbar')
+ .delay(1500)
+ .addClass('op00', 500);
+ }
+ $("div#journal_p div#panel_r").load("/desktop/journal_p_add",function(){
+ bindHandlers();
+ })
+ }
+
+ if(!o.desktopData[o.currentface]){
+ $(o.contentHolder).empty().load("/desktop/"+target,function(){
+ bindHandlers();
+ list();
+ });
+ }else{
+ $(o.contentHolder).html(o.desktopData[o.currentface]);
+ bindHandlers();
+ list();
+ }
+ };
+ this.initializeAppstore = function(target){
+ o.currenthtml = target;
+ o.currentface = "appstore";
+ var bindHandlers = function(){
+ $('.s_menu a').on({
+ click: function(){
+ if(!$(this).hasClass('active')){
+ var tfunc = $(this).attr('href');
+ switch(tfunc){
+ case 'widgets':
+ widgets();
+ break;
+ }
+ $('.s_menu a').removeClass('thmc1 thmtxt active');
+ $(this).addClass('thmc1 thmtxt active');
+ }
+ },
+ 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);
+ }
+ });
+ }
+ var 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;
+ });
+ // fill width for tiny scroll bar
+ var e = $('.list_t'),
+ count = e.length,
+ baseWidth = e.eq(1).outerWidth(true);
+
+ e.parents('.overview').width( baseWidth * count );
+
+ $('.tinycanvas')
+ .tinyscrollbar({ axis: 'x'})
+ .find('.scrollbar')
+ .delay(1500)
+ .addClass('op00', 500);
+ }
+ $("div#apps_store div#panel_r").load("/desktop_appstore/widgets",function(){
+
+ $.getJSON("/desktop_appstore/getuserwidgets",function(userwidgets){
+ var column = $(''),
+ 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 = $(''+widge.name+'
Author : '+widge.author+'
Shape : '+shp+'
Status : '+widge.status+'
');
+ 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+= ""+s.name +" ";
+ }
+ })
+ })
+ 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+= ""+sec_name+" ";
+ }
+ })
+ li.find("div.status").html("Status : Installed on "+s_name_list);
+ if(s_name_list_not)
+ li.find("div.not_status").html("Install on "+s_name_list_not);
+ }else{
+ li.find("div.not_status").html("Install on "+o.sectionList[0].name+" "+o.sectionList[1].name+" "+o.sectionList[2].name+" "+o.sectionList[3].name)+" ";
+ }
+ //console.log(section_names);
+ column.find("ul").append(li);
+ if(counter%4==0){
+ $("#apps_store div#widget_list").append(column);
+ column = $('');
+ }
+ counter++;
+ })
+ $("#apps_store div#widget_list").append(column);
+ bindHandlers();
+ })
+ })
+ }
+
+ if(!o.desktopData[o.currentface]){
+ $(o.contentHolder).empty().load("/desktop_appstore/"+target,function(){
+ widgets();
+ bindHandlers();
+ });
+ }else{
+ $(o.contentHolder).html(o.desktopData[o.currentface]);
+ widgets();
+ bindHandlers();
+ }
+ }
+ this.initializeBooks = function(target){
+ o.currenthtml = target;
+ o.currentface = "books";
+ var bindHandlers = function(){
+ $('.s_menu a').on({
+ click: function(){
+ if(!$(this).hasClass('active')){
+ var tfunc = $(this).attr('href');
+ switch(tfunc){
+ case 'list':
+ list();
+ break;
+ case 'addbook':
+ addbook();
+ break;
+ }
+ $('.s_menu a').removeClass('thmc1 thmtxt active');
+ $(this).addClass('thmc1 thmtxt active');
+ }
+ },
+ 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);
+ }
+ });
+ }
+
+ var list = function(){
+ var bindHandlers = function(){
+
+ }
+
+ $("div#books div#panel_r").load("/desktop/books_list",function(){
+ bindHandlers();
+ })
+ }
+
+ var addbook = function(){
+ var bindHandlers = function(){
+
+ }
+
+ $("div#books div#panel_r").load("/desktop/books_add",function(){
+ bindHandlers();
+ })
+ }
+ if(!o.desktopData[o.currentface]){
+ $(o.contentHolder).empty().load("/desktop/"+target,function(){
+ list();
+ bindHandlers();
+ });
+ }else{
+ $(o.contentHolder).html(o.desktopData[o.currentface]);
+ list();
+ bindHandlers();
+ }
+ }
+ this.loadWallpaper = function(wallpaper){ // this is to load new wallpaper
+ if(!wallpaper)wallpapernm = o.themesettings.background;else wallpapernm = wallpaper
+ var ww = $(window).width();
+ var wh = $(window).height();
+ if(!wallpaper)
+ $("img#thmbackground").attr({"src":"/"+o.themefolder+"/"+o.theme+"/images/"+wallpapernm,"width":ww}).css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","height":"auto"});
+ else
+ $("img#thmbackground").attr({"src":o.wallpaperPath+wallpaper,"width":ww}).css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","height":"auto"});
+
+ $("div#bgover").css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","width":ww,"height":wh});
+ };
+
+ this.loadIconCache = function(){ // this function load or refresh icon cache for the theme
+ var imgs = $("ul.docklist img");
+ $.each(imgs,function(){
+ var setting_name = $(this).attr("id").replace("_icon","");
+ $(this).attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons[setting_name])
+ })
+ };
+ this.initializeWidgets = function(){ // this function will initialize all the widgets in the desktop
+ var elements = $("#group_wrapper li.element");
+ $.each(elements,function(){
+ var widget = $(this);
+ if(widget.attr("data-category")=="widget"){
+ var widgename = widget.attr("data-content");
+ $.getScript("/desktop_widgets/"+widgename+"/"+widgename+".js",function(){
+ widget.find("div.appholder").load("/desktop_widgets/"+widgename+"/index.html.erb");
+ });
+ // $(this).find("div.appholder").append( $(' ').attr('href', "/desktop_widgets/"+widgename+"/css/"+widgename+".css"));
+ }
+
+ })
+ };
+ 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.simple_drop_down = function(){
+ // simple dropdown menu
+ if( !$('.sdm').children('.sdm_o').length > 0 ){
+ return;
+ } else {
+ $('.sdm').hover(function(){
+ $(this).stop(1,1).toggleClass('thmc2 thmtxt');
+ }, function(){
+ $(this).stop(1,1).toggleClass('thmc2 thmtxt');
+ });
+ $('.sdm').find('a').hover(function(){
+ $(this).stop(1,1).toggleClass('thmc2 thmtxt');
+ }, function(){
+ $(this).stop(1,1).toggleClass('thmc2 thmtxt');
+ });
+ }
+ }
+ o.initialize();
+}
+
+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(){
+ $.post("/desktop/temp_func",{sectionid:"4f83e7bbbd98eb041600001d"});
+}
diff --git a/app/controllers/desktop_publications_controller.rb b/app/controllers/desktop_publications_controller.rb
index 4f30ebde6..f0cbb808e 100644
--- a/app/controllers/desktop_publications_controller.rb
+++ b/app/controllers/desktop_publications_controller.rb
@@ -1,30 +1,42 @@
-class DesktopPublicationsController< ApplicationController
- def journal_p
- render "desktop/journal_p", :layout => false
- end
-
- def journal_p_list
- render "desktop/journal_pages/list", :layout => false
- end
-
- def journal_p_add
- render "desktop/journal_pages/add", :layout => false
- end
-
- def create_journal
- Journal.create(user_id: current_user.id, title: "2012, Javascript")
- b = Array.new
- b << {"success"=>"true"}
- render :json=>b.to_json
- end
-
- def getjournals
- @journals = current_user.journals
- data = Array.new
- @journals.each do |journal|
- @papers = journal.papers.all
- data << {"title" => journal.title, "papers" => @papers}
- end
- render :json=>data.to_json
- end
-end
+class DesktopPublicationsController< ApplicationController
+ def journal_p
+ render "desktop/journal_p", :layout => false
+ end
+
+ def journal_p_list
+ render "desktop/journal_pages/list", :layout => false
+ end
+
+ def journal_p_add
+ render "desktop/journal_pages/add", :layout => false
+ end
+
+ def books
+ render "desktop/books", :layout => false
+ end
+
+ def books_list
+ render "desktop/books/list", :layout => false
+ end
+
+ def books_add
+ render "desktop/books/add", :layout => false
+ end
+
+ def create_journal
+ Journal.create(user_id: current_user.id, title: "2012, Javascript")
+ b = Array.new
+ b << {"success"=>"true"}
+ render :json=>b.to_json
+ end
+
+ def getjournals
+ @journals = current_user.journals
+ data = Array.new
+ @journals.each do |journal|
+ @papers = journal.papers.all
+ data << {"title" => journal.title, "papers" => @papers}
+ end
+ render :json=>data.to_json
+ end
+end
diff --git a/app/views/desktop/books.html.erb b/app/views/desktop/books.html.erb
new file mode 100644
index 000000000..861a9926c
--- /dev/null
+++ b/app/views/desktop/books.html.erb
@@ -0,0 +1,33 @@
+
+
\ No newline at end of file
diff --git a/app/views/desktop/books/add.html.erb b/app/views/desktop/books/add.html.erb
new file mode 100644
index 000000000..764f293ef
--- /dev/null
+++ b/app/views/desktop/books/add.html.erb
@@ -0,0 +1,87 @@
+
+
\ No newline at end of file
diff --git a/app/views/desktop/books/list.html.erb b/app/views/desktop/books/list.html.erb
new file mode 100644
index 000000000..30fc4f60c
--- /dev/null
+++ b/app/views/desktop/books/list.html.erb
@@ -0,0 +1,75 @@
+
+
\ No newline at end of file
diff --git a/app/views/desktop/books/seminar.html.erb b/app/views/desktop/books/seminar.html.erb
new file mode 100644
index 000000000..cea6c091d
--- /dev/null
+++ b/app/views/desktop/books/seminar.html.erb
@@ -0,0 +1 @@
+this is seminar page.
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index cfdfadc2b..56f371fbf 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,197 +1,201 @@
-Orbit::Application.routes.draw do
-
- devise_for :users
-
- # routes for sinatra app
- match '/site/set_registered', :to => CentralServerExchangeApp
- match '/site/public_key', :to => CentralServerExchangeApp
- match '/site/update', :to => GithubApp
- match '/purchase/:type', :to => CentralServerExchangeApp
-
- match 'load_orbit_bar' => 'pages#load_orbit_bar'
-
- # routes for admin
- namespace :admin do
- resources :assets
- resources :app_auths
- resources :object_auths do
- collection do
- match 'new/:type/:obj_id',:action => 'new',:via => "get",:as => :init
- end
- member do
- match ':id/create_role',:action => 'create_role',:via => "post",:as => :create_role
- match 'remove/:type/:target_id' ,:action=> 'remove_role',:via => "delete",:as =>:remove
- end
- end
-
-
- resources :ad_banners do
- collection do
- match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get
- match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post
- end
- resources :ad_images ,:except => [:show,:index]
- end
- resources :dashboards
- resources :designs do
- collection do
- get 'upload_package'
- post 'upload_package'
- end
- member do
- post 'edit_file' => 'designs#edit_file'
- end
- end
- resources :infos do
- get 'add_attribute_field'
- end
- resources :items
- resources :links do
- member do
- get 'delete'
- end
- end
- resources :pages do
- member do
- get 'delete'
- get 'reload_themes'
- end
- end
- resources :module_apps do
- resources :app_auths do
- member do
- match 'remove/:type/:target_id' ,:action=> 'remove',:via => "delete",:as =>:remove
- end
- end
-
- member do
- match 'assign_manager' ,:action=> 'assign_manager',:via => "post",:as =>:assign_manager
- match 'assign_sub_manager' ,:action=> 'assign_sub_manager',:via => "post",:as =>:assign_sub_manager
-
- match 'remove_manager/:app_manager_id' ,:action=> 'remove_manager',:via => "delete",:as =>:remove_manager
- match 'remove_sub_manager/:app_sub_manager_id' ,:action=> 'remove_sub_manager',:via => "delete",:as =>:remove_sub_manager
- get 'reload_frontend_pages'
- end
- end
- resources :page_parts do
- member do
- get 'reload_widgets'
- end
- end
- resources :purchases do
- collection do
- get 'install_app'
- end
- member do
- get 'download'
- end
- end
- resources :roles do
- get 'add_sub_role'
- get 'add_attribute_field'
- end
- resources :sites
- resources :snippets
- resources :tags
- resources :translations
- resources :users
- end
- # end admin
-
- namespace :panel do
- resources :users
- end
-
- match '/desktop/'=>'desktop#index'
-
- # Sinatra Routes start
-
- # match '/desktop/desktop', :to => Desktopapp::DesktopApp
- # match '/desktop/app_manager', :to => Desktopapp::DesktopApp
- # match '/desktop/sections', :to => Desktopapp::DesktopApp
- # match '/desktop/settings', :to => Desktopapp::DesktopApp
- # match '/desktop/get_desktop_settings/', :to => Desktopapp::DesktopApp
- # match '/desktop/save_desktop_settings/', :to => Desktopapp::DesktopApp
- # match '/desktop/getgroups/', :to => Desktopapp::DesktopApp
- # match '/desktop/getsectionlist/', :to => Desktopapp::DesktopApp
- # match '/desktop/settingthemes/', :to => Desktopapp::DesktopApp
- # match '/desktop/settingsections/', :to => Desktopapp::DesktopApp
- # match '/desktop/getapplist/', :to => Desktopapp::DesktopApp
- # match '/desktop/newpositions/', :to => Desktopapp::DesktopApp
- # match '/desktop/settingconnection/', :to => Desktopapp::DesktopApp
-
- # match '/desktop/journal_p/', :to => Desktopapp::DesktopAppPublications
- # match '/desktop/journal_p_list/', :to => Desktopapp::DesktopAppPublications
- # match '/desktop/journal_p_add/', :to => Desktopapp::DesktopAppPublications
- # match '/desktop_publications/getjournals', :to => Desktopapp::DesktopAppPublications
-
- # match '/desktop/twitter/', :to => Desktopapp::Otheraccounts
- # match '/desktop/forgmail/', :to => Desktopapp::Otheraccounts
- # match '/desktop/getaccounts', :to => Desktopapp::Otheraccounts
- # match '/desktop/save_account_info/', :to => Desktopapp::Otheraccounts
-
- # match '/desktop_appstore/appstore', :to => Desktopapp::DesktopAppAppstore
- # match '/desktop_appstore/widgets', :to => Desktopapp::DesktopAppAppstore
- # match '/desktop_appstore/getuserwidgets', :to => Desktopapp::DesktopAppAppstore
- # match '/desktop_appstore/widgets_settings', :to => Desktopapp::DesktopAppAppstore
-
- # Sinatra Routes end
-
- match '/desktop/desktop'=>'desktop#desktop'
- match '/desktop/app_manager'=>'desktop#app_manager'
- match '/desktop/sections'=>'desktop#sections'
- match '/desktop/settings'=>'desktop#settings'
- match '/desktop/get_desktop_settings/'=>'desktop#get_desktop_settings'
- match '/desktop/save_desktop_settings/'=>'desktop#save_desktop_settings'
- match '/desktop/getgroups/'=>'desktop#getgroups'
- match '/desktop/getsectionlist/'=>'desktop#getsectionlist'
- match '/desktop/settingthemes/'=>'desktop#settingthemes'
- match '/desktop/settingsections/'=>'desktop#settingsections'
- match '/desktop/getapplist/'=>'desktop#getapplist'
- match '/desktop/newpositions/'=>'desktop#newpositions'
- match '/desktop/settingconnection/'=>'desktop#settingconnection'
-
-
- match '/desktop/journal_p/'=>'desktop_publications#journal_p'
- match '/desktop/journal_p_list/'=>'desktop_publications#journal_p_list'
- match '/desktop/journal_p_add/'=>'desktop_publications#journal_p_add'
- match '/desktop_publications/getjournals' => 'desktop_publications#getjournals'
-
- match '/desktop/twitter/'=>'otheraccounts#twitter'
- match '/desktop/forgmail/'=>'otheraccounts#gmail'
- match '/desktop/getaccounts'=>'otheraccounts#getaccounts'
- match '/desktop/save_account_info/'=>'otheraccounts#saveaccountinfo'
-
- match '/desktop_appstore/appstore'=>'desktop_appstore#appstore'
- match '/desktop_appstore/widgets'=>'desktop_appstore#widgets'
- match '/desktop_appstore/getuserwidgets'=>'desktop_appstore#getuserwidgets'
- match '/desktop_appstore/widgets_settings'=>'desktop_appstore#widgets_settings'
-
- match '/desktop_orbit/orbit' => 'desktop_orbit#orbit'
- match '/desktop_orbit/getevents' => 'desktop_orbit#getevents'
- #match '/desktop_orbit/getevents' => 'desktop_publications#create_journal'
-
- match '/desktop/temp_func/'=>'desktop#temp_func'
-
- match '/panel/:app_name/front_end/:app_action/:id' => 'pages#show_from_link', :constraints => lambda { |request|
- !request.query_string.include?("inner=true")
- }
-
- match '/panel/:app_name/front_end/:app_action' => 'pages#index_from_link', :constraints => lambda { |request|
- !request.query_string.include?("inner=true")
- }
-
- # routes for gridfs files
- match "/gridfs/*path" => "gridfs#serve"
- # match "/images/*path" => "gridfs#serve_images"
- # match "/admin/pages/images/*path" => "gridfs#serve_images"
-
- # routes for pages to generate
- match '*page_name' => 'pages#show', :as => :page, :constraints => lambda{|request|
- !request.path.starts_with?("/panel")
- }
-
- root :to => 'pages#index'
-
-end
-
+Orbit::Application.routes.draw do
+
+ devise_for :users
+
+ # routes for sinatra app
+ match '/site/set_registered', :to => CentralServerExchangeApp
+ match '/site/public_key', :to => CentralServerExchangeApp
+ match '/site/update', :to => GithubApp
+ match '/purchase/:type', :to => CentralServerExchangeApp
+
+ match 'load_orbit_bar' => 'pages#load_orbit_bar'
+
+ # routes for admin
+ namespace :admin do
+ resources :assets
+ resources :app_auths
+ resources :object_auths do
+ collection do
+ match 'new/:type/:obj_id',:action => 'new',:via => "get",:as => :init
+ end
+ member do
+ match ':id/create_role',:action => 'create_role',:via => "post",:as => :create_role
+ match 'remove/:type/:target_id' ,:action=> 'remove_role',:via => "delete",:as =>:remove
+ end
+ end
+
+
+ resources :ad_banners do
+ collection do
+ match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get
+ match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post
+ end
+ resources :ad_images ,:except => [:show,:index]
+ end
+ resources :dashboards
+ resources :designs do
+ collection do
+ get 'upload_package'
+ post 'upload_package'
+ end
+ member do
+ post 'edit_file' => 'designs#edit_file'
+ end
+ end
+ resources :infos do
+ get 'add_attribute_field'
+ end
+ resources :items
+ resources :links do
+ member do
+ get 'delete'
+ end
+ end
+ resources :pages do
+ member do
+ get 'delete'
+ get 'reload_themes'
+ end
+ end
+ resources :module_apps do
+ resources :app_auths do
+ member do
+ match 'remove/:type/:target_id' ,:action=> 'remove',:via => "delete",:as =>:remove
+ end
+ end
+
+ member do
+ match 'assign_manager' ,:action=> 'assign_manager',:via => "post",:as =>:assign_manager
+ match 'assign_sub_manager' ,:action=> 'assign_sub_manager',:via => "post",:as =>:assign_sub_manager
+
+ match 'remove_manager/:app_manager_id' ,:action=> 'remove_manager',:via => "delete",:as =>:remove_manager
+ match 'remove_sub_manager/:app_sub_manager_id' ,:action=> 'remove_sub_manager',:via => "delete",:as =>:remove_sub_manager
+ get 'reload_frontend_pages'
+ end
+ end
+ resources :page_parts do
+ member do
+ get 'reload_widgets'
+ end
+ end
+ resources :purchases do
+ collection do
+ get 'install_app'
+ end
+ member do
+ get 'download'
+ end
+ end
+ resources :roles do
+ get 'add_sub_role'
+ get 'add_attribute_field'
+ end
+ resources :sites
+ resources :snippets
+ resources :tags
+ resources :translations
+ resources :users
+ end
+ # end admin
+
+ namespace :panel do
+ resources :users
+ end
+
+ match '/desktop/'=>'desktop#index'
+
+ # Sinatra Routes start
+
+ # match '/desktop/desktop', :to => Desktopapp::DesktopApp
+ # match '/desktop/app_manager', :to => Desktopapp::DesktopApp
+ # match '/desktop/sections', :to => Desktopapp::DesktopApp
+ # match '/desktop/settings', :to => Desktopapp::DesktopApp
+ # match '/desktop/get_desktop_settings/', :to => Desktopapp::DesktopApp
+ # match '/desktop/save_desktop_settings/', :to => Desktopapp::DesktopApp
+ # match '/desktop/getgroups/', :to => Desktopapp::DesktopApp
+ # match '/desktop/getsectionlist/', :to => Desktopapp::DesktopApp
+ # match '/desktop/settingthemes/', :to => Desktopapp::DesktopApp
+ # match '/desktop/settingsections/', :to => Desktopapp::DesktopApp
+ # match '/desktop/getapplist/', :to => Desktopapp::DesktopApp
+ # match '/desktop/newpositions/', :to => Desktopapp::DesktopApp
+ # match '/desktop/settingconnection/', :to => Desktopapp::DesktopApp
+
+ # match '/desktop/journal_p/', :to => Desktopapp::DesktopAppPublications
+ # match '/desktop/journal_p_list/', :to => Desktopapp::DesktopAppPublications
+ # match '/desktop/journal_p_add/', :to => Desktopapp::DesktopAppPublications
+ # match '/desktop_publications/getjournals', :to => Desktopapp::DesktopAppPublications
+
+ # match '/desktop/twitter/', :to => Desktopapp::Otheraccounts
+ # match '/desktop/forgmail/', :to => Desktopapp::Otheraccounts
+ # match '/desktop/getaccounts', :to => Desktopapp::Otheraccounts
+ # match '/desktop/save_account_info/', :to => Desktopapp::Otheraccounts
+
+ # match '/desktop_appstore/appstore', :to => Desktopapp::DesktopAppAppstore
+ # match '/desktop_appstore/widgets', :to => Desktopapp::DesktopAppAppstore
+ # match '/desktop_appstore/getuserwidgets', :to => Desktopapp::DesktopAppAppstore
+ # match '/desktop_appstore/widgets_settings', :to => Desktopapp::DesktopAppAppstore
+
+ # Sinatra Routes end
+
+ match '/desktop/desktop'=>'desktop#desktop'
+ match '/desktop/app_manager'=>'desktop#app_manager'
+ match '/desktop/sections'=>'desktop#sections'
+ match '/desktop/settings'=>'desktop#settings'
+ match '/desktop/get_desktop_settings/'=>'desktop#get_desktop_settings'
+ match '/desktop/save_desktop_settings/'=>'desktop#save_desktop_settings'
+ match '/desktop/getgroups/'=>'desktop#getgroups'
+ match '/desktop/getsectionlist/'=>'desktop#getsectionlist'
+ match '/desktop/settingthemes/'=>'desktop#settingthemes'
+ match '/desktop/settingsections/'=>'desktop#settingsections'
+ match '/desktop/getapplist/'=>'desktop#getapplist'
+ match '/desktop/newpositions/'=>'desktop#newpositions'
+ match '/desktop/settingconnection/'=>'desktop#settingconnection'
+
+
+ match '/desktop/journal_p/'=>'desktop_publications#journal_p'
+ match '/desktop/journal_p_list/'=>'desktop_publications#journal_p_list'
+ match '/desktop/journal_p_add/'=>'desktop_publications#journal_p_add'
+ match '/desktop_publications/getjournals' => 'desktop_publications#getjournals'
+ match '/desktop/books' => 'desktop_publications#books'
+ match '/desktop/books_list/'=>'desktop_publications#books_list'
+ match '/desktop/books_add/'=>'desktop_publications#books_add'
+
+
+ match '/desktop/twitter/'=>'otheraccounts#twitter'
+ match '/desktop/forgmail/'=>'otheraccounts#gmail'
+ match '/desktop/getaccounts'=>'otheraccounts#getaccounts'
+ match '/desktop/save_account_info/'=>'otheraccounts#saveaccountinfo'
+
+ match '/desktop_appstore/appstore'=>'desktop_appstore#appstore'
+ match '/desktop_appstore/widgets'=>'desktop_appstore#widgets'
+ match '/desktop_appstore/getuserwidgets'=>'desktop_appstore#getuserwidgets'
+ match '/desktop_appstore/widgets_settings'=>'desktop_appstore#widgets_settings'
+
+ match '/desktop_orbit/orbit' => 'desktop_orbit#orbit'
+ match '/desktop_orbit/getevents' => 'desktop_orbit#getevents'
+ #match '/desktop_orbit/getevents' => 'desktop_publications#create_journal'
+
+ match '/desktop/temp_func/'=>'desktop#temp_func'
+
+ match '/panel/:app_name/front_end/:app_action/:id' => 'pages#show_from_link', :constraints => lambda { |request|
+ !request.query_string.include?("inner=true")
+ }
+
+ match '/panel/:app_name/front_end/:app_action' => 'pages#index_from_link', :constraints => lambda { |request|
+ !request.query_string.include?("inner=true")
+ }
+
+ # routes for gridfs files
+ match "/gridfs/*path" => "gridfs#serve"
+ # match "/images/*path" => "gridfs#serve_images"
+ # match "/admin/pages/images/*path" => "gridfs#serve_images"
+
+ # routes for pages to generate
+ match '*page_name' => 'pages#show', :as => :page, :constraints => lambda{|request|
+ !request.path.starts_with?("/panel")
+ }
+
+ root :to => 'pages#index'
+
+end
+