mindapp 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/generators/mindapp/USAGE +8 -0
- data/lib/generators/mindapp/install_generator.rb +134 -0
- data/lib/generators/mindapp/templates/app/assets/images/account.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/add.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/ajax-loader-circle.gif +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/ajax-loader.gif +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/anchor.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/application_double.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/application_form_edit.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/arrow_left.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/arrow_right.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/arrow_turn_left.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/arrow_turn_right.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/calendar.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/cancel.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/chart_bar.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/clock.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/cog.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/control_fastforward.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/control_play.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/cross.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/delete.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/external-link.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/help.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/house.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/logo_mindapp.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/logout.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/new.gif +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/new.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/page.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/page_attach.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/page_green.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/page_output.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/page_pdf.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/pencil.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/printer.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/refresh.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/report.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/rssmall.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/tick.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/user.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/view_code.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/application.js +19 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/disable_enter_key.js +10 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/iscroll-wrapper.js +32 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/iscroll.js +1084 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/jquery-1.7.1.js +9266 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/jquery.mobile.datebox.js +1772 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/jquery.mobile.js +7007 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/jquery.mobile.splitview.js +624 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/mindapp.js +14 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/application.css.scss +18 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun.eot +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun.ttf +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun.woff +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun_bold.ttf +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun_bolditalic.ttf +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun_italic.ttf +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.eot +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.ttf +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.woff +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew.css +47 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.eot +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.ttf +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.woff +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.eot +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.ttf +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.woff +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.eot +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.ttf +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.woff +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ajax-loader.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/bg.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/button_black.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/button_blue.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/button_red.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/cancel.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/close.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/del2.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/deli4.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/down-left.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/down-right.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/fbook.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ff.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/icon-search-black.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-18-black.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-18-white.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-36-black.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-36-white.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/overlay.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/rss3.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/rss4.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/search_bg.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/stumble2.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/stumble4.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/tab-left.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/tab-right.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/tech3.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/tech4.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/twitter3.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/twitter4.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-anim_basic_16x16.gif +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_217bc0_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_222222_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_454545_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_469bdd_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_6da8d5_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_888888_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_d8e7f3_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_f9bd01_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/indicator.gif +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/jquery.mobile.css +1855 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/jquery.mobile.datebox.css +65 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/jquery.mobile.grids.collapsible.css +122 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/jquery.mobile.splitview.css +130 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/mindapp.css +134 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/sarabun.css +37 -0
- data/lib/generators/mindapp/templates/app/controllers/identities_controller.rb +5 -0
- data/lib/generators/mindapp/templates/app/controllers/mindapp_controller.rb +464 -0
- data/lib/generators/mindapp/templates/app/controllers/sessions_controller.rb +28 -0
- data/lib/generators/mindapp/templates/app/mailers/.gitkeep +0 -0
- data/lib/generators/mindapp/templates/app/mailers/mindapp_mailer.rb +7 -0
- data/lib/generators/mindapp/templates/app/mindapp/index.mm +85 -0
- data/lib/generators/mindapp/templates/app/mindapp/template/view.html.erb +21 -0
- data/lib/generators/mindapp/templates/app/models/.gitkeep +0 -0
- data/lib/generators/mindapp/templates/app/models/identity.rb +14 -0
- data/lib/generators/mindapp/templates/app/models/mindapp/doc.rb +30 -0
- data/lib/generators/mindapp/templates/app/models/mindapp/module.rb +10 -0
- data/lib/generators/mindapp/templates/app/models/mindapp/notice.rb +11 -0
- data/lib/generators/mindapp/templates/app/models/mindapp/role.rb +7 -0
- data/lib/generators/mindapp/templates/app/models/mindapp/runseq.rb +24 -0
- data/lib/generators/mindapp/templates/app/models/mindapp/service.rb +16 -0
- data/lib/generators/mindapp/templates/app/models/mindapp/xmain.rb +38 -0
- data/lib/generators/mindapp/templates/app/models/param.rb +41 -0
- data/lib/generators/mindapp/templates/app/models/user.rb +30 -0
- data/lib/generators/mindapp/templates/app/views/identities/new.html.erb +30 -0
- data/lib/generators/mindapp/templates/app/views/layouts/_full.haml +39 -0
- data/lib/generators/mindapp/templates/app/views/layouts/_head.html.erb +14 -0
- data/lib/generators/mindapp/templates/app/views/layouts/_page.haml +16 -0
- data/lib/generators/mindapp/templates/app/views/layouts/_top.html.erb +10 -0
- data/lib/generators/mindapp/templates/app/views/layouts/application.haml +4 -0
- data/lib/generators/mindapp/templates/app/views/layouts/gmail.html.erb +9 -0
- data/lib/generators/mindapp/templates/app/views/layouts/mobile.html.erb +13 -0
- data/lib/generators/mindapp/templates/app/views/layouts/mobilejq.html.erb +31 -0
- data/lib/generators/mindapp/templates/app/views/layouts/print.html.erb +22 -0
- data/lib/generators/mindapp/templates/app/views/layouts/utf8.html.erb +21 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_activity.md +10 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_menu.haml +22 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_menu_mm.haml +30 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_model.md +5 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_modul.md +9 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_pending_home.haml +5 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_pending_page.haml +26 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_service.md +24 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_static.haml +23 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/doc.md +37 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/feed.rss.builder +27 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/help.haml +20 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/index.html.haml +34 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/pending.haml +1 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/run_form.haml +37 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/search.haml +20 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/status.haml +61 -0
- data/lib/generators/mindapp/templates/app/views/mindapp_mailer/gmail.html.erb +9 -0
- data/lib/generators/mindapp/templates/app/views/sessions/new.html.erb +11 -0
- data/lib/generators/mindapp/templates/mindapp.yml +10 -0
- data/lib/generators/mindapp/templates/seeds.rb +6 -0
- data/lib/mindapp.rb +6 -0
- data/lib/mindapp/helpers.rb +475 -0
- data/lib/mindapp/railtie.rb +18 -0
- data/lib/mindapp/version.rb +3 -0
- data/lib/tasks/mindapp.rake +191 -0
- data/mindapp.gemspec +19 -0
- metadata +239 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 songrit
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Mindapp
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'mindapp'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install mindapp
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,134 @@
|
|
1
|
+
module Mindapp
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
desc "Install mindapp component to existing Rails app "
|
5
|
+
def self.source_root
|
6
|
+
File.dirname(__FILE__) + "/templates"
|
7
|
+
end
|
8
|
+
def setup_gems
|
9
|
+
gem "nokogiri" # use for mindapp/doc
|
10
|
+
# gem "rmagick", :require => "RMagick", :platform => "ruby"
|
11
|
+
gem 'haml-rails'
|
12
|
+
gem "mail"
|
13
|
+
gem "prawn"
|
14
|
+
# bug in mongo ruby driver 1.6.1, wait for mongoid 2.4.7
|
15
|
+
gem "mongo", "1.5.1"
|
16
|
+
gem "bson_ext", "1.5.1"
|
17
|
+
gem "mongoid"
|
18
|
+
gem "redcarpet"
|
19
|
+
gem 'bcrypt-ruby', '~> 3.0.0'
|
20
|
+
gem 'omniauth-identity'
|
21
|
+
gem 'cloudinary'
|
22
|
+
gem_group :development, :test do
|
23
|
+
gem "debugger"
|
24
|
+
gem "rspec"
|
25
|
+
gem "rspec-rails"
|
26
|
+
gem "better_errors"
|
27
|
+
gem "binding_of_caller"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def setup_routes
|
32
|
+
route "root :to => 'mindapp#index'"
|
33
|
+
# route "match '/mindapp/init/:module/:service(/:id)' => 'Mindapp#init'"
|
34
|
+
|
35
|
+
route "resources :identities"
|
36
|
+
route "resources :sessions"
|
37
|
+
route "match '/auth/:provider/callback' => 'sessions#create'"
|
38
|
+
route "match '/auth/failure' => 'sessions#failure'"
|
39
|
+
route "match '/logout' => 'sessions#destroy', :as => 'logout'"
|
40
|
+
route "match ':controller(/:action(/:id))(.:format)'"
|
41
|
+
end
|
42
|
+
|
43
|
+
def setup_env
|
44
|
+
create_file 'README.md', ''
|
45
|
+
run "bundle install"
|
46
|
+
generate "mongoid:config"
|
47
|
+
generate "rspec:install"
|
48
|
+
inject_into_file 'config/application.rb', :after => 'require "active_resource/railtie"' do
|
49
|
+
"\nrequire 'mongoid/railtie'\n"
|
50
|
+
"\nrequire 'rexml/document'\n"
|
51
|
+
end
|
52
|
+
application do
|
53
|
+
%q{
|
54
|
+
# Mindapp default
|
55
|
+
config.generators do |g|
|
56
|
+
g.orm :mongoid
|
57
|
+
g.template_engine :haml
|
58
|
+
g.test_framework :rspec
|
59
|
+
g.integration_tool :rspec
|
60
|
+
end
|
61
|
+
# gmail config
|
62
|
+
config.action_mailer.delivery_method = :smtp
|
63
|
+
config.action_mailer.smtp_settings = {
|
64
|
+
:address => "smtp.gmail.com",
|
65
|
+
:port => 587,
|
66
|
+
:user_name => 'user@gmail.com',
|
67
|
+
:password => 'secret',
|
68
|
+
:authentication => 'plain',
|
69
|
+
:enable_starttls_auto => true }
|
70
|
+
config.action_mailer.raise_delivery_errors = true
|
71
|
+
config.action_mailer.perform_deliveries = true
|
72
|
+
}
|
73
|
+
end
|
74
|
+
initializer "mindapp.rb" do
|
75
|
+
%q{# encoding: utf-8
|
76
|
+
|
77
|
+
DEFAULT_TITLE = 'Mindapp'
|
78
|
+
DEFAULT_HEADER = 'Mindapp'
|
79
|
+
GMAP = true
|
80
|
+
NEXT = "Next >"
|
81
|
+
# unset IMAGE_LOCATION to use cloudinary
|
82
|
+
# IMAGE_LOCATION = "upload"
|
83
|
+
# for debugging
|
84
|
+
# DONT_SEND_MAIL = true
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
inject_into_file 'config/environment.rb', :after => "initialize!" do
|
89
|
+
"\n\n# hack to fix cloudinary error https://github.com/archiloque/rest-client/issues/141" +
|
90
|
+
"\nclass Hash\n remove_method :read\nrescue\nend"
|
91
|
+
end
|
92
|
+
inject_into_file 'config/environments/development.rb', :after => 'config.action_mailer.raise_delivery_errors = false' do
|
93
|
+
"\n config.action_mailer.default_url_options = { :host => 'localhost:3000' }"
|
94
|
+
end
|
95
|
+
inject_into_file 'config/environments/production.rb', :after => 'config.assets.compile = false' do
|
96
|
+
"\n config.assets.compile = true"
|
97
|
+
end
|
98
|
+
inject_into_file 'config/mongoid.yml', :after => ' # raise_not_found_error: true' do
|
99
|
+
"\n raise_not_found_error: false"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def setup_omniauth
|
104
|
+
# gem 'bcrypt-ruby', '~> 3.0.0'
|
105
|
+
# gem 'omniauth-identity'
|
106
|
+
initializer "omniauth.rb" do
|
107
|
+
%q{
|
108
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
109
|
+
provider :identity,
|
110
|
+
:fields => [:code, :email],
|
111
|
+
:on_failed_registration=> lambda { |env|
|
112
|
+
IdentitiesController.action(:new).call(env)
|
113
|
+
}
|
114
|
+
end
|
115
|
+
}
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def setup_app
|
120
|
+
inside("public") { run "mv index.html index.html.bak" }
|
121
|
+
inside("app/views/layouts") { run "mv application.html.erb application.html.erb.bak" }
|
122
|
+
inside("app/assets/javascripts") { run "mv application.js application.js.bak" }
|
123
|
+
inside("app/assets/stylesheets") { run "mv application.css application.css.bak" }
|
124
|
+
directory "app"
|
125
|
+
end
|
126
|
+
def gen_user
|
127
|
+
copy_file "seeds.rb","db/seeds.rb"
|
128
|
+
end
|
129
|
+
def gen_sample_cloudinary
|
130
|
+
copy_file "cloudinary.yml","config/cloudinary.yml"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,19 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery-1.7.1
|
14
|
+
//= require jquery.mobile.splitview
|
15
|
+
//= require jquery.mobile
|
16
|
+
//= require iscroll-wrapper
|
17
|
+
//= require iscroll
|
18
|
+
//= require mindapp
|
19
|
+
//= require jquery.mobile.datebox
|
@@ -0,0 +1,10 @@
|
|
1
|
+
$(function() {
|
2
|
+
$("input").keypress(function (evt) {
|
3
|
+
//Deterime where our character code is coming from within the event
|
4
|
+
var charCode = evt.charCode || evt.keyCode;
|
5
|
+
if (charCode == 13) { //Enter key's keycode
|
6
|
+
alert("กรุณาใช้เม้าส์คลิ้กที่ปุ่มเพื่อดำเนินการต่อ");
|
7
|
+
return false;
|
8
|
+
}
|
9
|
+
});
|
10
|
+
})
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/*
|
2
|
+
* iscroll-wrapper for jQquery.
|
3
|
+
* http://sanraul.com/projects/jqloader/
|
4
|
+
*
|
5
|
+
* Copyright (c) 2011 Raul Sanchez (http://www.sanraul.com)
|
6
|
+
*
|
7
|
+
* Dual licensed under the MIT and GPL licenses:
|
8
|
+
* http://www.opensource.org/licenses/mit-license.php
|
9
|
+
* http://www.gnu.org/licenses/gpl.html
|
10
|
+
*/
|
11
|
+
|
12
|
+
(function($){
|
13
|
+
$.fn.iscroll = function(options){
|
14
|
+
if(this.data('iScrollReady') == null){
|
15
|
+
var that = this;
|
16
|
+
var options = $.extend({}, options);
|
17
|
+
options.onScrollEnd = function(){
|
18
|
+
that.triggerHandler('onScrollEnd', [this]);
|
19
|
+
};
|
20
|
+
arguments.callee.object = new iScroll(this.get(0), options);
|
21
|
+
// NOTE: for some reason in a complex page the plugin does not register
|
22
|
+
// the size of the element. This will fix that in the meantime.
|
23
|
+
setTimeout(function(scroller){
|
24
|
+
scroller.refresh();
|
25
|
+
}, 1000, arguments.callee.object);
|
26
|
+
this.data('iScrollReady', true);
|
27
|
+
}else{
|
28
|
+
arguments.callee.object.refresh();
|
29
|
+
}
|
30
|
+
return arguments.callee.object;
|
31
|
+
};
|
32
|
+
})(jQuery);
|
@@ -0,0 +1,1084 @@
|
|
1
|
+
/*!
|
2
|
+
* iScroll v4.1.9 ~ Copyright (c) 2011 Matteo Spinelli, http://cubiq.org
|
3
|
+
* Released under MIT license, http://cubiq.org/license
|
4
|
+
*/
|
5
|
+
(function(){
|
6
|
+
var m = Math,
|
7
|
+
mround = function (r) { return r >> 0; },
|
8
|
+
vendor = (/webkit/i).test(navigator.appVersion) ? 'webkit' :
|
9
|
+
(/firefox/i).test(navigator.userAgent) ? 'Moz' :
|
10
|
+
'opera' in window ? 'O' : '',
|
11
|
+
|
12
|
+
// Browser capabilities
|
13
|
+
isAndroid = (/android/gi).test(navigator.appVersion),
|
14
|
+
isIDevice = (/iphone|ipad/gi).test(navigator.appVersion),
|
15
|
+
isPlaybook = (/playbook/gi).test(navigator.appVersion),
|
16
|
+
isTouchPad = (/hp-tablet/gi).test(navigator.appVersion),
|
17
|
+
|
18
|
+
has3d = 'WebKitCSSMatrix' in window && 'm11' in new WebKitCSSMatrix(),
|
19
|
+
hasTouch = 'ontouchstart' in window && !isTouchPad,
|
20
|
+
hasTransform = vendor + 'Transform' in document.documentElement.style,
|
21
|
+
hasTransitionEnd = isIDevice || isPlaybook,
|
22
|
+
|
23
|
+
nextFrame = (function() {
|
24
|
+
return window.requestAnimationFrame
|
25
|
+
|| window.webkitRequestAnimationFrame
|
26
|
+
|| window.mozRequestAnimationFrame
|
27
|
+
|| window.oRequestAnimationFrame
|
28
|
+
|| window.msRequestAnimationFrame
|
29
|
+
|| function(callback) { return setTimeout(callback, 1); }
|
30
|
+
})(),
|
31
|
+
cancelFrame = (function () {
|
32
|
+
return window.cancelRequestAnimationFrame
|
33
|
+
|| window.webkitCancelRequestAnimationFrame
|
34
|
+
|| window.mozCancelRequestAnimationFrame
|
35
|
+
|| window.oCancelRequestAnimationFrame
|
36
|
+
|| window.msCancelRequestAnimationFrame
|
37
|
+
|| clearTimeout
|
38
|
+
})(),
|
39
|
+
|
40
|
+
// Events
|
41
|
+
RESIZE_EV = 'onorientationchange' in window ? 'orientationchange' : 'resize',
|
42
|
+
START_EV = hasTouch ? 'touchstart' : 'mousedown',
|
43
|
+
MOVE_EV = hasTouch ? 'touchmove' : 'mousemove',
|
44
|
+
END_EV = hasTouch ? 'touchend' : 'mouseup',
|
45
|
+
CANCEL_EV = hasTouch ? 'touchcancel' : 'mouseup',
|
46
|
+
WHEEL_EV = vendor == 'Moz' ? 'DOMMouseScroll' : 'mousewheel',
|
47
|
+
|
48
|
+
// Helpers
|
49
|
+
trnOpen = 'translate' + (has3d ? '3d(' : '('),
|
50
|
+
trnClose = has3d ? ',0)' : ')',
|
51
|
+
|
52
|
+
// Constructor
|
53
|
+
iScroll = function (el, options) {
|
54
|
+
var that = this,
|
55
|
+
doc = document,
|
56
|
+
i;
|
57
|
+
|
58
|
+
that.wrapper = typeof el == 'object' ? el : doc.getElementById(el);
|
59
|
+
that.wrapper.style.overflow = 'hidden';
|
60
|
+
that.scroller = that.wrapper.children[0];
|
61
|
+
|
62
|
+
// Default options
|
63
|
+
that.options = {
|
64
|
+
hScroll: true,
|
65
|
+
vScroll: true,
|
66
|
+
x: 0,
|
67
|
+
y: 0,
|
68
|
+
bounce: true,
|
69
|
+
bounceLock: false,
|
70
|
+
momentum: true,
|
71
|
+
lockDirection: true,
|
72
|
+
useTransform: true,
|
73
|
+
useTransition: false,
|
74
|
+
topOffset: 0,
|
75
|
+
checkDOMChanges: false, // Experimental
|
76
|
+
|
77
|
+
// Scrollbar
|
78
|
+
hScrollbar: true,
|
79
|
+
vScrollbar: true,
|
80
|
+
fixedScrollbar: isAndroid,
|
81
|
+
hideScrollbar: isIDevice,
|
82
|
+
fadeScrollbar: isIDevice && has3d,
|
83
|
+
scrollbarClass: '',
|
84
|
+
|
85
|
+
// Zoom
|
86
|
+
zoom: false,
|
87
|
+
zoomMin: 1,
|
88
|
+
zoomMax: 4,
|
89
|
+
doubleTapZoom: 2,
|
90
|
+
wheelAction: 'scroll',
|
91
|
+
|
92
|
+
// Snap
|
93
|
+
snap: false,
|
94
|
+
snapThreshold: 1,
|
95
|
+
|
96
|
+
// Events
|
97
|
+
onRefresh: null,
|
98
|
+
onBeforeScrollStart: function (e) { e.preventDefault(); },
|
99
|
+
onScrollStart: null,
|
100
|
+
onBeforeScrollMove: null,
|
101
|
+
onScrollMove: null,
|
102
|
+
onBeforeScrollEnd: null,
|
103
|
+
onScrollEnd: null,
|
104
|
+
onTouchEnd: null,
|
105
|
+
onDestroy: null,
|
106
|
+
onZoomStart: null,
|
107
|
+
onZoom: null,
|
108
|
+
onZoomEnd: null
|
109
|
+
};
|
110
|
+
|
111
|
+
// User defined options
|
112
|
+
for (i in options) that.options[i] = options[i];
|
113
|
+
|
114
|
+
// Set starting position
|
115
|
+
that.x = that.options.x;
|
116
|
+
that.y = that.options.y;
|
117
|
+
|
118
|
+
// Normalize options
|
119
|
+
that.options.useTransform = hasTransform ? that.options.useTransform : false;
|
120
|
+
that.options.hScrollbar = that.options.hScroll && that.options.hScrollbar;
|
121
|
+
that.options.vScrollbar = that.options.vScroll && that.options.vScrollbar;
|
122
|
+
that.options.zoom = that.options.useTransform && that.options.zoom;
|
123
|
+
that.options.useTransition = hasTransitionEnd && that.options.useTransition;
|
124
|
+
|
125
|
+
// Helpers FIX ANDROID BUG!
|
126
|
+
// translate3d and scale doesn't work together!
|
127
|
+
// Ignoring 3d ONLY WHEN YOU SET that.options.zoom
|
128
|
+
if ( that.options.zoom && isAndroid ){
|
129
|
+
trnOpen = 'translate(';
|
130
|
+
trnClose = ')';
|
131
|
+
}
|
132
|
+
|
133
|
+
// Set some default styles
|
134
|
+
that.scroller.style[vendor + 'TransitionProperty'] = that.options.useTransform ? '-' + vendor.toLowerCase() + '-transform' : 'top left';
|
135
|
+
that.scroller.style[vendor + 'TransitionDuration'] = '0';
|
136
|
+
that.scroller.style[vendor + 'TransformOrigin'] = '0 0';
|
137
|
+
if (that.options.useTransition) that.scroller.style[vendor + 'TransitionTimingFunction'] = 'cubic-bezier(0.33,0.66,0.66,1)';
|
138
|
+
|
139
|
+
if (that.options.useTransform) that.scroller.style[vendor + 'Transform'] = trnOpen + that.x + 'px,' + that.y + 'px' + trnClose;
|
140
|
+
else that.scroller.style.cssText += ';position:absolute;top:' + that.y + 'px;left:' + that.x + 'px';
|
141
|
+
|
142
|
+
if (that.options.useTransition) that.options.fixedScrollbar = true;
|
143
|
+
|
144
|
+
that.refresh();
|
145
|
+
|
146
|
+
that._bind(RESIZE_EV, window);
|
147
|
+
that._bind(START_EV);
|
148
|
+
if (!hasTouch) {
|
149
|
+
that._bind('mouseout', that.wrapper);
|
150
|
+
if (that.options.wheelAction != 'none')
|
151
|
+
that._bind(WHEEL_EV);
|
152
|
+
}
|
153
|
+
|
154
|
+
if (that.options.checkDOMChanges) that.checkDOMTime = setInterval(function () {
|
155
|
+
that._checkDOMChanges();
|
156
|
+
}, 500);
|
157
|
+
};
|
158
|
+
|
159
|
+
// Prototype
|
160
|
+
iScroll.prototype = {
|
161
|
+
enabled: true,
|
162
|
+
x: 0,
|
163
|
+
y: 0,
|
164
|
+
steps: [],
|
165
|
+
scale: 1,
|
166
|
+
currPageX: 0, currPageY: 0,
|
167
|
+
pagesX: [], pagesY: [],
|
168
|
+
aniTime: null,
|
169
|
+
wheelZoomCount: 0,
|
170
|
+
|
171
|
+
handleEvent: function (e) {
|
172
|
+
var that = this;
|
173
|
+
switch(e.type) {
|
174
|
+
case START_EV:
|
175
|
+
if (!hasTouch && e.button !== 0) return;
|
176
|
+
that._start(e);
|
177
|
+
break;
|
178
|
+
case MOVE_EV: that._move(e); break;
|
179
|
+
case END_EV:
|
180
|
+
case CANCEL_EV: that._end(e); break;
|
181
|
+
case RESIZE_EV: that._resize(); break;
|
182
|
+
case WHEEL_EV: that._wheel(e); break;
|
183
|
+
case 'mouseout': that._mouseout(e); break;
|
184
|
+
case 'webkitTransitionEnd': that._transitionEnd(e); break;
|
185
|
+
}
|
186
|
+
},
|
187
|
+
|
188
|
+
_checkDOMChanges: function () {
|
189
|
+
if (this.moved || this.zoomed || this.animating ||
|
190
|
+
(this.scrollerW == this.scroller.offsetWidth * this.scale && this.scrollerH == this.scroller.offsetHeight * this.scale)) return;
|
191
|
+
|
192
|
+
this.refresh();
|
193
|
+
},
|
194
|
+
|
195
|
+
_scrollbar: function (dir) {
|
196
|
+
var that = this,
|
197
|
+
doc = document,
|
198
|
+
bar;
|
199
|
+
|
200
|
+
if (!that[dir + 'Scrollbar']) {
|
201
|
+
if (that[dir + 'ScrollbarWrapper']) {
|
202
|
+
if (hasTransform) that[dir + 'ScrollbarIndicator'].style[vendor + 'Transform'] = '';
|
203
|
+
that[dir + 'ScrollbarWrapper'].parentNode.removeChild(that[dir + 'ScrollbarWrapper']);
|
204
|
+
that[dir + 'ScrollbarWrapper'] = null;
|
205
|
+
that[dir + 'ScrollbarIndicator'] = null;
|
206
|
+
}
|
207
|
+
|
208
|
+
return;
|
209
|
+
}
|
210
|
+
|
211
|
+
if (!that[dir + 'ScrollbarWrapper']) {
|
212
|
+
// Create the scrollbar wrapper
|
213
|
+
bar = doc.createElement('div');
|
214
|
+
|
215
|
+
if (that.options.scrollbarClass) bar.className = that.options.scrollbarClass + dir.toUpperCase();
|
216
|
+
else bar.style.cssText = 'position:absolute;z-index:100;' + (dir == 'h' ? 'height:7px;bottom:1px;left:2px;right:' + (that.vScrollbar ? '7' : '2') + 'px' : 'width:7px;bottom:' + (that.hScrollbar ? '7' : '2') + 'px;top:2px;right:1px');
|
217
|
+
|
218
|
+
bar.style.cssText += ';pointer-events:none;-' + vendor + '-transition-property:opacity;-' + vendor + '-transition-duration:' + (that.options.fadeScrollbar ? '350ms' : '0') + ';overflow:hidden;opacity:' + (that.options.hideScrollbar ? '0' : '1');
|
219
|
+
|
220
|
+
that.wrapper.appendChild(bar);
|
221
|
+
that[dir + 'ScrollbarWrapper'] = bar;
|
222
|
+
|
223
|
+
// Create the scrollbar indicator
|
224
|
+
bar = doc.createElement('div');
|
225
|
+
if (!that.options.scrollbarClass) {
|
226
|
+
bar.style.cssText = 'position:absolute;z-index:100;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);-' + vendor + '-background-clip:padding-box;-' + vendor + '-box-sizing:border-box;' + (dir == 'h' ? 'height:100%' : 'width:100%') + ';-' + vendor + '-border-radius:3px;border-radius:3px';
|
227
|
+
}
|
228
|
+
bar.style.cssText += ';pointer-events:none;-' + vendor + '-transition-property:-' + vendor + '-transform;-' + vendor + '-transition-timing-function:cubic-bezier(0.33,0.66,0.66,1);-' + vendor + '-transition-duration:0;-' + vendor + '-transform:' + trnOpen + '0,0' + trnClose;
|
229
|
+
if (that.options.useTransition) bar.style.cssText += ';-' + vendor + '-transition-timing-function:cubic-bezier(0.33,0.66,0.66,1)';
|
230
|
+
|
231
|
+
that[dir + 'ScrollbarWrapper'].appendChild(bar);
|
232
|
+
that[dir + 'ScrollbarIndicator'] = bar;
|
233
|
+
}
|
234
|
+
|
235
|
+
if (dir == 'h') {
|
236
|
+
that.hScrollbarSize = that.hScrollbarWrapper.clientWidth;
|
237
|
+
that.hScrollbarIndicatorSize = m.max(mround(that.hScrollbarSize * that.hScrollbarSize / that.scrollerW), 8);
|
238
|
+
that.hScrollbarIndicator.style.width = that.hScrollbarIndicatorSize + 'px';
|
239
|
+
that.hScrollbarMaxScroll = that.hScrollbarSize - that.hScrollbarIndicatorSize;
|
240
|
+
that.hScrollbarProp = that.hScrollbarMaxScroll / that.maxScrollX;
|
241
|
+
} else {
|
242
|
+
that.vScrollbarSize = that.vScrollbarWrapper.clientHeight;
|
243
|
+
that.vScrollbarIndicatorSize = m.max(mround(that.vScrollbarSize * that.vScrollbarSize / that.scrollerH), 8);
|
244
|
+
that.vScrollbarIndicator.style.height = that.vScrollbarIndicatorSize + 'px';
|
245
|
+
that.vScrollbarMaxScroll = that.vScrollbarSize - that.vScrollbarIndicatorSize;
|
246
|
+
that.vScrollbarProp = that.vScrollbarMaxScroll / that.maxScrollY;
|
247
|
+
}
|
248
|
+
|
249
|
+
// Reset position
|
250
|
+
that._scrollbarPos(dir, true);
|
251
|
+
},
|
252
|
+
|
253
|
+
_resize: function () {
|
254
|
+
var that = this;
|
255
|
+
setTimeout(function () { that.refresh(); }, isAndroid ? 200 : 0);
|
256
|
+
},
|
257
|
+
|
258
|
+
_pos: function (x, y) {
|
259
|
+
x = this.hScroll ? x : 0;
|
260
|
+
y = this.vScroll ? y : 0;
|
261
|
+
|
262
|
+
if (this.options.useTransform) {
|
263
|
+
this.scroller.style[vendor + 'Transform'] = trnOpen + x + 'px,' + y + 'px' + trnClose + ' scale(' + this.scale + ')';
|
264
|
+
} else {
|
265
|
+
x = mround(x);
|
266
|
+
y = mround(y);
|
267
|
+
this.scroller.style.left = x + 'px';
|
268
|
+
this.scroller.style.top = y + 'px';
|
269
|
+
}
|
270
|
+
|
271
|
+
this.x = x;
|
272
|
+
this.y = y;
|
273
|
+
|
274
|
+
this._scrollbarPos('h');
|
275
|
+
this._scrollbarPos('v');
|
276
|
+
},
|
277
|
+
|
278
|
+
_scrollbarPos: function (dir, hidden) {
|
279
|
+
var that = this,
|
280
|
+
pos = dir == 'h' ? that.x : that.y,
|
281
|
+
size;
|
282
|
+
|
283
|
+
if (!that[dir + 'Scrollbar']) return;
|
284
|
+
|
285
|
+
pos = that[dir + 'ScrollbarProp'] * pos;
|
286
|
+
|
287
|
+
if (pos < 0) {
|
288
|
+
if (!that.options.fixedScrollbar) {
|
289
|
+
size = that[dir + 'ScrollbarIndicatorSize'] + mround(pos * 3);
|
290
|
+
if (size < 8) size = 8;
|
291
|
+
that[dir + 'ScrollbarIndicator'].style[dir == 'h' ? 'width' : 'height'] = size + 'px';
|
292
|
+
}
|
293
|
+
pos = 0;
|
294
|
+
} else if (pos > that[dir + 'ScrollbarMaxScroll']) {
|
295
|
+
if (!that.options.fixedScrollbar) {
|
296
|
+
size = that[dir + 'ScrollbarIndicatorSize'] - mround((pos - that[dir + 'ScrollbarMaxScroll']) * 3);
|
297
|
+
if (size < 8) size = 8;
|
298
|
+
that[dir + 'ScrollbarIndicator'].style[dir == 'h' ? 'width' : 'height'] = size + 'px';
|
299
|
+
pos = that[dir + 'ScrollbarMaxScroll'] + (that[dir + 'ScrollbarIndicatorSize'] - size);
|
300
|
+
} else {
|
301
|
+
pos = that[dir + 'ScrollbarMaxScroll'];
|
302
|
+
}
|
303
|
+
}
|
304
|
+
|
305
|
+
that[dir + 'ScrollbarWrapper'].style[vendor + 'TransitionDelay'] = '0';
|
306
|
+
that[dir + 'ScrollbarWrapper'].style.opacity = hidden && that.options.hideScrollbar ? '0' : '1';
|
307
|
+
that[dir + 'ScrollbarIndicator'].style[vendor + 'Transform'] = trnOpen + (dir == 'h' ? pos + 'px,0' : '0,' + pos + 'px') + trnClose;
|
308
|
+
},
|
309
|
+
|
310
|
+
_start: function (e) {
|
311
|
+
var that = this,
|
312
|
+
point = hasTouch ? e.touches[0] : e,
|
313
|
+
matrix, x, y,
|
314
|
+
c1, c2,
|
315
|
+
tagName = e.target.nodeName.toLowerCase();
|
316
|
+
|
317
|
+
if (tagName === "select" || tagName === "input" || tagName === "textarea") {
|
318
|
+
e.target.focus();
|
319
|
+
that.focusedInput = e.target;
|
320
|
+
return;
|
321
|
+
}
|
322
|
+
|
323
|
+
if (that.focusedInput){
|
324
|
+
that.focusedInput.blur();
|
325
|
+
that.focusedInput = false;
|
326
|
+
}
|
327
|
+
|
328
|
+
if (!that.enabled) return;
|
329
|
+
|
330
|
+
if (that.options.onBeforeScrollStart) that.options.onBeforeScrollStart.call(that, e);
|
331
|
+
|
332
|
+
if (that.options.useTransition || that.options.zoom) that._transitionTime(0);
|
333
|
+
|
334
|
+
that.moved = false;
|
335
|
+
that.animating = false;
|
336
|
+
that.zoomed = false;
|
337
|
+
that.distX = 0;
|
338
|
+
that.distY = 0;
|
339
|
+
that.absDistX = 0;
|
340
|
+
that.absDistY = 0;
|
341
|
+
that.dirX = 0;
|
342
|
+
that.dirY = 0;
|
343
|
+
|
344
|
+
// Gesture start
|
345
|
+
if (that.options.zoom && hasTouch && e.touches.length > 1) {
|
346
|
+
c1 = m.abs(e.touches[0].pageX-e.touches[1].pageX);
|
347
|
+
c2 = m.abs(e.touches[0].pageY-e.touches[1].pageY);
|
348
|
+
that.touchesDistStart = m.sqrt(c1 * c1 + c2 * c2);
|
349
|
+
|
350
|
+
that.originX = m.abs(e.touches[0].pageX + e.touches[1].pageX - that.wrapperOffsetLeft * 2) / 2 - that.x;
|
351
|
+
that.originY = m.abs(e.touches[0].pageY + e.touches[1].pageY - that.wrapperOffsetTop * 2) / 2 - that.y;
|
352
|
+
|
353
|
+
if (that.options.onZoomStart) that.options.onZoomStart.call(that, e);
|
354
|
+
}
|
355
|
+
|
356
|
+
if (that.options.momentum) {
|
357
|
+
if (that.options.useTransform) {
|
358
|
+
// Very lame general purpose alternative to CSSMatrix
|
359
|
+
matrix = getComputedStyle(that.scroller, null)[vendor + 'Transform'].replace(/[^0-9-.,]/g, '').split(',');
|
360
|
+
x = matrix[4] * 1;
|
361
|
+
y = matrix[5] * 1;
|
362
|
+
} else {
|
363
|
+
x = getComputedStyle(that.scroller, null).left.replace(/[^0-9-]/g, '') * 1;
|
364
|
+
y = getComputedStyle(that.scroller, null).top.replace(/[^0-9-]/g, '') * 1;
|
365
|
+
}
|
366
|
+
|
367
|
+
if (x != that.x || y != that.y) {
|
368
|
+
if (that.options.useTransition) that._unbind('webkitTransitionEnd');
|
369
|
+
else cancelFrame(that.aniTime);
|
370
|
+
that.steps = [];
|
371
|
+
that._pos(x, y);
|
372
|
+
}
|
373
|
+
}
|
374
|
+
|
375
|
+
that.absStartX = that.x; // Needed by snap threshold
|
376
|
+
that.absStartY = that.y;
|
377
|
+
|
378
|
+
that.startX = that.x;
|
379
|
+
that.startY = that.y;
|
380
|
+
that.pointX = point.pageX;
|
381
|
+
that.pointY = point.pageY;
|
382
|
+
|
383
|
+
that.startTime = e.timeStamp || Date.now();
|
384
|
+
|
385
|
+
if (that.options.onScrollStart) that.options.onScrollStart.call(that, e);
|
386
|
+
|
387
|
+
that._bind(MOVE_EV);
|
388
|
+
that._bind(END_EV);
|
389
|
+
that._bind(CANCEL_EV);
|
390
|
+
},
|
391
|
+
|
392
|
+
_move: function (e) {
|
393
|
+
var that = this,
|
394
|
+
point = hasTouch ? e.touches[0] : e,
|
395
|
+
deltaX = point.pageX - that.pointX,
|
396
|
+
deltaY = point.pageY - that.pointY,
|
397
|
+
newX = that.x + deltaX,
|
398
|
+
newY = that.y + deltaY,
|
399
|
+
c1, c2, scale,
|
400
|
+
timestamp = e.timeStamp || Date.now();
|
401
|
+
|
402
|
+
if (that.options.onBeforeScrollMove) that.options.onBeforeScrollMove.call(that, e);
|
403
|
+
|
404
|
+
// Zoom
|
405
|
+
if (that.options.zoom && hasTouch && e.touches.length > 1) {
|
406
|
+
c1 = m.abs(e.touches[0].pageX - e.touches[1].pageX);
|
407
|
+
c2 = m.abs(e.touches[0].pageY - e.touches[1].pageY);
|
408
|
+
that.touchesDist = m.sqrt(c1*c1+c2*c2);
|
409
|
+
|
410
|
+
that.zoomed = true;
|
411
|
+
|
412
|
+
scale = 1 / that.touchesDistStart * that.touchesDist * this.scale;
|
413
|
+
|
414
|
+
if (scale < that.options.zoomMin) scale = 0.5 * that.options.zoomMin * Math.pow(2.0, scale / that.options.zoomMin);
|
415
|
+
else if (scale > that.options.zoomMax) scale = 2.0 * that.options.zoomMax * Math.pow(0.5, that.options.zoomMax / scale);
|
416
|
+
|
417
|
+
that.lastScale = scale / this.scale;
|
418
|
+
|
419
|
+
newX = this.originX - this.originX * that.lastScale + this.x,
|
420
|
+
newY = this.originY - this.originY * that.lastScale + this.y;
|
421
|
+
|
422
|
+
this.scroller.style[vendor + 'Transform'] = trnOpen + newX + 'px,' + newY + 'px' + trnClose + ' scale(' + scale + ')';
|
423
|
+
|
424
|
+
if (that.options.onZoom) that.options.onZoom.call(that, e);
|
425
|
+
return;
|
426
|
+
}
|
427
|
+
|
428
|
+
that.pointX = point.pageX;
|
429
|
+
that.pointY = point.pageY;
|
430
|
+
|
431
|
+
// Slow down if outside of the boundaries
|
432
|
+
if (newX > 0 || newX < that.maxScrollX) {
|
433
|
+
newX = that.options.bounce ? that.x + (deltaX / 2) : newX >= 0 || that.maxScrollX >= 0 ? 0 : that.maxScrollX;
|
434
|
+
}
|
435
|
+
if (newY > that.minScrollY || newY < that.maxScrollY) {
|
436
|
+
newY = that.options.bounce ? that.y + (deltaY / 2) : newY >= that.minScrollY || that.maxScrollY >= 0 ? that.minScrollY : that.maxScrollY;
|
437
|
+
}
|
438
|
+
|
439
|
+
if (that.absDistX < 6 && that.absDistY < 6) {
|
440
|
+
that.distX += deltaX;
|
441
|
+
that.distY += deltaY;
|
442
|
+
that.absDistX = m.abs(that.distX);
|
443
|
+
that.absDistY = m.abs(that.distY);
|
444
|
+
|
445
|
+
return;
|
446
|
+
}
|
447
|
+
|
448
|
+
// Lock direction
|
449
|
+
if (that.options.lockDirection) {
|
450
|
+
if (that.absDistX > that.absDistY + 5) {
|
451
|
+
newY = that.y;
|
452
|
+
deltaY = 0;
|
453
|
+
} else if (that.absDistY > that.absDistX + 5) {
|
454
|
+
newX = that.x;
|
455
|
+
deltaX = 0;
|
456
|
+
}
|
457
|
+
}
|
458
|
+
|
459
|
+
that.moved = true;
|
460
|
+
that._pos(newX, newY);
|
461
|
+
that.dirX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0;
|
462
|
+
that.dirY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0;
|
463
|
+
|
464
|
+
if (timestamp - that.startTime > 300) {
|
465
|
+
that.startTime = timestamp;
|
466
|
+
that.startX = that.x;
|
467
|
+
that.startY = that.y;
|
468
|
+
}
|
469
|
+
|
470
|
+
if (that.options.onScrollMove) that.options.onScrollMove.call(that, e);
|
471
|
+
},
|
472
|
+
|
473
|
+
_end: function (e) {
|
474
|
+
if (hasTouch && e.touches.length != 0) return;
|
475
|
+
|
476
|
+
var that = this,
|
477
|
+
point = hasTouch ? e.changedTouches[0] : e,
|
478
|
+
target, ev,
|
479
|
+
momentumX = { dist:0, time:0 },
|
480
|
+
momentumY = { dist:0, time:0 },
|
481
|
+
duration = (e.timeStamp || Date.now()) - that.startTime,
|
482
|
+
newPosX = that.x,
|
483
|
+
newPosY = that.y,
|
484
|
+
distX, distY,
|
485
|
+
newDuration,
|
486
|
+
snap,
|
487
|
+
scale;
|
488
|
+
|
489
|
+
that._unbind(MOVE_EV);
|
490
|
+
that._unbind(END_EV);
|
491
|
+
that._unbind(CANCEL_EV);
|
492
|
+
|
493
|
+
if (that.options.onBeforeScrollEnd) that.options.onBeforeScrollEnd.call(that, e);
|
494
|
+
|
495
|
+
if (that.zoomed) {
|
496
|
+
scale = that.scale * that.lastScale;
|
497
|
+
scale = Math.max(that.options.zoomMin, scale);
|
498
|
+
scale = Math.min(that.options.zoomMax, scale);
|
499
|
+
that.lastScale = scale / that.scale;
|
500
|
+
that.scale = scale;
|
501
|
+
|
502
|
+
that.x = that.originX - that.originX * that.lastScale + that.x;
|
503
|
+
that.y = that.originY - that.originY * that.lastScale + that.y;
|
504
|
+
|
505
|
+
that.scroller.style[vendor + 'TransitionDuration'] = '200ms';
|
506
|
+
that.scroller.style[vendor + 'Transform'] = trnOpen + that.x + 'px,' + that.y + 'px' + trnClose + ' scale(' + that.scale + ')';
|
507
|
+
|
508
|
+
that.zoomed = false;
|
509
|
+
that.refresh();
|
510
|
+
|
511
|
+
if (that.options.onZoomEnd) that.options.onZoomEnd.call(that, e);
|
512
|
+
return;
|
513
|
+
}
|
514
|
+
|
515
|
+
if (!that.moved) {
|
516
|
+
if (hasTouch) {
|
517
|
+
if (that.doubleTapTimer && that.options.zoom) {
|
518
|
+
// Double tapped
|
519
|
+
clearTimeout(that.doubleTapTimer);
|
520
|
+
that.doubleTapTimer = null;
|
521
|
+
if (that.options.onZoomStart) that.options.onZoomStart.call(that, e);
|
522
|
+
that.zoom(that.pointX, that.pointY, that.scale == 1 ? that.options.doubleTapZoom : 1);
|
523
|
+
if (that.options.onZoomEnd) {
|
524
|
+
setTimeout(function() {
|
525
|
+
that.options.onZoomEnd.call(that, e);
|
526
|
+
}, 200); // 200 is default zoom duration
|
527
|
+
}
|
528
|
+
} else {
|
529
|
+
that.doubleTapTimer = setTimeout(function () {
|
530
|
+
that.doubleTapTimer = null;
|
531
|
+
|
532
|
+
// Find the last touched element
|
533
|
+
target = point.target;
|
534
|
+
while (target.nodeType != 1) target = target.parentNode;
|
535
|
+
|
536
|
+
if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA') {
|
537
|
+
ev = document.createEvent('MouseEvents');
|
538
|
+
ev.initMouseEvent('click', true, true, e.view, 1,
|
539
|
+
point.screenX, point.screenY, point.clientX, point.clientY,
|
540
|
+
e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
|
541
|
+
0, null);
|
542
|
+
ev._fake = true;
|
543
|
+
target.dispatchEvent(ev);
|
544
|
+
}
|
545
|
+
}, that.options.zoom ? 250 : 0);
|
546
|
+
}
|
547
|
+
}
|
548
|
+
|
549
|
+
that._resetPos(200);
|
550
|
+
|
551
|
+
if (that.options.onTouchEnd) that.options.onTouchEnd.call(that, e);
|
552
|
+
return;
|
553
|
+
}
|
554
|
+
|
555
|
+
if (duration < 300 && that.options.momentum) {
|
556
|
+
momentumX = newPosX ? that._momentum(newPosX - that.startX, duration, -that.x, that.scrollerW - that.wrapperW + that.x, that.options.bounce ? that.wrapperW : 0) : momentumX;
|
557
|
+
momentumY = newPosY ? that._momentum(newPosY - that.startY, duration, -that.y, (that.maxScrollY < 0 ? that.scrollerH - that.wrapperH + that.y - that.minScrollY : 0), that.options.bounce ? that.wrapperH : 0) : momentumY;
|
558
|
+
|
559
|
+
newPosX = that.x + momentumX.dist;
|
560
|
+
newPosY = that.y + momentumY.dist;
|
561
|
+
|
562
|
+
if ((that.x > 0 && newPosX > 0) || (that.x < that.maxScrollX && newPosX < that.maxScrollX)) momentumX = { dist:0, time:0 };
|
563
|
+
if ((that.y > that.minScrollY && newPosY > that.minScrollY) || (that.y < that.maxScrollY && newPosY < that.maxScrollY)) momentumY = { dist:0, time:0 };
|
564
|
+
}
|
565
|
+
|
566
|
+
if (momentumX.dist || momentumY.dist) {
|
567
|
+
newDuration = m.max(m.max(momentumX.time, momentumY.time), 10);
|
568
|
+
|
569
|
+
// Do we need to snap?
|
570
|
+
if (that.options.snap) {
|
571
|
+
distX = newPosX - that.absStartX;
|
572
|
+
distY = newPosY - that.absStartY;
|
573
|
+
if (m.abs(distX) < that.options.snapThreshold && m.abs(distY) < that.options.snapThreshold) { that.scrollTo(that.absStartX, that.absStartY, 200); }
|
574
|
+
else {
|
575
|
+
snap = that._snap(newPosX, newPosY);
|
576
|
+
newPosX = snap.x;
|
577
|
+
newPosY = snap.y;
|
578
|
+
newDuration = m.max(snap.time, newDuration);
|
579
|
+
}
|
580
|
+
}
|
581
|
+
|
582
|
+
that.scrollTo(mround(newPosX), mround(newPosY), newDuration);
|
583
|
+
|
584
|
+
if (that.options.onTouchEnd) that.options.onTouchEnd.call(that, e);
|
585
|
+
return;
|
586
|
+
}
|
587
|
+
|
588
|
+
// Do we need to snap?
|
589
|
+
if (that.options.snap) {
|
590
|
+
distX = newPosX - that.absStartX;
|
591
|
+
distY = newPosY - that.absStartY;
|
592
|
+
if (m.abs(distX) < that.options.snapThreshold && m.abs(distY) < that.options.snapThreshold) that.scrollTo(that.absStartX, that.absStartY, 200);
|
593
|
+
else {
|
594
|
+
snap = that._snap(that.x, that.y);
|
595
|
+
if (snap.x != that.x || snap.y != that.y) that.scrollTo(snap.x, snap.y, snap.time);
|
596
|
+
}
|
597
|
+
|
598
|
+
if (that.options.onTouchEnd) that.options.onTouchEnd.call(that, e);
|
599
|
+
return;
|
600
|
+
}
|
601
|
+
|
602
|
+
that._resetPos(200);
|
603
|
+
if (that.options.onTouchEnd) that.options.onTouchEnd.call(that, e);
|
604
|
+
},
|
605
|
+
|
606
|
+
_resetPos: function (time) {
|
607
|
+
var that = this,
|
608
|
+
resetX = that.x >= 0 ? 0 : that.x < that.maxScrollX ? that.maxScrollX : that.x,
|
609
|
+
resetY = that.y >= that.minScrollY || that.maxScrollY > 0 ? that.minScrollY : that.y < that.maxScrollY ? that.maxScrollY : that.y;
|
610
|
+
|
611
|
+
if (resetX == that.x && resetY == that.y) {
|
612
|
+
if (that.moved) {
|
613
|
+
that.moved = false;
|
614
|
+
if (that.options.onScrollEnd) that.options.onScrollEnd.call(that); // Execute custom code on scroll end
|
615
|
+
}
|
616
|
+
|
617
|
+
if (that.hScrollbar && that.options.hideScrollbar) {
|
618
|
+
if (vendor == 'webkit') that.hScrollbarWrapper.style[vendor + 'TransitionDelay'] = '300ms';
|
619
|
+
that.hScrollbarWrapper.style.opacity = '0';
|
620
|
+
}
|
621
|
+
if (that.vScrollbar && that.options.hideScrollbar) {
|
622
|
+
if (vendor == 'webkit') that.vScrollbarWrapper.style[vendor + 'TransitionDelay'] = '300ms';
|
623
|
+
that.vScrollbarWrapper.style.opacity = '0';
|
624
|
+
}
|
625
|
+
|
626
|
+
return;
|
627
|
+
}
|
628
|
+
|
629
|
+
that.scrollTo(resetX, resetY, time || 0);
|
630
|
+
},
|
631
|
+
|
632
|
+
_wheel: function (e) {
|
633
|
+
var that = this,
|
634
|
+
wheelDeltaX, wheelDeltaY,
|
635
|
+
deltaX, deltaY,
|
636
|
+
deltaScale;
|
637
|
+
|
638
|
+
if ('wheelDeltaX' in e) {
|
639
|
+
wheelDeltaX = e.wheelDeltaX / 12;
|
640
|
+
wheelDeltaY = e.wheelDeltaY / 12;
|
641
|
+
} else if ('detail' in e) {
|
642
|
+
wheelDeltaX = wheelDeltaY = -e.detail * 3;
|
643
|
+
} else {
|
644
|
+
wheelDeltaX = wheelDeltaY = -e.wheelDelta;
|
645
|
+
}
|
646
|
+
|
647
|
+
if (that.options.wheelAction == 'zoom') {
|
648
|
+
deltaScale = that.scale * Math.pow(2, 1/3 * (wheelDeltaY ? wheelDeltaY / Math.abs(wheelDeltaY) : 0));
|
649
|
+
if (deltaScale < that.options.zoomMin) deltaScale = that.options.zoomMin;
|
650
|
+
if (deltaScale > that.options.zoomMax) deltaScale = that.options.zoomMax;
|
651
|
+
|
652
|
+
if (deltaScale != that.scale) {
|
653
|
+
if (!that.wheelZoomCount && that.options.onZoomStart) that.options.onZoomStart.call(that, e);
|
654
|
+
that.wheelZoomCount++;
|
655
|
+
|
656
|
+
that.zoom(e.pageX, e.pageY, deltaScale, 400);
|
657
|
+
|
658
|
+
setTimeout(function() {
|
659
|
+
that.wheelZoomCount--;
|
660
|
+
if (!that.wheelZoomCount && that.options.onZoomEnd) that.options.onZoomEnd.call(that, e);
|
661
|
+
}, 400);
|
662
|
+
}
|
663
|
+
|
664
|
+
return;
|
665
|
+
}
|
666
|
+
|
667
|
+
deltaX = that.x + wheelDeltaX;
|
668
|
+
deltaY = that.y + wheelDeltaY;
|
669
|
+
|
670
|
+
if (deltaX > 0) deltaX = 0;
|
671
|
+
else if (deltaX < that.maxScrollX) deltaX = that.maxScrollX;
|
672
|
+
|
673
|
+
if (deltaY > that.minScrollY) deltaY = that.minScrollY;
|
674
|
+
else if (deltaY < that.maxScrollY) deltaY = that.maxScrollY;
|
675
|
+
|
676
|
+
that.scrollTo(deltaX, deltaY, 0);
|
677
|
+
},
|
678
|
+
|
679
|
+
_mouseout: function (e) {
|
680
|
+
var t = e.relatedTarget;
|
681
|
+
|
682
|
+
if (!t) {
|
683
|
+
this._end(e);
|
684
|
+
return;
|
685
|
+
}
|
686
|
+
|
687
|
+
while (t = t.parentNode) if (t == this.wrapper) return;
|
688
|
+
|
689
|
+
this._end(e);
|
690
|
+
},
|
691
|
+
|
692
|
+
_transitionEnd: function (e) {
|
693
|
+
var that = this;
|
694
|
+
|
695
|
+
if (e.target != that.scroller) return;
|
696
|
+
|
697
|
+
that._unbind('webkitTransitionEnd');
|
698
|
+
|
699
|
+
that._startAni();
|
700
|
+
},
|
701
|
+
|
702
|
+
|
703
|
+
/**
|
704
|
+
*
|
705
|
+
* Utilities
|
706
|
+
*
|
707
|
+
*/
|
708
|
+
_startAni: function () {
|
709
|
+
var that = this,
|
710
|
+
startX = that.x, startY = that.y,
|
711
|
+
startTime = Date.now(),
|
712
|
+
step, easeOut,
|
713
|
+
animate;
|
714
|
+
|
715
|
+
if (that.animating) return;
|
716
|
+
|
717
|
+
if (!that.steps.length) {
|
718
|
+
that._resetPos(400);
|
719
|
+
return;
|
720
|
+
}
|
721
|
+
|
722
|
+
step = that.steps.shift();
|
723
|
+
|
724
|
+
if (step.x == startX && step.y == startY) step.time = 0;
|
725
|
+
|
726
|
+
that.animating = true;
|
727
|
+
that.moved = true;
|
728
|
+
|
729
|
+
if (that.options.useTransition) {
|
730
|
+
that._transitionTime(step.time);
|
731
|
+
that._pos(step.x, step.y);
|
732
|
+
that.animating = false;
|
733
|
+
if (step.time) that._bind('webkitTransitionEnd');
|
734
|
+
else that._resetPos(0);
|
735
|
+
return;
|
736
|
+
}
|
737
|
+
|
738
|
+
animate = function () {
|
739
|
+
var now = Date.now(),
|
740
|
+
newX, newY;
|
741
|
+
|
742
|
+
if (now >= startTime + step.time) {
|
743
|
+
that._pos(step.x, step.y);
|
744
|
+
that.animating = false;
|
745
|
+
if (that.options.onAnimationEnd) that.options.onAnimationEnd.call(that); // Execute custom code on animation end
|
746
|
+
that._startAni();
|
747
|
+
return;
|
748
|
+
}
|
749
|
+
|
750
|
+
now = (now - startTime) / step.time - 1;
|
751
|
+
easeOut = m.sqrt(1 - now * now);
|
752
|
+
newX = (step.x - startX) * easeOut + startX;
|
753
|
+
newY = (step.y - startY) * easeOut + startY;
|
754
|
+
that._pos(newX, newY);
|
755
|
+
if (that.animating) that.aniTime = nextFrame(animate);
|
756
|
+
};
|
757
|
+
|
758
|
+
animate();
|
759
|
+
},
|
760
|
+
|
761
|
+
_transitionTime: function (time) {
|
762
|
+
time += 'ms';
|
763
|
+
this.scroller.style[vendor + 'TransitionDuration'] = time;
|
764
|
+
if (this.hScrollbar) this.hScrollbarIndicator.style[vendor + 'TransitionDuration'] = time;
|
765
|
+
if (this.vScrollbar) this.vScrollbarIndicator.style[vendor + 'TransitionDuration'] = time;
|
766
|
+
},
|
767
|
+
|
768
|
+
_momentum: function (dist, time, maxDistUpper, maxDistLower, size) {
|
769
|
+
var deceleration = 0.0006,
|
770
|
+
speed = m.abs(dist) / time,
|
771
|
+
newDist = (speed * speed) / (2 * deceleration),
|
772
|
+
newTime = 0, outsideDist = 0;
|
773
|
+
|
774
|
+
// Proportinally reduce speed if we are outside of the boundaries
|
775
|
+
if (dist > 0 && newDist > maxDistUpper) {
|
776
|
+
outsideDist = size / (6 / (newDist / speed * deceleration));
|
777
|
+
maxDistUpper = maxDistUpper + outsideDist;
|
778
|
+
speed = speed * maxDistUpper / newDist;
|
779
|
+
newDist = maxDistUpper;
|
780
|
+
} else if (dist < 0 && newDist > maxDistLower) {
|
781
|
+
outsideDist = size / (6 / (newDist / speed * deceleration));
|
782
|
+
maxDistLower = maxDistLower + outsideDist;
|
783
|
+
speed = speed * maxDistLower / newDist;
|
784
|
+
newDist = maxDistLower;
|
785
|
+
}
|
786
|
+
|
787
|
+
newDist = newDist * (dist < 0 ? -1 : 1);
|
788
|
+
newTime = speed / deceleration;
|
789
|
+
|
790
|
+
return { dist: newDist, time: mround(newTime) };
|
791
|
+
},
|
792
|
+
|
793
|
+
_offset: function (el) {
|
794
|
+
var left = -el.offsetLeft,
|
795
|
+
top = -el.offsetTop;
|
796
|
+
|
797
|
+
while (el = el.offsetParent) {
|
798
|
+
left -= el.offsetLeft;
|
799
|
+
top -= el.offsetTop;
|
800
|
+
}
|
801
|
+
|
802
|
+
if (el != this.wrapper) {
|
803
|
+
left *= this.scale;
|
804
|
+
top *= this.scale;
|
805
|
+
}
|
806
|
+
|
807
|
+
return { left: left, top: top };
|
808
|
+
},
|
809
|
+
|
810
|
+
_snap: function (x, y) {
|
811
|
+
var that = this,
|
812
|
+
i, l,
|
813
|
+
page, time,
|
814
|
+
sizeX, sizeY;
|
815
|
+
|
816
|
+
// Check page X
|
817
|
+
page = that.pagesX.length - 1;
|
818
|
+
for (i=0, l=that.pagesX.length; i<l; i++) {
|
819
|
+
if (x >= that.pagesX[i]) {
|
820
|
+
page = i;
|
821
|
+
break;
|
822
|
+
}
|
823
|
+
}
|
824
|
+
if (page == that.currPageX && page > 0 && that.dirX < 0) page--;
|
825
|
+
x = that.pagesX[page];
|
826
|
+
sizeX = m.abs(x - that.pagesX[that.currPageX]);
|
827
|
+
sizeX = sizeX ? m.abs(that.x - x) / sizeX * 500 : 0;
|
828
|
+
that.currPageX = page;
|
829
|
+
|
830
|
+
// Check page Y
|
831
|
+
page = that.pagesY.length-1;
|
832
|
+
for (i=0; i<page; i++) {
|
833
|
+
if (y >= that.pagesY[i]) {
|
834
|
+
page = i;
|
835
|
+
break;
|
836
|
+
}
|
837
|
+
}
|
838
|
+
if (page == that.currPageY && page > 0 && that.dirY < 0) page--;
|
839
|
+
y = that.pagesY[page];
|
840
|
+
sizeY = m.abs(y - that.pagesY[that.currPageY]);
|
841
|
+
sizeY = sizeY ? m.abs(that.y - y) / sizeY * 500 : 0;
|
842
|
+
that.currPageY = page;
|
843
|
+
|
844
|
+
// Snap with constant speed (proportional duration)
|
845
|
+
time = mround(m.max(sizeX, sizeY)) || 200;
|
846
|
+
|
847
|
+
return { x: x, y: y, time: time };
|
848
|
+
},
|
849
|
+
|
850
|
+
_bind: function (type, el, bubble) {
|
851
|
+
(el || this.scroller).addEventListener(type, this, !!bubble);
|
852
|
+
},
|
853
|
+
|
854
|
+
_unbind: function (type, el, bubble) {
|
855
|
+
(el || this.scroller).removeEventListener(type, this, !!bubble);
|
856
|
+
},
|
857
|
+
|
858
|
+
|
859
|
+
/**
|
860
|
+
*
|
861
|
+
* Public methods
|
862
|
+
*
|
863
|
+
*/
|
864
|
+
destroy: function () {
|
865
|
+
var that = this;
|
866
|
+
|
867
|
+
that.scroller.style[vendor + 'Transform'] = '';
|
868
|
+
|
869
|
+
// Remove the scrollbars
|
870
|
+
that.hScrollbar = false;
|
871
|
+
that.vScrollbar = false;
|
872
|
+
that._scrollbar('h');
|
873
|
+
that._scrollbar('v');
|
874
|
+
|
875
|
+
// Remove the event listeners
|
876
|
+
that._unbind(RESIZE_EV, window);
|
877
|
+
that._unbind(START_EV);
|
878
|
+
that._unbind(MOVE_EV);
|
879
|
+
that._unbind(END_EV);
|
880
|
+
that._unbind(CANCEL_EV);
|
881
|
+
|
882
|
+
if (!that.options.hasTouch) {
|
883
|
+
that._unbind('mouseout', that.wrapper);
|
884
|
+
that._unbind(WHEEL_EV);
|
885
|
+
}
|
886
|
+
|
887
|
+
if (that.options.useTransition) that._unbind('webkitTransitionEnd');
|
888
|
+
|
889
|
+
if (that.options.checkDOMChanges) clearInterval(that.checkDOMTime);
|
890
|
+
|
891
|
+
if (that.options.onDestroy) that.options.onDestroy.call(that);
|
892
|
+
},
|
893
|
+
|
894
|
+
refresh: function () {
|
895
|
+
var that = this,
|
896
|
+
offset,
|
897
|
+
i, l,
|
898
|
+
els,
|
899
|
+
pos = 0,
|
900
|
+
page = 0;
|
901
|
+
|
902
|
+
if (that.scale < that.options.zoomMin) that.scale = that.options.zoomMin;
|
903
|
+
that.wrapperW = that.wrapper.clientWidth || 1;
|
904
|
+
that.wrapperH = that.wrapper.clientHeight || 1;
|
905
|
+
|
906
|
+
that.minScrollY = -that.options.topOffset || 0;
|
907
|
+
that.scrollerW = mround(that.scroller.offsetWidth * that.scale);
|
908
|
+
that.scrollerH = mround((that.scroller.offsetHeight + that.minScrollY) * that.scale);
|
909
|
+
that.maxScrollX = that.wrapperW - that.scrollerW;
|
910
|
+
that.maxScrollY = that.wrapperH - that.scrollerH + that.minScrollY;
|
911
|
+
that.dirX = 0;
|
912
|
+
that.dirY = 0;
|
913
|
+
|
914
|
+
if (that.options.onRefresh) that.options.onRefresh.call(that);
|
915
|
+
|
916
|
+
that.hScroll = that.options.hScroll && that.maxScrollX < 0;
|
917
|
+
that.vScroll = that.options.vScroll && (!that.options.bounceLock && !that.hScroll || that.scrollerH > that.wrapperH);
|
918
|
+
|
919
|
+
that.hScrollbar = that.hScroll && that.options.hScrollbar;
|
920
|
+
that.vScrollbar = that.vScroll && that.options.vScrollbar && that.scrollerH > that.wrapperH;
|
921
|
+
|
922
|
+
offset = that._offset(that.wrapper);
|
923
|
+
that.wrapperOffsetLeft = -offset.left;
|
924
|
+
that.wrapperOffsetTop = -offset.top;
|
925
|
+
|
926
|
+
// Prepare snap
|
927
|
+
if (typeof that.options.snap == 'string') {
|
928
|
+
that.pagesX = [];
|
929
|
+
that.pagesY = [];
|
930
|
+
els = that.scroller.querySelectorAll(that.options.snap);
|
931
|
+
for (i=0, l=els.length; i<l; i++) {
|
932
|
+
pos = that._offset(els[i]);
|
933
|
+
pos.left += that.wrapperOffsetLeft;
|
934
|
+
pos.top += that.wrapperOffsetTop;
|
935
|
+
that.pagesX[i] = pos.left < that.maxScrollX ? that.maxScrollX : pos.left * that.scale;
|
936
|
+
that.pagesY[i] = pos.top < that.maxScrollY ? that.maxScrollY : pos.top * that.scale;
|
937
|
+
}
|
938
|
+
} else if (that.options.snap) {
|
939
|
+
that.pagesX = [];
|
940
|
+
while (pos >= that.maxScrollX) {
|
941
|
+
that.pagesX[page] = pos;
|
942
|
+
pos = pos - that.wrapperW;
|
943
|
+
page++;
|
944
|
+
}
|
945
|
+
if (that.maxScrollX%that.wrapperW) that.pagesX[that.pagesX.length] = that.maxScrollX - that.pagesX[that.pagesX.length-1] + that.pagesX[that.pagesX.length-1];
|
946
|
+
|
947
|
+
pos = 0;
|
948
|
+
page = 0;
|
949
|
+
that.pagesY = [];
|
950
|
+
while (pos >= that.maxScrollY) {
|
951
|
+
that.pagesY[page] = pos;
|
952
|
+
pos = pos - that.wrapperH;
|
953
|
+
page++;
|
954
|
+
}
|
955
|
+
if (that.maxScrollY%that.wrapperH) that.pagesY[that.pagesY.length] = that.maxScrollY - that.pagesY[that.pagesY.length-1] + that.pagesY[that.pagesY.length-1];
|
956
|
+
}
|
957
|
+
|
958
|
+
// Prepare the scrollbars
|
959
|
+
that._scrollbar('h');
|
960
|
+
that._scrollbar('v');
|
961
|
+
|
962
|
+
if (!that.zoomed) {
|
963
|
+
that.scroller.style[vendor + 'TransitionDuration'] = '0';
|
964
|
+
that._resetPos(200);
|
965
|
+
}
|
966
|
+
},
|
967
|
+
|
968
|
+
scrollTo: function (x, y, time, relative) {
|
969
|
+
var that = this,
|
970
|
+
step = x,
|
971
|
+
i, l;
|
972
|
+
|
973
|
+
that.stop();
|
974
|
+
|
975
|
+
if (!step.length) step = [{ x: x, y: y, time: time, relative: relative }];
|
976
|
+
|
977
|
+
for (i=0, l=step.length; i<l; i++) {
|
978
|
+
if (step[i].relative) { step[i].x = that.x - step[i].x; step[i].y = that.y - step[i].y; }
|
979
|
+
that.steps.push({ x: step[i].x, y: step[i].y, time: step[i].time || 0 });
|
980
|
+
}
|
981
|
+
|
982
|
+
that._startAni();
|
983
|
+
},
|
984
|
+
|
985
|
+
scrollToElement: function (el, time) {
|
986
|
+
var that = this, pos;
|
987
|
+
el = el.nodeType ? el : that.scroller.querySelector(el);
|
988
|
+
if (!el) return;
|
989
|
+
|
990
|
+
pos = that._offset(el);
|
991
|
+
pos.left += that.wrapperOffsetLeft;
|
992
|
+
pos.top += that.wrapperOffsetTop;
|
993
|
+
|
994
|
+
pos.left = pos.left > 0 ? 0 : pos.left < that.maxScrollX ? that.maxScrollX : pos.left;
|
995
|
+
pos.top = pos.top > that.minScrollY ? that.minScrollY : pos.top < that.maxScrollY ? that.maxScrollY : pos.top;
|
996
|
+
time = time === undefined ? m.max(m.abs(pos.left)*2, m.abs(pos.top)*2) : time;
|
997
|
+
|
998
|
+
that.scrollTo(pos.left, pos.top, time);
|
999
|
+
},
|
1000
|
+
|
1001
|
+
scrollToPage: function (pageX, pageY, time) {
|
1002
|
+
var that = this, x, y;
|
1003
|
+
|
1004
|
+
time = time === undefined ? 400 : time;
|
1005
|
+
|
1006
|
+
if (that.options.onScrollStart) that.options.onScrollStart.call(that);
|
1007
|
+
|
1008
|
+
if (that.options.snap) {
|
1009
|
+
pageX = pageX == 'next' ? that.currPageX+1 : pageX == 'prev' ? that.currPageX-1 : pageX;
|
1010
|
+
pageY = pageY == 'next' ? that.currPageY+1 : pageY == 'prev' ? that.currPageY-1 : pageY;
|
1011
|
+
|
1012
|
+
pageX = pageX < 0 ? 0 : pageX > that.pagesX.length-1 ? that.pagesX.length-1 : pageX;
|
1013
|
+
pageY = pageY < 0 ? 0 : pageY > that.pagesY.length-1 ? that.pagesY.length-1 : pageY;
|
1014
|
+
|
1015
|
+
that.currPageX = pageX;
|
1016
|
+
that.currPageY = pageY;
|
1017
|
+
x = that.pagesX[pageX];
|
1018
|
+
y = that.pagesY[pageY];
|
1019
|
+
} else {
|
1020
|
+
x = -that.wrapperW * pageX;
|
1021
|
+
y = -that.wrapperH * pageY;
|
1022
|
+
if (x < that.maxScrollX) x = that.maxScrollX;
|
1023
|
+
if (y < that.maxScrollY) y = that.maxScrollY;
|
1024
|
+
}
|
1025
|
+
|
1026
|
+
that.scrollTo(x, y, time);
|
1027
|
+
},
|
1028
|
+
|
1029
|
+
disable: function () {
|
1030
|
+
this.stop();
|
1031
|
+
this._resetPos(0);
|
1032
|
+
this.enabled = false;
|
1033
|
+
|
1034
|
+
// If disabled after touchstart we make sure that there are no left over events
|
1035
|
+
this._unbind(MOVE_EV);
|
1036
|
+
this._unbind(END_EV);
|
1037
|
+
this._unbind(CANCEL_EV);
|
1038
|
+
},
|
1039
|
+
|
1040
|
+
enable: function () {
|
1041
|
+
this.enabled = true;
|
1042
|
+
},
|
1043
|
+
|
1044
|
+
stop: function () {
|
1045
|
+
if (this.options.useTransition) this._unbind('webkitTransitionEnd');
|
1046
|
+
else cancelFrame(this.aniTime);
|
1047
|
+
this.steps = [];
|
1048
|
+
this.moved = false;
|
1049
|
+
this.animating = false;
|
1050
|
+
},
|
1051
|
+
|
1052
|
+
zoom: function (x, y, scale, time) {
|
1053
|
+
var that = this,
|
1054
|
+
relScale = scale / that.scale;
|
1055
|
+
|
1056
|
+
if (!that.options.useTransform) return;
|
1057
|
+
|
1058
|
+
that.zoomed = true;
|
1059
|
+
time = time === undefined ? 200 : time;
|
1060
|
+
x = x - that.wrapperOffsetLeft - that.x;
|
1061
|
+
y = y - that.wrapperOffsetTop - that.y;
|
1062
|
+
that.x = x - x * relScale + that.x;
|
1063
|
+
that.y = y - y * relScale + that.y;
|
1064
|
+
|
1065
|
+
that.scale = scale;
|
1066
|
+
that.refresh();
|
1067
|
+
|
1068
|
+
that.x = that.x > 0 ? 0 : that.x < that.maxScrollX ? that.maxScrollX : that.x;
|
1069
|
+
that.y = that.y > that.minScrollY ? that.minScrollY : that.y < that.maxScrollY ? that.maxScrollY : that.y;
|
1070
|
+
|
1071
|
+
that.scroller.style[vendor + 'TransitionDuration'] = time + 'ms';
|
1072
|
+
that.scroller.style[vendor + 'Transform'] = trnOpen + that.x + 'px,' + that.y + 'px' + trnClose + ' scale(' + scale + ')';
|
1073
|
+
that.zoomed = false;
|
1074
|
+
},
|
1075
|
+
|
1076
|
+
isReady: function () {
|
1077
|
+
return !this.moved && !this.zoomed && !this.animating;
|
1078
|
+
}
|
1079
|
+
};
|
1080
|
+
|
1081
|
+
if (typeof exports !== 'undefined') exports.iScroll = iScroll;
|
1082
|
+
else window.iScroll = iScroll;
|
1083
|
+
|
1084
|
+
})();
|