Compare commits
3 Commits
master
...
asset_alia
Author | SHA1 | Date | |
---|---|---|---|
|
4316e602a1 | ||
|
671ef6c376 | ||
|
d75604d654 |
13
.gitignore
vendored
@ -1,6 +1,6 @@
|
|||||||
.bundle
|
.bundle
|
||||||
db/*.sqlite3
|
db/*.sqlite3
|
||||||
log
|
log/*.log
|
||||||
tmp/**/*
|
tmp/**/*
|
||||||
.DS_Store
|
.DS_Store
|
||||||
rerun.txt
|
rerun.txt
|
||||||
@ -30,16 +30,9 @@ Capfile
|
|||||||
config/deploy.rb
|
config/deploy.rb
|
||||||
perf/*.rb
|
perf/*.rb
|
||||||
gem_graph.png
|
gem_graph.png
|
||||||
|
sites/
|
||||||
permanent
|
permanent
|
||||||
doc/bushido
|
doc/bushido
|
||||||
*.swp
|
*.swp
|
||||||
.sass-cache/
|
|
||||||
spec/dummy/public/sites
|
|
||||||
/spec/dummy/tmp/
|
|
||||||
/spec/dummy/spec/tmp
|
|
||||||
/spec/dummy/log/*.log
|
|
||||||
/spec/dummy/tmp/**/*
|
|
||||||
app/assets/javascripts/old/
|
|
||||||
app/assets/stylesheets/old/
|
|
||||||
.rbenv-gemsets
|
|
||||||
|
|
||||||
|
@ -11,4 +11,3 @@ notifications:
|
|||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
- 1.0-stable
|
|
||||||
|
111
Gemfile
Executable file → Normal file
@ -1,55 +1,86 @@
|
|||||||
#!/usr/bin/env bundle
|
|
||||||
# encoding: utf-8
|
|
||||||
|
|
||||||
source :rubygems
|
source :rubygems
|
||||||
|
|
||||||
gemspec # Include gemspec dependencies
|
# add in all the runtime dependencies
|
||||||
|
|
||||||
# The rest of the dependencies are for use when in the locomotive development environment
|
gem 'rake', '0.9.2'
|
||||||
|
|
||||||
|
gem 'rails', '3.0.10'
|
||||||
|
|
||||||
|
gem 'warden'
|
||||||
|
gem 'devise', '~>1.5.0'
|
||||||
|
gem 'devise_bushido_authenticatable', '1.0.0.alpha10', :require => 'devise_cas_authenticatable'
|
||||||
|
|
||||||
|
gem 'mongo', '~> 1.3.1'
|
||||||
|
gem 'bson', '~> 1.3.1'
|
||||||
|
gem 'bson_ext', '~> 1.3.1'
|
||||||
|
gem 'mongoid', '~> 2.0.2'
|
||||||
|
gem 'locomotive_mongoid_acts_as_tree', '0.1.5.7', :require => 'mongoid_acts_as_tree'
|
||||||
|
gem 'kaminari'
|
||||||
|
|
||||||
|
gem 'haml', '3.1.2'
|
||||||
|
gem 'sass', '3.1.2'
|
||||||
|
gem 'locomotive_liquid', '2.2.2', :require => 'liquid'
|
||||||
|
gem 'formtastic', '~> 1.2.3'
|
||||||
|
gem 'inherited_resources', '~> 1.1.2'
|
||||||
|
|
||||||
|
gem 'rmagick', '2.12.2', :require => 'RMagick'
|
||||||
|
gem 'carrierwave', '0.5.6'
|
||||||
|
gem 'dragonfly', '~> 0.9.1'
|
||||||
|
gem 'rack-cache', :require => 'rack/cache'
|
||||||
|
|
||||||
|
gem 'custom_fields', '1.0.0.beta.25'
|
||||||
|
gem 'cancan'
|
||||||
|
gem 'fog', '0.8.2'
|
||||||
|
gem 'mimetype-fu'
|
||||||
|
gem 'actionmailer-with-request', :require => 'actionmailer_with_request'
|
||||||
|
gem 'heroku', '1.19.1'
|
||||||
|
gem 'httparty', '0.7.8'
|
||||||
|
gem 'RedCloth', '4.2.9'
|
||||||
|
gem 'delayed_job_mongoid', '1.0.8'
|
||||||
|
gem 'rubyzip'
|
||||||
|
gem 'locomotive_jammit-s3', :require => 'jammit-s3'
|
||||||
|
gem 'SystemTimer', :platforms => :ruby_18
|
||||||
|
gem 'cells', '3.8.0'
|
||||||
|
gem 'sanitize'
|
||||||
|
gem 'highline'
|
||||||
|
|
||||||
|
# The rest of the dependencies are for use when in the locomotive dev environment
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
# gem 'custom_fields', :path => '../gems/custom_fields' # for Developers
|
|
||||||
# gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git', :branch => '2.0.0.rc' # Branch on Github
|
|
||||||
|
|
||||||
# gem 'locomotive-aloha-rails', :path => '../gems/aloha-rails' # for Developers
|
|
||||||
|
|
||||||
gem 'rspec-rails', '~> 2.8.0' # In order to have rspec tasks and generators
|
|
||||||
gem 'rspec-cells'
|
|
||||||
|
|
||||||
gem 'unicorn' # Using unicorn_rails instead of webrick (default server)
|
gem 'unicorn' # Using unicorn_rails instead of webrick (default server)
|
||||||
|
|
||||||
|
gem 'rspec-rails', '2.6.1' # in order to have rspec tasks and generators
|
||||||
|
|
||||||
|
gem 'rspec-cells'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :assets do
|
group :test, :development do
|
||||||
gem 'sass-rails', '~> 3.2.4'
|
gem 'linecache', '0.43', :platforms => :mri_18
|
||||||
gem 'coffee-rails', '~> 3.2.2'
|
gem 'ruby-debug', :platforms => :mri_18
|
||||||
gem 'uglifier', '~> 1.2.4'
|
gem 'ruby-debug19', :platforms => :mri_19
|
||||||
gem 'compass-rails'
|
|
||||||
|
gem 'bushido_stub', '0.0.3'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'launchy'
|
gem 'cucumber-rails', '1.2.0', :require => false
|
||||||
|
gem 'autotest', :platforms => :mri
|
||||||
# gem 'autotest', :platforms => :mri
|
gem 'ZenTest', :platforms => :mri
|
||||||
# gem 'ZenTest', :platforms => :mri
|
gem 'growl-glue'
|
||||||
|
gem 'rspec-rails', '2.6.1'
|
||||||
# gem 'growl-glue'
|
gem 'factory_girl_rails', '~> 1.3.0'
|
||||||
|
gem 'pickle'
|
||||||
gem 'cucumber-rails', :require => false
|
gem 'xpath', '~> 0.1.4'
|
||||||
gem 'poltergeist'
|
gem 'capybara'
|
||||||
gem 'rspec-rails', '~> 2.8.0'
|
gem 'database_cleaner'
|
||||||
gem 'shoulda-matchers'
|
gem 'shoulda-matchers'
|
||||||
|
|
||||||
gem 'factory_girl_rails', '~> 1.6.0'
|
gem 'spork', '~> 0.9.0.rc'
|
||||||
gem 'pickle'
|
gem 'launchy'
|
||||||
gem 'mocha', '0.9.12' # :git => 'git://github.com/floehopper/mocha.git'
|
gem 'mocha', '0.9.12' # :git => 'git://github.com/floehopper/mocha.git'
|
||||||
|
|
||||||
gem 'capybara'
|
|
||||||
|
|
||||||
gem 'xpath', '~> 0.1.4'
|
|
||||||
|
|
||||||
gem 'json_spec'
|
|
||||||
|
|
||||||
gem 'database_cleaner'
|
|
||||||
|
|
||||||
# gem 'debugger', :git => 'git://github.com/cldwalker/debugger.git'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
group :production do
|
||||||
|
gem 'bushido', '0.0.35'
|
||||||
|
end
|
||||||
|
|
||||||
|
519
Gemfile.lock
@ -1,83 +1,57 @@
|
|||||||
PATH
|
|
||||||
remote: .
|
|
||||||
specs:
|
|
||||||
locomotive_cms (2.0.0.rc8)
|
|
||||||
RedCloth (~> 4.2.8)
|
|
||||||
actionmailer-with-request (~> 0.3.0)
|
|
||||||
bson_ext (~> 1.5.2)
|
|
||||||
cancan (~> 1.6.7)
|
|
||||||
carrierwave-mongoid (~> 0.2.1)
|
|
||||||
cells (~> 3.8.0)
|
|
||||||
codemirror-rails (~> 2.21)
|
|
||||||
custom_fields (~> 2.0.0.rc12)
|
|
||||||
devise (~> 2.1.0)
|
|
||||||
devise-encryptable (~> 0.1.1)
|
|
||||||
dragonfly (~> 0.9.8)
|
|
||||||
flash_cookie_session (~> 1.1.1)
|
|
||||||
fog (~> 1.3.1)
|
|
||||||
formtastic (~> 2.0.2)
|
|
||||||
haml (~> 3.1.6)
|
|
||||||
highline (~> 1.6.2)
|
|
||||||
httparty (~> 0.8.1)
|
|
||||||
jquery-rails (~> 1.0.19)
|
|
||||||
kaminari (~> 0.13.0)
|
|
||||||
locomotive-aloha-rails (~> 0.20.1.4)
|
|
||||||
locomotive-mongoid-tree (~> 0.6.2)
|
|
||||||
locomotive-tinymce-rails (~> 3.4.7.2)
|
|
||||||
locomotive_liquid (= 2.2.2)
|
|
||||||
mimetype-fu (~> 0.1.2)
|
|
||||||
mongo (~> 1.5.2)
|
|
||||||
mongoid (~> 2.4.9)
|
|
||||||
multi_json (~> 1.3.4)
|
|
||||||
rack-cache (~> 1.1)
|
|
||||||
rails (~> 3.2.5)
|
|
||||||
rails-backbone (~> 0.6.1)
|
|
||||||
rake (~> 0.9.2)
|
|
||||||
responders (~> 0.6.4)
|
|
||||||
rmagick (~> 2.12.2)
|
|
||||||
sanitize (~> 2.0.3)
|
|
||||||
unidecoder (~> 1.1.1)
|
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
|
POpen4 (0.1.4)
|
||||||
|
Platform (>= 0.4.0)
|
||||||
|
open4
|
||||||
|
Platform (0.4.0)
|
||||||
RedCloth (4.2.9)
|
RedCloth (4.2.9)
|
||||||
actionmailer (3.2.5)
|
SystemTimer (1.2.3)
|
||||||
actionpack (= 3.2.5)
|
ZenTest (4.6.2)
|
||||||
mail (~> 2.4.4)
|
abstract (1.0.0)
|
||||||
|
actionmailer (3.0.10)
|
||||||
|
actionpack (= 3.0.10)
|
||||||
|
mail (~> 2.2.19)
|
||||||
actionmailer-with-request (0.3.0)
|
actionmailer-with-request (0.3.0)
|
||||||
rails (>= 3)
|
rails (>= 3)
|
||||||
actionpack (3.2.5)
|
actionpack (3.0.10)
|
||||||
activemodel (= 3.2.5)
|
activemodel (= 3.0.10)
|
||||||
activesupport (= 3.2.5)
|
activesupport (= 3.0.10)
|
||||||
builder (~> 3.0.0)
|
builder (~> 2.1.2)
|
||||||
erubis (~> 2.7.0)
|
erubis (~> 2.6.6)
|
||||||
journey (~> 1.0.1)
|
i18n (~> 0.5.0)
|
||||||
rack (~> 1.4.0)
|
rack (~> 1.2.1)
|
||||||
rack-cache (~> 1.2)
|
rack-mount (~> 0.6.14)
|
||||||
rack-test (~> 0.6.1)
|
rack-test (~> 0.5.7)
|
||||||
sprockets (~> 2.1.3)
|
tzinfo (~> 0.3.23)
|
||||||
activemodel (3.2.5)
|
activemodel (3.0.10)
|
||||||
activesupport (= 3.2.5)
|
activesupport (= 3.0.10)
|
||||||
builder (~> 3.0.0)
|
builder (~> 2.1.2)
|
||||||
activerecord (3.2.5)
|
i18n (~> 0.5.0)
|
||||||
activemodel (= 3.2.5)
|
activerecord (3.0.10)
|
||||||
activesupport (= 3.2.5)
|
activemodel (= 3.0.10)
|
||||||
arel (~> 3.0.2)
|
activesupport (= 3.0.10)
|
||||||
tzinfo (~> 0.3.29)
|
arel (~> 2.0.10)
|
||||||
activeresource (3.2.5)
|
tzinfo (~> 0.3.23)
|
||||||
activemodel (= 3.2.5)
|
activeresource (3.0.10)
|
||||||
activesupport (= 3.2.5)
|
activemodel (= 3.0.10)
|
||||||
activesupport (3.2.5)
|
activesupport (= 3.0.10)
|
||||||
i18n (~> 0.6)
|
activesupport (3.0.10)
|
||||||
multi_json (~> 1.0)
|
archive-tar-minitar (0.5.2)
|
||||||
addressable (2.2.8)
|
arel (2.0.10)
|
||||||
arel (3.0.2)
|
autotest (4.4.6)
|
||||||
|
ZenTest (>= 4.4.1)
|
||||||
bcrypt-ruby (3.0.1)
|
bcrypt-ruby (3.0.1)
|
||||||
bson (1.5.2)
|
bson (1.3.1)
|
||||||
bson_ext (1.5.2)
|
bson_ext (1.3.1)
|
||||||
bson (= 1.5.2)
|
builder (2.1.2)
|
||||||
builder (3.0.0)
|
bushido (0.0.35)
|
||||||
|
highline (>= 1.6.1)
|
||||||
|
json (>= 1.4.6)
|
||||||
|
orm_adapter (~> 0.0.3)
|
||||||
|
rest-client (>= 1.6.1)
|
||||||
|
bushido_stub (0.0.3)
|
||||||
|
activesupport (>= 3.0.7)
|
||||||
cancan (1.6.7)
|
cancan (1.6.7)
|
||||||
capybara (1.1.2)
|
capybara (1.1.2)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
@ -86,260 +60,281 @@ GEM
|
|||||||
rack-test (>= 0.5.4)
|
rack-test (>= 0.5.4)
|
||||||
selenium-webdriver (~> 2.0)
|
selenium-webdriver (~> 2.0)
|
||||||
xpath (~> 0.1.4)
|
xpath (~> 0.1.4)
|
||||||
carrierwave (0.6.2)
|
carrierwave (0.5.6)
|
||||||
activemodel (>= 3.2.0)
|
activesupport (~> 3.0)
|
||||||
activesupport (>= 3.2.0)
|
cells (3.8.0)
|
||||||
carrierwave-mongoid (0.2.1)
|
|
||||||
carrierwave (~> 0.6.1)
|
|
||||||
mongoid (~> 2.1)
|
|
||||||
cells (3.8.5)
|
|
||||||
actionpack (~> 3.0)
|
actionpack (~> 3.0)
|
||||||
railties (~> 3.0)
|
railties (~> 3.0)
|
||||||
childprocess (0.3.2)
|
childprocess (0.2.5)
|
||||||
ffi (~> 1.0.6)
|
ffi (~> 1.0.6)
|
||||||
chunky_png (1.2.5)
|
columnize (0.3.6)
|
||||||
codemirror-rails (2.24)
|
configuration (1.3.1)
|
||||||
railties (~> 3.0)
|
crack (0.1.8)
|
||||||
coffee-rails (3.2.2)
|
cucumber (1.1.4)
|
||||||
coffee-script (>= 2.2.0)
|
|
||||||
railties (~> 3.2.0)
|
|
||||||
coffee-script (2.2.0)
|
|
||||||
coffee-script-source
|
|
||||||
execjs
|
|
||||||
coffee-script-source (1.3.3)
|
|
||||||
compass (0.12.1)
|
|
||||||
chunky_png (~> 1.2)
|
|
||||||
fssm (>= 0.2.7)
|
|
||||||
sass (~> 3.1)
|
|
||||||
compass-rails (1.0.2)
|
|
||||||
compass (>= 0.12.0, < 0.14)
|
|
||||||
cucumber (1.2.1)
|
|
||||||
builder (>= 2.1.2)
|
builder (>= 2.1.2)
|
||||||
diff-lcs (>= 1.1.3)
|
diff-lcs (>= 1.1.2)
|
||||||
gherkin (~> 2.11.0)
|
gherkin (~> 2.7.1)
|
||||||
json (>= 1.4.6)
|
json (>= 1.4.6)
|
||||||
cucumber-rails (1.3.0)
|
term-ansicolor (>= 1.0.6)
|
||||||
capybara (>= 1.1.2)
|
cucumber-rails (1.2.0)
|
||||||
cucumber (>= 1.1.8)
|
capybara (>= 1.1.1)
|
||||||
|
cucumber (>= 1.1.1)
|
||||||
nokogiri (>= 1.5.0)
|
nokogiri (>= 1.5.0)
|
||||||
custom_fields (2.0.0.rc12)
|
custom_fields (1.0.0.beta.25)
|
||||||
activesupport (~> 3.2.1)
|
activesupport (~> 3.0.9)
|
||||||
carrierwave-mongoid (~> 0.2.1)
|
mongoid (= 2.0.2)
|
||||||
mongoid (~> 2.4.9)
|
database_cleaner (0.7.0)
|
||||||
database_cleaner (0.8.0)
|
delayed_job (3.0.0)
|
||||||
devise (2.1.0)
|
activesupport (~> 3.0)
|
||||||
|
delayed_job_mongoid (1.0.8)
|
||||||
|
delayed_job (~> 3.0.0)
|
||||||
|
mongoid (>= 2.0)
|
||||||
|
devise (1.5.3)
|
||||||
bcrypt-ruby (~> 3.0)
|
bcrypt-ruby (~> 3.0)
|
||||||
orm_adapter (~> 0.0.7)
|
orm_adapter (~> 0.0.3)
|
||||||
railties (~> 3.1)
|
warden (~> 1.1)
|
||||||
warden (~> 1.1.1)
|
devise_bushido_authenticatable (1.0.0.alpha10)
|
||||||
devise-encryptable (0.1.1)
|
devise
|
||||||
devise (>= 2.1.0.rc)
|
devise (>= 1.0.6)
|
||||||
|
rubycas-client (>= 2.2.1)
|
||||||
diff-lcs (1.1.3)
|
diff-lcs (1.1.3)
|
||||||
dragonfly (0.9.12)
|
dragonfly (0.9.9)
|
||||||
rack
|
rack
|
||||||
ejs (1.0.0)
|
erubis (2.6.6)
|
||||||
erubis (2.7.0)
|
abstract (>= 1.0.0)
|
||||||
eventmachine (0.12.10)
|
excon (0.6.6)
|
||||||
excon (0.13.4)
|
factory_girl (2.2.0)
|
||||||
execjs (1.4.0)
|
activesupport
|
||||||
multi_json (~> 1.0)
|
factory_girl_rails (1.3.0)
|
||||||
factory_girl (2.5.2)
|
factory_girl (~> 2.2.0)
|
||||||
activesupport (>= 2.3.9)
|
|
||||||
factory_girl_rails (1.6.0)
|
|
||||||
factory_girl (~> 2.5.0)
|
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
faye-websocket (0.4.5)
|
|
||||||
eventmachine (>= 0.12.0)
|
|
||||||
ffi (1.0.11)
|
ffi (1.0.11)
|
||||||
flash_cookie_session (1.1.3)
|
fog (0.8.2)
|
||||||
rails (~> 3.0)
|
|
||||||
fog (1.3.1)
|
|
||||||
builder
|
builder
|
||||||
excon (~> 0.13.0)
|
excon (~> 0.6.1)
|
||||||
formatador (~> 0.2.0)
|
formatador (>= 0.1.3)
|
||||||
|
json
|
||||||
mime-types
|
mime-types
|
||||||
multi_json (~> 1.0)
|
|
||||||
net-scp (~> 1.0.4)
|
|
||||||
net-ssh (>= 2.1.3)
|
net-ssh (>= 2.1.3)
|
||||||
nokogiri (~> 1.5.0)
|
nokogiri (>= 1.4.4)
|
||||||
ruby-hmac
|
ruby-hmac
|
||||||
formatador (0.2.3)
|
formatador (0.2.1)
|
||||||
formtastic (2.0.2)
|
formtastic (1.2.4)
|
||||||
rails (~> 3.0)
|
actionpack (>= 2.3.7)
|
||||||
fssm (0.2.9)
|
activesupport (>= 2.3.7)
|
||||||
gherkin (2.11.0)
|
i18n (~> 0.4)
|
||||||
|
gherkin (2.7.2)
|
||||||
json (>= 1.4.6)
|
json (>= 1.4.6)
|
||||||
haml (3.1.6)
|
growl-glue (1.0.7)
|
||||||
highline (1.6.12)
|
haml (3.1.2)
|
||||||
hike (1.2.1)
|
has_scope (0.5.1)
|
||||||
http_parser.rb (0.5.3)
|
heroku (1.19.1)
|
||||||
httparty (0.8.3)
|
activesupport (>= 2.1.0)
|
||||||
multi_json (~> 1.0)
|
launchy (~> 0.3.2)
|
||||||
multi_xml
|
rest-client (>= 1.4.0, < 1.7.0)
|
||||||
i18n (0.6.0)
|
highline (1.6.9)
|
||||||
journey (1.0.3)
|
httparty (0.7.8)
|
||||||
jquery-rails (1.0.19)
|
crack (= 0.1.8)
|
||||||
railties (~> 3.0)
|
i18n (0.5.0)
|
||||||
thor (~> 0.14)
|
inherited_resources (1.1.2)
|
||||||
json (1.7.3)
|
has_scope (~> 0.5.0)
|
||||||
json_spec (1.0.3)
|
responders (~> 0.6.0)
|
||||||
multi_json (~> 1.0)
|
jammit (0.6.5)
|
||||||
rspec (~> 2.0)
|
yui-compressor (>= 0.9.3)
|
||||||
|
json (1.6.5)
|
||||||
kaminari (0.13.0)
|
kaminari (0.13.0)
|
||||||
actionpack (>= 3.0.0)
|
actionpack (>= 3.0.0)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
kgio (2.7.4)
|
kgio (2.7.0)
|
||||||
launchy (2.1.0)
|
launchy (0.3.7)
|
||||||
addressable (~> 2.2.6)
|
configuration (>= 0.0.5)
|
||||||
libwebsocket (0.1.3)
|
rake (>= 0.8.1)
|
||||||
addressable
|
linecache (0.43)
|
||||||
locomotive-aloha-rails (0.20.1.4)
|
linecache19 (0.5.12)
|
||||||
actionpack (~> 3.2.1)
|
ruby_core_source (>= 0.1.4)
|
||||||
locomotive-mongoid-tree (0.6.2)
|
locomotive_jammit-s3 (0.5.4.4)
|
||||||
mongoid (~> 2.0)
|
jammit (>= 0.5.4)
|
||||||
locomotive-tinymce-rails (3.4.7.2)
|
mimemagic (>= 0.1.7)
|
||||||
actionpack (~> 3.0)
|
s3 (>= 0.3.7)
|
||||||
locomotive_liquid (2.2.2)
|
locomotive_liquid (2.2.2)
|
||||||
mail (2.4.4)
|
locomotive_mongoid_acts_as_tree (0.1.5.7)
|
||||||
|
mongoid (= 2.0.2)
|
||||||
|
mail (2.2.19)
|
||||||
|
activesupport (>= 2.3.6)
|
||||||
i18n (>= 0.4.0)
|
i18n (>= 0.4.0)
|
||||||
mime-types (~> 1.16)
|
mime-types (~> 1.16)
|
||||||
treetop (~> 1.4.8)
|
treetop (~> 1.4.8)
|
||||||
mime-types (1.18)
|
mime-types (1.17.2)
|
||||||
|
mimemagic (0.1.8)
|
||||||
mimetype-fu (0.1.2)
|
mimetype-fu (0.1.2)
|
||||||
mocha (0.9.12)
|
mocha (0.9.12)
|
||||||
mongo (1.5.2)
|
mongo (1.3.1)
|
||||||
bson (= 1.5.2)
|
bson (>= 1.3.1)
|
||||||
mongoid (2.4.11)
|
mongoid (2.0.2)
|
||||||
activemodel (~> 3.1)
|
activemodel (~> 3.0)
|
||||||
mongo (<= 1.6.2)
|
mongo (~> 1.3)
|
||||||
tzinfo (~> 0.3.22)
|
tzinfo (~> 0.3.22)
|
||||||
multi_json (1.3.6)
|
multi_json (1.0.4)
|
||||||
multi_xml (0.5.1)
|
net-ssh (2.2.2)
|
||||||
net-scp (1.0.4)
|
nokogiri (1.5.0)
|
||||||
net-ssh (>= 1.99.1)
|
open4 (1.3.0)
|
||||||
net-ssh (2.5.2)
|
orm_adapter (0.0.6)
|
||||||
nokogiri (1.5.3)
|
|
||||||
orm_adapter (0.0.7)
|
|
||||||
pickle (0.4.10)
|
pickle (0.4.10)
|
||||||
cucumber (>= 0.8)
|
cucumber (>= 0.8)
|
||||||
rake
|
rake
|
||||||
poltergeist (0.6.0)
|
|
||||||
capybara (~> 1.0)
|
|
||||||
childprocess (~> 0.3)
|
|
||||||
faye-websocket (~> 0.4, >= 0.4.4)
|
|
||||||
http_parser.rb (~> 0.5.3)
|
|
||||||
multi_json (~> 1.0)
|
|
||||||
polyglot (0.3.3)
|
polyglot (0.3.3)
|
||||||
rack (1.4.1)
|
proxies (0.2.1)
|
||||||
rack-cache (1.2)
|
rack (1.2.5)
|
||||||
|
rack-cache (1.1)
|
||||||
rack (>= 0.4)
|
rack (>= 0.4)
|
||||||
rack-ssl (1.3.2)
|
rack-mount (0.6.14)
|
||||||
rack
|
rack (>= 1.0.0)
|
||||||
rack-test (0.6.1)
|
rack-test (0.5.7)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
rails (3.2.5)
|
rails (3.0.10)
|
||||||
actionmailer (= 3.2.5)
|
actionmailer (= 3.0.10)
|
||||||
actionpack (= 3.2.5)
|
actionpack (= 3.0.10)
|
||||||
activerecord (= 3.2.5)
|
activerecord (= 3.0.10)
|
||||||
activeresource (= 3.2.5)
|
activeresource (= 3.0.10)
|
||||||
activesupport (= 3.2.5)
|
activesupport (= 3.0.10)
|
||||||
bundler (~> 1.0)
|
bundler (~> 1.0)
|
||||||
railties (= 3.2.5)
|
railties (= 3.0.10)
|
||||||
rails-backbone (0.6.1)
|
railties (3.0.10)
|
||||||
coffee-script (~> 2.2.0)
|
actionpack (= 3.0.10)
|
||||||
ejs (~> 1.0.0)
|
activesupport (= 3.0.10)
|
||||||
railties (>= 3.1.0)
|
|
||||||
railties (3.2.5)
|
|
||||||
actionpack (= 3.2.5)
|
|
||||||
activesupport (= 3.2.5)
|
|
||||||
rack-ssl (~> 1.3.2)
|
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
rdoc (~> 3.4)
|
rdoc (~> 3.4)
|
||||||
thor (>= 0.14.6, < 2.0)
|
thor (~> 0.14.4)
|
||||||
raindrops (0.9.0)
|
raindrops (0.8.0)
|
||||||
rake (0.9.2.2)
|
rake (0.9.2)
|
||||||
rdoc (3.12)
|
rdoc (3.12)
|
||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
responders (0.6.5)
|
responders (0.6.4)
|
||||||
|
rest-client (1.6.7)
|
||||||
|
mime-types (>= 1.16)
|
||||||
rmagick (2.12.2)
|
rmagick (2.12.2)
|
||||||
rspec (2.8.0)
|
rspec (2.6.0)
|
||||||
rspec-core (~> 2.8.0)
|
rspec-core (~> 2.6.0)
|
||||||
rspec-expectations (~> 2.8.0)
|
rspec-expectations (~> 2.6.0)
|
||||||
rspec-mocks (~> 2.8.0)
|
rspec-mocks (~> 2.6.0)
|
||||||
rspec-cells (0.1.2)
|
rspec-cells (0.1.1)
|
||||||
cells (~> 3.4)
|
|
||||||
rails (~> 3.0)
|
rails (~> 3.0)
|
||||||
rspec-rails (~> 2.2)
|
rspec-rails (~> 2.2)
|
||||||
rspec-core (2.8.0)
|
rspec-core (2.6.4)
|
||||||
rspec-expectations (2.8.0)
|
rspec-expectations (2.6.0)
|
||||||
diff-lcs (~> 1.1.2)
|
diff-lcs (~> 1.1.2)
|
||||||
rspec-mocks (2.8.0)
|
rspec-mocks (2.6.0)
|
||||||
rspec-rails (2.8.1)
|
rspec-rails (2.6.1)
|
||||||
actionpack (>= 3.0)
|
actionpack (~> 3.0)
|
||||||
activesupport (>= 3.0)
|
activesupport (~> 3.0)
|
||||||
railties (>= 3.0)
|
railties (~> 3.0)
|
||||||
rspec (~> 2.8.0)
|
rspec (~> 2.6.0)
|
||||||
|
ruby-debug (0.10.4)
|
||||||
|
columnize (>= 0.1)
|
||||||
|
ruby-debug-base (~> 0.10.4.0)
|
||||||
|
ruby-debug-base (0.10.4)
|
||||||
|
linecache (>= 0.3)
|
||||||
|
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)
|
||||||
ruby-hmac (0.4.0)
|
ruby-hmac (0.4.0)
|
||||||
rubyzip (0.9.8)
|
ruby_core_source (0.1.5)
|
||||||
|
archive-tar-minitar (>= 0.5.2)
|
||||||
|
rubycas-client (2.3.8)
|
||||||
|
activesupport
|
||||||
|
rubyzip (0.9.5)
|
||||||
|
s3 (0.3.11)
|
||||||
|
proxies (~> 0.2.0)
|
||||||
sanitize (2.0.3)
|
sanitize (2.0.3)
|
||||||
nokogiri (>= 1.4.4, < 1.6)
|
nokogiri (>= 1.4.4, < 1.6)
|
||||||
sass (3.1.19)
|
sass (3.1.2)
|
||||||
sass-rails (3.2.5)
|
selenium-webdriver (2.16.0)
|
||||||
railties (~> 3.2.0)
|
|
||||||
sass (>= 3.1.10)
|
|
||||||
tilt (~> 1.3)
|
|
||||||
selenium-webdriver (2.22.2)
|
|
||||||
childprocess (>= 0.2.5)
|
childprocess (>= 0.2.5)
|
||||||
ffi (~> 1.0)
|
ffi (~> 1.0.9)
|
||||||
libwebsocket (~> 0.1.3)
|
multi_json (~> 1.0.4)
|
||||||
multi_json (~> 1.0)
|
|
||||||
rubyzip
|
rubyzip
|
||||||
shoulda-matchers (1.1.0)
|
shoulda-matchers (1.0.0)
|
||||||
activesupport (>= 3.0.0)
|
spork (0.9.0.rc9)
|
||||||
sprockets (2.1.3)
|
term-ansicolor (1.0.7)
|
||||||
hike (~> 1.2)
|
thor (0.14.6)
|
||||||
rack (~> 1.0)
|
|
||||||
tilt (~> 1.1, != 1.3.0)
|
|
||||||
thor (0.15.2)
|
|
||||||
tilt (1.3.3)
|
|
||||||
treetop (1.4.10)
|
treetop (1.4.10)
|
||||||
polyglot
|
polyglot
|
||||||
polyglot (>= 0.3.1)
|
polyglot (>= 0.3.1)
|
||||||
tzinfo (0.3.33)
|
tzinfo (0.3.31)
|
||||||
uglifier (1.2.4)
|
unicorn (4.1.1)
|
||||||
execjs (>= 0.3.0)
|
kgio (~> 2.4)
|
||||||
multi_json (>= 1.0.2)
|
|
||||||
unicorn (4.3.1)
|
|
||||||
kgio (~> 2.6)
|
|
||||||
rack
|
rack
|
||||||
raindrops (~> 0.7)
|
raindrops (~> 0.6)
|
||||||
unidecoder (1.1.1)
|
warden (1.1.0)
|
||||||
warden (1.1.1)
|
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
xpath (0.1.4)
|
xpath (0.1.4)
|
||||||
nokogiri (~> 1.3)
|
nokogiri (~> 1.3)
|
||||||
|
yui-compressor (0.9.6)
|
||||||
|
POpen4 (>= 0.1.4)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
RedCloth (= 4.2.9)
|
||||||
|
SystemTimer
|
||||||
|
ZenTest
|
||||||
|
actionmailer-with-request
|
||||||
|
autotest
|
||||||
|
bson (~> 1.3.1)
|
||||||
|
bson_ext (~> 1.3.1)
|
||||||
|
bushido (= 0.0.35)
|
||||||
|
bushido_stub (= 0.0.3)
|
||||||
|
cancan
|
||||||
capybara
|
capybara
|
||||||
coffee-rails (~> 3.2.2)
|
carrierwave (= 0.5.6)
|
||||||
compass-rails
|
cells (= 3.8.0)
|
||||||
cucumber-rails
|
cucumber-rails (= 1.2.0)
|
||||||
|
custom_fields (= 1.0.0.beta.25)
|
||||||
database_cleaner
|
database_cleaner
|
||||||
factory_girl_rails (~> 1.6.0)
|
delayed_job_mongoid (= 1.0.8)
|
||||||
json_spec
|
devise (~> 1.5.0)
|
||||||
|
devise_bushido_authenticatable (= 1.0.0.alpha10)
|
||||||
|
dragonfly (~> 0.9.1)
|
||||||
|
factory_girl_rails (~> 1.3.0)
|
||||||
|
fog (= 0.8.2)
|
||||||
|
formtastic (~> 1.2.3)
|
||||||
|
growl-glue
|
||||||
|
haml (= 3.1.2)
|
||||||
|
heroku (= 1.19.1)
|
||||||
|
highline
|
||||||
|
httparty (= 0.7.8)
|
||||||
|
inherited_resources (~> 1.1.2)
|
||||||
|
kaminari
|
||||||
launchy
|
launchy
|
||||||
locomotive_cms!
|
linecache (= 0.43)
|
||||||
|
locomotive_jammit-s3
|
||||||
|
locomotive_liquid (= 2.2.2)
|
||||||
|
locomotive_mongoid_acts_as_tree (= 0.1.5.7)
|
||||||
|
mimetype-fu
|
||||||
mocha (= 0.9.12)
|
mocha (= 0.9.12)
|
||||||
|
mongo (~> 1.3.1)
|
||||||
|
mongoid (~> 2.0.2)
|
||||||
pickle
|
pickle
|
||||||
poltergeist
|
rack-cache
|
||||||
|
rails (= 3.0.10)
|
||||||
|
rake (= 0.9.2)
|
||||||
|
rmagick (= 2.12.2)
|
||||||
rspec-cells
|
rspec-cells
|
||||||
rspec-rails (~> 2.8.0)
|
rspec-rails (= 2.6.1)
|
||||||
sass-rails (~> 3.2.4)
|
ruby-debug
|
||||||
|
ruby-debug19
|
||||||
|
rubyzip
|
||||||
|
sanitize
|
||||||
|
sass (= 3.1.2)
|
||||||
shoulda-matchers
|
shoulda-matchers
|
||||||
uglifier (~> 1.2.4)
|
spork (~> 0.9.0.rc)
|
||||||
unicorn
|
unicorn
|
||||||
|
warden
|
||||||
xpath (~> 0.1.4)
|
xpath (~> 0.1.4)
|
||||||
|
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
== MIT License
|
== MIT License
|
||||||
|
|
||||||
Copyright (c) 2010-2012, Didier Lafforgue.
|
Copyright (c) 2010, Didier Lafforgue.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -5,15 +5,13 @@ h1. Locomotive CMS
|
|||||||
|
|
||||||
Locomotive is a simple but powerful CMS based on liquid templates and mongodb database. At my company ("NoCoffee":http://www.nocoffee.fr), we use it for our clients when they request a simple website.
|
Locomotive is a simple but powerful CMS based on liquid templates and mongodb database. At my company ("NoCoffee":http://www.nocoffee.fr), we use it for our clients when they request a simple website.
|
||||||
|
|
||||||
If we have to give a couple of features to describe our application, there will be:
|
If we have to give only 5 main features to describe our application, there will be:
|
||||||
|
|
||||||
* managing as many websites as you want with one application instance
|
* managing as many websites as you want with one application instance
|
||||||
* nice looking UI (see http://www.locomotivecms.com for some screenshots)
|
* nice looking UI (see http://www.locomotivecms.com for some screenshots)
|
||||||
* flexible content types
|
* flexible content types
|
||||||
* content localization out of the box
|
* playing smoothly with Heroku and MongoHQ
|
||||||
* playing smoothly with Heroku, Bushido and MongoHQ
|
* inline editing (beta)
|
||||||
* inline editing (wip)
|
|
||||||
* API
|
|
||||||
|
|
||||||
h2. Strategy / Development status
|
h2. Strategy / Development status
|
||||||
|
|
||||||
@ -22,17 +20,16 @@ Now, our goal is to port our prototype to Rails 3 and migrate from mongomapper t
|
|||||||
|
|
||||||
h2. Gems
|
h2. Gems
|
||||||
|
|
||||||
Here is a short list of main gems / technologies used in the application.
|
Here is a short list of main gems used in the application.
|
||||||
|
|
||||||
* Rails 3.2.5
|
* Rails 3.0.10
|
||||||
* Mongoid 2.4.9 (with MongoDB 2.0)
|
* Mongoid 2.0.2 (with MongoDB 1.8)
|
||||||
* Liquid
|
* Liquid
|
||||||
* Devise
|
* Devise
|
||||||
* Carrierwave
|
* Carrierwave
|
||||||
* Haml
|
* Haml
|
||||||
* Formtastic
|
* Delayed job
|
||||||
* Cells
|
* Jammit-s3
|
||||||
* Coffeescript / Backbone / SASS
|
|
||||||
|
|
||||||
h2. Installation
|
h2. Installation
|
||||||
|
|
||||||
@ -40,13 +37,13 @@ See the "official website":http://www.locomotivecms.com
|
|||||||
|
|
||||||
h2. Upgrading
|
h2. Upgrading
|
||||||
|
|
||||||
We work on the procedure to upgrade from a previous version of the engine (below the 2.0.0)
|
If you wish to upgrade your locomotive install from an older version to the current 1.0.0rc1 then "please refer to the upgrade guide":http://www.locomotivecms.com/support/howto/upgrade
|
||||||
|
|
||||||
h2. Community
|
h2. Community
|
||||||
|
|
||||||
* Get help or discuss locomotive CMS at the "LocomotiveCMS Google group":https://groups.google.com/forum/?fromgroups#!forum/locomotivecms or the "LocomotiveCMS Discussion Forums":http://locomotive.vanillaforums.com/ (deprecated)
|
* Get help or discuss locomotive CMS at the "LocomotiveCMS Discussion Forums":http://locomotive.vanillaforums.com/
|
||||||
* Join us on IRC "#locomotivecms at irc.freenode.net!":http://webchat.freenode.net/
|
* Join us on IRC "#locomotivecms at irc.freenode.net!":http://webchat.freenode.net/
|
||||||
* "Follow us on twitter":http://twitter.com/locomotivecms
|
* "Follow us on twitter":http://twitter.com/locomotiveapp
|
||||||
|
|
||||||
h2. Contributing to Locomotive
|
h2. Contributing to Locomotive
|
||||||
|
|
||||||
@ -55,18 +52,17 @@ Locomotive CMS is an open source project, we encourage contributions. If you hav
|
|||||||
* Install ruby and mongoDB
|
* Install ruby and mongoDB
|
||||||
* Clone the project <code>git clone git@github.com:locomotivecms/engine.git</code>
|
* Clone the project <code>git clone git@github.com:locomotivecms/engine.git</code>
|
||||||
* Setup a virtual host entry for <code>test.example.com</code> to point to localhost
|
* Setup a virtual host entry for <code>test.example.com</code> to point to localhost
|
||||||
* Install PhantomJS (Required for the cucumber suite See: https://github.com/jonleighton/poltergeist)
|
|
||||||
* Run the tests <code>rake</code>
|
* Run the tests <code>rake</code>
|
||||||
* Write your failing tests
|
* Write your failing tests
|
||||||
* Make the tests pass
|
* Make the tests pass
|
||||||
* "Create a GitHub pull request":http://help.github.com/send-pull-requests
|
* "Create a GitHub pull request":http://help.github.com/send-pull-requests
|
||||||
|
|
||||||
For new features (especially large ones) it is best to create a topic on the "Google group":https://groups.google.com/forum/?fromgroups#!forum/locomotivecms first to make sure it fits into the goals of the project.
|
For new features (especially large ones) it is best to create a topic on the "discussion forums":http://locomotive.vanillaforums.com/ first to make sure it fits into the goals of the project.
|
||||||
|
|
||||||
h2. Team
|
h2. Team
|
||||||
|
|
||||||
* Developers: "Didier Lafforgue":http://www.nocoffee.fr, "Mario Visic":http://www.mariovisic.com, "Jacques Crocker":http://www.railsjedi.com
|
* Developers: "Didier Lafforgue":http://www.nocoffee.fr, "Jacques Crocker":http://www.railsjedi.com, "Mario Visic":http://www.mariovisic.com
|
||||||
* Contributors: "Dirk Kelly":http://www.dirkkelly.com, "Raphael Costa":http://raphaelcosta.net (Brazilian Portuguese translation), "Bernd Hauser":http://www.designhunger.de (German translation), "Andrea Frigido":http://www.frisoft.it (Italian translation), "Enrique García":https://github.com/kikito (Spanish translation), "Lars Smit":https://github.com/larssmit (Dutch translation), "PitOn":https://github.com/GarPit (Russian translation), "paulsponagl":https://github.com/paulsponagl
|
* Contributors: "Dirk Kelly":http://www.dirkkelly.com, "Raphael Costa":http://raphaelcosta.net (Brazilian Portuguese translation), "Bernd Hauser":http://www.designhunger.de (German translation), "Andrea Frigido":http://www.frisoft.it (Italian translation), "Enrique García":https://github.com/kikito (Spanish translation), "Lars Smit":https://github.com/larssmit (Dutch translation), "PitOn":https://github.com/GarPit (Russian translation)
|
||||||
* UI Designer: "Sacha Greif":http://www.sachagreif.com
|
* UI Designer: "Sacha Greif":http://www.sachagreif.com
|
||||||
* IE maintainer: "Alex Sanford":https://github.com/alexsanford
|
* IE maintainer: "Alex Sanford":https://github.com/alexsanford
|
||||||
|
|
||||||
@ -84,5 +80,5 @@ h2. Contact
|
|||||||
|
|
||||||
Feel free to contact me at didier at nocoffee dot fr.
|
Feel free to contact me at didier at nocoffee dot fr.
|
||||||
|
|
||||||
Copyright (c) 2012 NoCoffee, released under the MIT license
|
Copyright (c) 2011 NoCoffee, released under the MIT license
|
||||||
...
|
...
|
||||||
|
88
Rakefile
@ -1,19 +1,75 @@
|
|||||||
#!/usr/bin/env rake
|
require File.expand_path('../config/application', __FILE__)
|
||||||
begin
|
|
||||||
require 'bundler/setup'
|
require 'rubygems'
|
||||||
rescue LoadError
|
|
||||||
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
require 'rake/dsl_definition'
|
||||||
|
require 'rake'
|
||||||
|
require 'rdoc/task'
|
||||||
|
require 'rubygems/package_task'
|
||||||
|
|
||||||
|
Locomotive::Application.load_tasks
|
||||||
|
|
||||||
|
gemspec = eval(File.read('locomotive_cms.gemspec'))
|
||||||
|
Gem::PackageTask.new(gemspec) do |pkg|
|
||||||
|
pkg.gem_spec = gemspec
|
||||||
end
|
end
|
||||||
|
|
||||||
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
desc 'build the gem and release it to rubygems.org'
|
||||||
|
task :release => :gem do
|
||||||
|
sh "gem push pkg/custom_fields-#{gemspec.version}.gem"
|
||||||
|
end
|
||||||
|
|
||||||
# === Locomotive tasks ===
|
task :default => [:spec, :cucumber]
|
||||||
load 'lib/tasks/locomotive.rake'
|
|
||||||
|
|
||||||
# === Gems install tasks ===
|
# only for running the tests suite in the order observed in *nix systems
|
||||||
Bundler::GemHelper.install_tasks
|
task :spec_nix do
|
||||||
|
files = %w(
|
||||||
|
lib/core_ext_spec.rb
|
||||||
|
lib/locomotive/routing/site_dispatcher_spec.rb
|
||||||
|
lib/locomotive/bushido_spec.rb
|
||||||
|
lib/locomotive/render_spec.rb
|
||||||
|
lib/locomotive/httparty/patches_spec.rb
|
||||||
|
lib/locomotive/httparty/webservice_spec.rb
|
||||||
|
lib/locomotive/configuration_spec.rb
|
||||||
|
lib/locomotive/liquid/tags/consume_spec.rb
|
||||||
|
lib/locomotive/liquid/tags/with_scope_spec.rb
|
||||||
|
lib/locomotive/liquid/tags/nav_spec.rb
|
||||||
|
lib/locomotive/liquid/tags/editable/content_spec.rb
|
||||||
|
lib/locomotive/liquid/tags/editable/short_text_spec.rb
|
||||||
|
lib/locomotive/liquid/tags/seo_spec.rb
|
||||||
|
lib/locomotive/liquid/tags/paginate_spec.rb
|
||||||
|
lib/locomotive/liquid/drops/content_spec.rb
|
||||||
|
lib/locomotive/liquid/drops/contents_spec.rb
|
||||||
|
lib/locomotive/liquid/drops/page_spec.rb
|
||||||
|
lib/locomotive/liquid/drops/site_spec.rb
|
||||||
|
lib/locomotive/liquid/filters/resize_spec.rb
|
||||||
|
lib/locomotive/liquid/filters/html_spec.rb
|
||||||
|
lib/locomotive/liquid/filters/date_spec.rb
|
||||||
|
lib/locomotive/liquid/filters/text_spec.rb
|
||||||
|
lib/locomotive/liquid/filters/misc_spec.rb
|
||||||
|
lib/locomotive/heroku_spec.rb
|
||||||
|
lib/locomotive/import_spec.rb
|
||||||
|
lib/locomotive/export_spec.rb
|
||||||
|
models/content_instance_spec.rb
|
||||||
|
models/editable_element_spec.rb
|
||||||
|
models/account_spec.rb
|
||||||
|
models/content_type_spec.rb
|
||||||
|
models/snippet_spec.rb
|
||||||
|
models/ability_spec.rb
|
||||||
|
models/membership_spec.rb
|
||||||
|
models/page_spec.rb
|
||||||
|
models/asset_spec.rb
|
||||||
|
models/theme_asset_spec.rb
|
||||||
|
models/site_spec.rb
|
||||||
|
cells/admin/main_menu_cell_spec.rb
|
||||||
|
cells/admin/global_actions_spec.rb
|
||||||
|
cells/admin/settings_menu_cell_spec.rb
|
||||||
|
requests/seo_trailing_slash_spec.rb
|
||||||
|
).collect { |f| File.join('spec', f) }.join(' ')
|
||||||
|
|
||||||
|
sh "bundle exec rspec #{files}"
|
||||||
|
end
|
||||||
|
|
||||||
# === Travis
|
|
||||||
task :travis do
|
task :travis do
|
||||||
["rspec spec", "cucumber -b"].each do |cmd|
|
["rspec spec", "cucumber -b"].each do |cmd|
|
||||||
puts "Starting to run #{cmd}..."
|
puts "Starting to run #{cmd}..."
|
||||||
@ -21,13 +77,3 @@ task :travis do
|
|||||||
raise "#{cmd} failed!" unless $?.exitstatus == 0
|
raise "#{cmd} failed!" unless $?.exitstatus == 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# === RSpec ===
|
|
||||||
require 'rspec/core/rake_task'
|
|
||||||
RSpec::Core::RakeTask.new(:spec)
|
|
||||||
|
|
||||||
# === Cucumber ===
|
|
||||||
load 'lib/tasks/cucumber.rake'
|
|
||||||
|
|
||||||
# === Default task ===
|
|
||||||
task :default => [:spec, :cucumber]
|
|
||||||
|
Before Width: | Height: | Size: 314 B |
Before Width: | Height: | Size: 248 B |
Before Width: | Height: | Size: 247 B |
Before Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 780 B |
Before Width: | Height: | Size: 356 B |
Before Width: | Height: | Size: 359 B |
Before Width: | Height: | Size: 352 B |
Before Width: | Height: | Size: 350 B |
Before Width: | Height: | Size: 347 B |
Before Width: | Height: | Size: 351 B |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 437 B |
Before Width: | Height: | Size: 1.1 KiB |
@ -1,3 +0,0 @@
|
|||||||
button.aloha-locomotive-media-insert {
|
|
||||||
background: url(../img/image.gif) !important;
|
|
||||||
}
|
|
Before Width: | Height: | Size: 621 B |
@ -1,96 +0,0 @@
|
|||||||
define(
|
|
||||||
['aloha/jquery', 'aloha/plugin', 'aloha/floatingmenu', 'i18n!aloha/nls/i18n', 'i18n!locomotive_media/nls/i18n', 'css!locomotive_media/css/image.css'],
|
|
||||||
function(aQuery, Plugin, FloatingMenu, i18nCore, i18n) {
|
|
||||||
var jQuery = aQuery;
|
|
||||||
var $ = aQuery;
|
|
||||||
var GENTICS = window.GENTICS, Aloha = window.Aloha;
|
|
||||||
|
|
||||||
return Plugin.create('locomotive_media', {
|
|
||||||
init: function() {
|
|
||||||
FloatingMenu.createScope(this.name, 'Aloha.continuoustext');
|
|
||||||
|
|
||||||
this._addUIInsertButton(i18nCore.t('floatingmenu.tab.insert'));
|
|
||||||
},
|
|
||||||
|
|
||||||
openDialog: function() {
|
|
||||||
var that = this;
|
|
||||||
var picker = window.parent.application_view.content_assets_picker_view;
|
|
||||||
|
|
||||||
picker.options.on_select = function(asset) {
|
|
||||||
if (asset.get('image') == true)
|
|
||||||
that.insertImg(asset);
|
|
||||||
else
|
|
||||||
that.insertLink(asset);
|
|
||||||
|
|
||||||
picker.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
picker.fetch_assets();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method will insert a new image dom element into the dom tree
|
|
||||||
*/
|
|
||||||
insertImg: function(asset) {
|
|
||||||
var range = Aloha.Selection.getRangeObject(),
|
|
||||||
imageUrl = asset.get('url'),
|
|
||||||
imagestyle, imagetag, newImg;
|
|
||||||
|
|
||||||
if (range.isCollapsed()) {
|
|
||||||
imagestyle = "max-width: " + asset.get('width') + "; max-height: " + asset.get('height');
|
|
||||||
imagetag = '<img style="'+ imagestyle + '" src="' + imageUrl + '" title="" />';
|
|
||||||
newImg = jQuery(imagetag);
|
|
||||||
GENTICS.Utils.Dom.insertIntoDOM(newImg, range, jQuery(Aloha.activeEditable.obj));
|
|
||||||
} else {
|
|
||||||
Aloha.Log.error('media cannot markup a selection');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method will insert a new link dom element into the dom tree
|
|
||||||
*/
|
|
||||||
insertLink: function(asset) {
|
|
||||||
var range = Aloha.Selection.getRangeObject(),
|
|
||||||
linkText = asset.get('filename'),
|
|
||||||
linkUrl = asset.get('url'),
|
|
||||||
linktag, newLink;
|
|
||||||
|
|
||||||
if (range.isCollapsed()) {
|
|
||||||
linktag = '<a href="' + linkUrl + '">' + linkText + '</a>';
|
|
||||||
newLink = jQuery(linktag);
|
|
||||||
GENTICS.Utils.Dom.insertIntoDOM(newLink, range, jQuery(Aloha.activeEditable.obj));
|
|
||||||
range.startContainer = range.endContainer = newLink.contents().get(0);
|
|
||||||
range.startOffset = 0;
|
|
||||||
range.endOffset = linkText.length;
|
|
||||||
} else {
|
|
||||||
linktag = '<a href="' + linkUrl + '"></a>';
|
|
||||||
newLink = jQuery(linktag);
|
|
||||||
GENTICS.Utils.Dom.addMarkup(range, newLink, false);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the insert button to the floating menu
|
|
||||||
*/
|
|
||||||
_addUIInsertButton: function(tabId) {
|
|
||||||
var that = this;
|
|
||||||
this.insertMediaButton = new Aloha.ui.Button({
|
|
||||||
'name' : 'insertlocomotivemedia',
|
|
||||||
'iconClass': 'aloha-button aloha-locomotive-media-insert',
|
|
||||||
'size' : 'small',
|
|
||||||
'onclick' : function () { that.openDialog(); },
|
|
||||||
'tooltip' : i18n.t('button.addimg.tooltip'),
|
|
||||||
'toggle' : false
|
|
||||||
});
|
|
||||||
|
|
||||||
FloatingMenu.addButton(
|
|
||||||
'Aloha.continuoustext',
|
|
||||||
this.insertMediaButton,
|
|
||||||
tabId,
|
|
||||||
1
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
@ -1 +0,0 @@
|
|||||||
define({ 'button.addimg.tooltip': 'insérer média' });
|
|
@ -1,4 +0,0 @@
|
|||||||
define({
|
|
||||||
root: { "button.addimg.tooltip": "insert media" },
|
|
||||||
fr: true
|
|
||||||
});
|
|
@ -1 +0,0 @@
|
|||||||
{}
|
|
@ -1,25 +0,0 @@
|
|||||||
// This is a manifest file that'll be compiled into including all the files listed below.
|
|
||||||
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
|
||||||
// be included in the compiled file accessible from http://example.com/assets/application.js
|
|
||||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
||||||
// the compiled file.
|
|
||||||
//
|
|
||||||
//= require jquery
|
|
||||||
//= require jquery-ui
|
|
||||||
//= require jquery_ujs
|
|
||||||
//= require underscore
|
|
||||||
//= require backbone
|
|
||||||
//= require codemirror
|
|
||||||
//= require tinymce-jquery
|
|
||||||
//= require codemirror/utils/overlay
|
|
||||||
//= require codemirror/modes/css
|
|
||||||
//= require codemirror/modes/javascript
|
|
||||||
//= require codemirror/modes/xml
|
|
||||||
//= require codemirror/modes/htmlmixed
|
|
||||||
//= require locomotive/vendor
|
|
||||||
//= require ./locomotive/application
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
$.datepicker.setDefaults($.datepicker.regional[window.locale]);
|
|
||||||
});
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
|||||||
#= require ./utils/aloha_settings
|
|
||||||
#= require aloha
|
|
@ -1,12 +0,0 @@
|
|||||||
#= require_self
|
|
||||||
#= require_tree ./utils
|
|
||||||
#= require_tree ./models
|
|
||||||
#= require_tree ./views
|
|
||||||
|
|
||||||
window.Locomotive =
|
|
||||||
mounted_on: window.Locomotive.mounted_on
|
|
||||||
Models: {}
|
|
||||||
Collections: {}
|
|
||||||
Views: {}
|
|
||||||
|
|
||||||
window.Locomotive.Views.Memberships = {}
|
|
@ -1,22 +0,0 @@
|
|||||||
#= require jquery
|
|
||||||
#= require jquery-ui
|
|
||||||
#= require jquery_ujs
|
|
||||||
#= require underscore
|
|
||||||
#= require backbone
|
|
||||||
#= require locomotive/backbone.sync
|
|
||||||
#= require locomotive/growl
|
|
||||||
#= require locomotive/handlebars
|
|
||||||
#= require locomotive/ICanHandlebarz
|
|
||||||
#= require locomotive/resize
|
|
||||||
#= require locomotive/toggle
|
|
||||||
#= require_self
|
|
||||||
#= require_tree ./utils
|
|
||||||
#= require_tree ./models
|
|
||||||
#= require_tree ./views/content_assets
|
|
||||||
#= require_tree ./views/inline_editor
|
|
||||||
|
|
||||||
window.Locomotive =
|
|
||||||
mounted_on: '/locomotive' # default path
|
|
||||||
Models: {}
|
|
||||||
Collections: {}
|
|
||||||
Views: {}
|
|
@ -1,11 +0,0 @@
|
|||||||
class Locomotive.Models.Account extends Backbone.Model
|
|
||||||
|
|
||||||
paramRoot: 'account'
|
|
||||||
|
|
||||||
urlRoot: "#{Locomotive.mounted_on}/accounts"
|
|
||||||
|
|
||||||
class Locomotive.Models.CurrentAccount extends Locomotive.Models.Account
|
|
||||||
|
|
||||||
url: "#{Locomotive.mounted_on}/my_account"
|
|
||||||
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
|||||||
class Locomotive.Models.ContentAsset extends Backbone.Model
|
|
||||||
|
|
||||||
paramRoot: 'content_asset'
|
|
||||||
|
|
||||||
urlRoot: "#{Locomotive.mounted_on}/content_assets"
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
@prepare()
|
|
||||||
|
|
||||||
prepare: ->
|
|
||||||
@set
|
|
||||||
image: @get('content_type') == 'image'
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
class Locomotive.Models.ContentAssetsCollection extends Backbone.Collection
|
|
||||||
|
|
||||||
model: Locomotive.Models.ContentAsset
|
|
||||||
|
|
||||||
url: "#{Locomotive.mounted_on}/content_assets"
|
|
@ -1,61 +0,0 @@
|
|||||||
class Locomotive.Models.ContentEntry extends Backbone.Model
|
|
||||||
|
|
||||||
paramRoot: 'content_entry'
|
|
||||||
|
|
||||||
urlRoot: "#{Locomotive.mounted_on}/content_types/:slug/entries"
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
@urlRoot = @urlRoot.replace(':slug', @get('content_type_slug'))
|
|
||||||
|
|
||||||
_.each @get('has_many_custom_fields'), (field) =>
|
|
||||||
name = field[0]
|
|
||||||
collection = new Locomotive.Models.ContentEntriesCollection(@get(name))
|
|
||||||
@set_attribute name, collection
|
|
||||||
|
|
||||||
_.each @get('many_to_many_custom_fields'), (field) =>
|
|
||||||
name = field[0]
|
|
||||||
collection = new Locomotive.Models.ContentEntriesCollection(@get(name))
|
|
||||||
collection.comparator = (entry) -> entry.get('__position') || 0
|
|
||||||
@set_attribute name, collection
|
|
||||||
|
|
||||||
set_attribute: (attribute, value) ->
|
|
||||||
data = {}
|
|
||||||
data[attribute] = value
|
|
||||||
@set data
|
|
||||||
|
|
||||||
update_attributes: (attributes) ->
|
|
||||||
_.each attributes.file_custom_fields, (field) => # special treatment for files
|
|
||||||
attribute = "#{field}_url"
|
|
||||||
@set_attribute attribute, attributes[attribute]
|
|
||||||
@set_attribute "remove_#{field}", false
|
|
||||||
|
|
||||||
toMinJSON: ->
|
|
||||||
_.tap {}, (hash) =>
|
|
||||||
_.each @attributes, (val, key) =>
|
|
||||||
if key == 'id' || key == '_destroy' || key.indexOf('position_in_') == 0
|
|
||||||
hash[key] = val
|
|
||||||
|
|
||||||
toJSON: ->
|
|
||||||
_.tap super, (hash) =>
|
|
||||||
hash['_slug'] = '' if hash['_slug'] == null # avoid empty hash
|
|
||||||
_.each _.keys(hash), (key) =>
|
|
||||||
unless _.include(@get('safe_attributes'), key)
|
|
||||||
delete hash[key]
|
|
||||||
|
|
||||||
_.each @get('has_many_custom_fields'), (field) => # include the has_many relationships
|
|
||||||
name = field[0]
|
|
||||||
if @get(name).length > 0
|
|
||||||
hash["#{name}_attributes"] = @get(name).toMinJSON()
|
|
||||||
|
|
||||||
_.each @get('many_to_many_custom_fields'), (field) => # include the many_to_many relationships
|
|
||||||
name = field[0]; setter_name = field[1]
|
|
||||||
hash[setter_name] = @get(name).sort().map (entry) => entry.id
|
|
||||||
|
|
||||||
class Locomotive.Models.ContentEntriesCollection extends Backbone.Collection
|
|
||||||
|
|
||||||
model: Locomotive.Models.ContentEntry
|
|
||||||
|
|
||||||
url: "#{Locomotive.mounted_on}/content_types/:slug/entries"
|
|
||||||
|
|
||||||
toMinJSON: ->
|
|
||||||
@map (entry) => entry.toMinJSON()
|
|
@ -1,23 +0,0 @@
|
|||||||
class Locomotive.Models.ContentType extends Backbone.Model
|
|
||||||
|
|
||||||
paramRoot: 'content_type'
|
|
||||||
|
|
||||||
urlRoot: "#{Locomotive.mounted_on}/content_types"
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
@_normalize()
|
|
||||||
|
|
||||||
_normalize: ->
|
|
||||||
@set
|
|
||||||
entries_custom_fields: new Locomotive.Models.CustomFieldsCollection(@get('entries_custom_fields'))
|
|
||||||
|
|
||||||
toJSON: ->
|
|
||||||
_.tap super, (hash) =>
|
|
||||||
delete hash.entries_custom_fields
|
|
||||||
hash.entries_custom_fields_attributes = @get('entries_custom_fields').toJSONForSave() if @get('entries_custom_fields')? && @get('entries_custom_fields').length > 0
|
|
||||||
|
|
||||||
class Locomotive.Models.ContentTypesCollection extends Backbone.Collection
|
|
||||||
|
|
||||||
model: Locomotive.Models.ContentType
|
|
||||||
|
|
||||||
url: "#{Locomotive.mounted_on}/content_types"
|
|
@ -1,38 +0,0 @@
|
|||||||
class Locomotive.Models.CustomField extends Backbone.Model
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
@_normalize()
|
|
||||||
|
|
||||||
unless @get('name')?
|
|
||||||
@set name: @get('label').slugify()
|
|
||||||
|
|
||||||
_normalize: ->
|
|
||||||
@set
|
|
||||||
select_options: new Locomotive.Models.CustomFieldSelectOptionsCollection(@get('select_options'))
|
|
||||||
|
|
||||||
_undesired_fields:
|
|
||||||
['select_options', 'type_text', 'text_formatting_text', 'inverse_of_text', 'class_name_text', 'undefined_text', 'undefined', 'created_at', 'updated_at']
|
|
||||||
|
|
||||||
_relationship_fields:
|
|
||||||
['class_name', 'inverse_of', 'ui_enabled']
|
|
||||||
|
|
||||||
is_relationship_type: ->
|
|
||||||
_.include(['belongs_to', 'has_many', 'many_to_many'], @get('type'))
|
|
||||||
|
|
||||||
toJSONForSave: ->
|
|
||||||
_.tap {}, (hash) =>
|
|
||||||
for key, value of @.toJSON()
|
|
||||||
unless _.include(@_undesired_fields, key)
|
|
||||||
if _.include(@_relationship_fields, key)
|
|
||||||
hash[key] = value if @is_relationship_type()
|
|
||||||
else
|
|
||||||
hash[key] = value
|
|
||||||
|
|
||||||
hash.select_options_attributes = @get('select_options').toJSONForSave() if @get('select_options')? && @get('select_options').length > 0
|
|
||||||
|
|
||||||
class Locomotive.Models.CustomFieldsCollection extends Backbone.Collection
|
|
||||||
|
|
||||||
model: Locomotive.Models.CustomField
|
|
||||||
|
|
||||||
toJSONForSave: ->
|
|
||||||
@map (model) => model.toJSONForSave()
|
|
@ -1,13 +0,0 @@
|
|||||||
class Locomotive.Models.CustomFieldSelectOption extends Backbone.Model
|
|
||||||
|
|
||||||
toJSONForSave: ->
|
|
||||||
_.tap {}, (hash) =>
|
|
||||||
for key, value of @.toJSON()
|
|
||||||
hash[key] = value unless _.include(['created_at', 'updated_at'], key)
|
|
||||||
|
|
||||||
class Locomotive.Models.CustomFieldSelectOptionsCollection extends Backbone.Collection
|
|
||||||
|
|
||||||
model: Locomotive.Models.CustomFieldSelectOption
|
|
||||||
|
|
||||||
toJSONForSave: ->
|
|
||||||
@map (model) => model.toJSONForSave()
|
|
@ -1,3 +0,0 @@
|
|||||||
class Locomotive.Models.Domain extends Backbone.Model
|
|
||||||
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
|||||||
class Locomotive.Models.EditableElement extends Backbone.Model
|
|
||||||
|
|
||||||
toJSONForSave: ->
|
|
||||||
_.tap {}, (hash) =>
|
|
||||||
for key, value of @.toJSON()
|
|
||||||
hash[key] = value if _.include(['id', 'source', 'content', 'remove_source'], key)
|
|
||||||
|
|
||||||
if @get('type') == 'EditableFile'
|
|
||||||
delete hash['content']
|
|
||||||
else
|
|
||||||
delete hash['source']
|
|
||||||
|
|
||||||
class Locomotive.Models.EditableElementsCollection extends Backbone.Collection
|
|
||||||
|
|
||||||
model: Locomotive.Models.EditableElement
|
|
||||||
|
|
||||||
blocks: ->
|
|
||||||
names = _.uniq(@map (editable, index) -> editable.get('block_name'))
|
|
||||||
_.tap [], (list) =>
|
|
||||||
_.each names, (name, index) ->
|
|
||||||
list.push name: name, index: index
|
|
||||||
|
|
||||||
by_block: (name) ->
|
|
||||||
@filter (editable) -> editable.get('block_name') == name
|
|
||||||
|
|
||||||
toJSONForSave: ->
|
|
||||||
@map (model) => model.toJSONForSave()
|
|
@ -1,13 +0,0 @@
|
|||||||
class Locomotive.Models.Membership extends Backbone.Model
|
|
||||||
|
|
||||||
toJSONForSave: ->
|
|
||||||
_.tap {}, (hash) =>
|
|
||||||
for key, value of @.toJSON()
|
|
||||||
hash[key] = value if _.include(['id', '_id', 'role', '_destroy'], key)
|
|
||||||
|
|
||||||
class Locomotive.Models.MembershipsCollection extends Backbone.Collection
|
|
||||||
|
|
||||||
model: Locomotive.Models.Membership
|
|
||||||
|
|
||||||
toJSONForSave: ->
|
|
||||||
@map (model) => model.toJSONForSave()
|
|
@ -1,27 +0,0 @@
|
|||||||
class Locomotive.Models.Page extends Backbone.Model
|
|
||||||
|
|
||||||
paramRoot: 'page'
|
|
||||||
|
|
||||||
urlRoot: "#{Locomotive.mounted_on}/pages"
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
@_normalize()
|
|
||||||
|
|
||||||
@set
|
|
||||||
edit_url: "#{Locomotive.mounted_on}/pages/#{@id}/edit"
|
|
||||||
|
|
||||||
_normalize: ->
|
|
||||||
@set
|
|
||||||
editable_elements: new Locomotive.Models.EditableElementsCollection(@get('editable_elements') || [])
|
|
||||||
|
|
||||||
toJSON: ->
|
|
||||||
_.tap super, (hash) =>
|
|
||||||
_.each ['fullpath', 'localized_fullpaths', 'templatized_from_parent', 'target_klass_name_text', 'content_type_id_text', 'edit_url', 'parent_id_text', 'response_type_text'], (key) => delete hash[key]
|
|
||||||
|
|
||||||
delete hash['editable_elements']
|
|
||||||
hash.editable_elements = @get('editable_elements').toJSONForSave() if @get('editable_elements')? && @get('editable_elements').length > 0
|
|
||||||
|
|
||||||
delete hash['target_klass_name']
|
|
||||||
hash.target_klass_name = @get('target_klass_name') if @get('templatized') == true
|
|
||||||
|
|
||||||
class Locomotive.Models.PagesCollection extends Backbone.Collection
|
|
@ -1,33 +0,0 @@
|
|||||||
class Locomotive.Models.Site extends Backbone.Model
|
|
||||||
|
|
||||||
paramRoot: 'site'
|
|
||||||
|
|
||||||
urlRoot: "#{Locomotive.mounted_on}/sites"
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
# Be careful, domains_without_subdomain becomes domains
|
|
||||||
domains = _.map @get('domains_without_subdomain'), (name) =>
|
|
||||||
new Locomotive.Models.Domain(name: name)
|
|
||||||
|
|
||||||
memberships = new Locomotive.Models.MembershipsCollection(@get('memberships'))
|
|
||||||
|
|
||||||
@set domains: domains, memberships: memberships
|
|
||||||
|
|
||||||
includes_domain: (name) ->
|
|
||||||
name == @domain_with_domain() || _.any(@get('domains'), (domain) -> domain.get('name') == name)
|
|
||||||
|
|
||||||
domain_with_domain: ->
|
|
||||||
"#{@get('subdomain')}.#{@get('domain_name')}"
|
|
||||||
|
|
||||||
toJSON: ->
|
|
||||||
_.tap super, (hash) =>
|
|
||||||
delete hash.memberships
|
|
||||||
hash.memberships_attributes = @get('memberships').toJSONForSave() if @get('memberships')? && @get('memberships').length > 0
|
|
||||||
delete hash.domains
|
|
||||||
hash.domains = _.map(@get('domains'), (domain) -> domain.get('name'))
|
|
||||||
|
|
||||||
class Locomotive.Models.CurrentSite extends Locomotive.Models.Site
|
|
||||||
|
|
||||||
url: "#{Locomotive.mounted_on}/current_site"
|
|
||||||
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
|||||||
class Locomotive.Models.Snippet extends Backbone.Model
|
|
||||||
|
|
||||||
paramRoot: 'snippet'
|
|
||||||
|
|
||||||
urlRoot: "#{Locomotive.mounted_on}/snippets"
|
|
||||||
|
|
||||||
class Locomotive.Models.SnippetsCollection extends Backbone.Collection
|
|
||||||
|
|
||||||
model: Locomotive.Models.Snippet
|
|
||||||
|
|
||||||
url: "#{Locomotive.mounted_on}/snippets"
|
|
@ -1,11 +0,0 @@
|
|||||||
class Locomotive.Models.ThemeAsset extends Backbone.Model
|
|
||||||
|
|
||||||
paramRoot: 'theme_asset'
|
|
||||||
|
|
||||||
urlRoot: "#{Locomotive.mounted_on}/theme_assets"
|
|
||||||
|
|
||||||
class Locomotive.Models.ThemeAssetsCollection extends Backbone.Collection
|
|
||||||
|
|
||||||
model: Locomotive.Models.ThemeAsset
|
|
||||||
|
|
||||||
url: "#{Locomotive.mounted_on}/theme_assets"
|
|
@ -1 +0,0 @@
|
|||||||
#= require jquery
|
|
@ -1,37 +0,0 @@
|
|||||||
window.Aloha = window.Aloha ?= {}
|
|
||||||
|
|
||||||
window.Aloha.settings =
|
|
||||||
|
|
||||||
logLevels: { 'error': true, 'warn': true, 'info': false, 'debug': false }
|
|
||||||
|
|
||||||
errorhandling: true
|
|
||||||
|
|
||||||
plugins:
|
|
||||||
|
|
||||||
format:
|
|
||||||
config: [ 'b', 'i', 'u','del','sub','sup', 'p', 'title', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'removeFormat']
|
|
||||||
editables:
|
|
||||||
'.editable-short-text' : [ 'b', 'i', 'u' ]
|
|
||||||
|
|
||||||
link:
|
|
||||||
config: [ 'a' ]
|
|
||||||
editables:
|
|
||||||
'.editable-short-text': [ ]
|
|
||||||
|
|
||||||
list:
|
|
||||||
config: [ 'ul' ]
|
|
||||||
editables:
|
|
||||||
'.editable-short-text': [ ]
|
|
||||||
|
|
||||||
image:
|
|
||||||
ui:
|
|
||||||
insert: false
|
|
||||||
crop: false
|
|
||||||
|
|
||||||
i18n:
|
|
||||||
available: ['en', 'fr', 'pt-BR', 'es', 'de', 'no', 'ru', 'nl']
|
|
||||||
|
|
||||||
sidebar:
|
|
||||||
disabled: true
|
|
||||||
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
|||||||
(function() {
|
|
||||||
String.prototype.trim = function() {
|
|
||||||
return this.replace(/^\s+/g, '').replace(/\s+$/g, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
String.prototype.repeat = function(num) {
|
|
||||||
for (var i = 0, buf = ""; i < num; i++) buf += this;
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
String.prototype.truncate = function(length) {
|
|
||||||
if (this.length > length) {
|
|
||||||
return this.slice(0, length - 3) + "...";
|
|
||||||
} else {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String.prototype.slugify = function(sep) {
|
|
||||||
if (typeof sep == 'undefined') sep = '_';
|
|
||||||
var alphaNumRegexp = new RegExp('[^\\w\\' + sep + ']', 'g');
|
|
||||||
var avoidDuplicateRegexp = new RegExp('[\\' + sep + ']{2,}', 'g');
|
|
||||||
return this.replace(/\s/g, sep).replace(alphaNumRegexp, '').replace(avoidDuplicateRegexp, sep).toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addParameterToURL = function(key, value, context) { // code from http://stackoverflow.com/questions/486896/adding-a-parameter-to-the-url-with-javascript
|
|
||||||
if (typeof context == 'undefined') context = document;
|
|
||||||
|
|
||||||
key = encodeURIComponent(key); value = encodeURIComponent(value);
|
|
||||||
|
|
||||||
var kvp = context.location.search.substr(1).split('&');
|
|
||||||
|
|
||||||
var i = kvp.length; var x; while(i--) {
|
|
||||||
x = kvp[i].split('=');
|
|
||||||
|
|
||||||
if (x[0] == key) {
|
|
||||||
x[1] = value;
|
|
||||||
kvp[i] = x.join('=');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i < 0) { kvp[kvp.length] = [key,value].join('='); }
|
|
||||||
|
|
||||||
//this will reload the page, it's likely better to store this until finished
|
|
||||||
context.location.search = kvp.join('&');
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addJavascript = function(doc, src, options) {
|
|
||||||
var script = doc.createElement('script');
|
|
||||||
script.type = 'text/javascript';
|
|
||||||
script.src = src;
|
|
||||||
if (options && options.onload) {
|
|
||||||
script.onload = options.onload;
|
|
||||||
delete(options.onload);
|
|
||||||
}
|
|
||||||
for (var key in options) {
|
|
||||||
script.setAttribute(key, options[key]);
|
|
||||||
}
|
|
||||||
doc.body.appendChild(script);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addStylesheet = function(doc, src, options) {
|
|
||||||
var stylesheet = doc.createElement('link');
|
|
||||||
stylesheet.style = 'text/css';
|
|
||||||
stylesheet.href = src;
|
|
||||||
stylesheet.media = 'screen';
|
|
||||||
stylesheet.rel = 'stylesheet';
|
|
||||||
doc.head.appendChild(stylesheet);
|
|
||||||
}
|
|
||||||
|
|
||||||
$.ui.dialog.prototype.overlayEl = function() { return this.overlay.$el; }
|
|
||||||
|
|
||||||
})();
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
$.growl.settings.noticeTemplate = '' +
|
|
||||||
'<div class="notice %title%">' +
|
|
||||||
' <p>%message%</p>' +
|
|
||||||
'</div>';
|
|
||||||
|
|
||||||
$.growl.settings.dockCss = {
|
|
||||||
position: 'fixed',
|
|
||||||
bottom: '20px',
|
|
||||||
left: '0px',
|
|
||||||
width: '100%',
|
|
||||||
zIndex: 50000
|
|
||||||
};
|
|
||||||
|
|
||||||
// $.growl.settings.displayTimeout = 500;
|
|
@ -1,9 +0,0 @@
|
|||||||
Handlebars.registerHelper 'each_with_index', (context, block) ->
|
|
||||||
ret = ""
|
|
||||||
|
|
||||||
for num in context
|
|
||||||
data = context[num]
|
|
||||||
data._index = num
|
|
||||||
ret = ret + block(data)
|
|
||||||
|
|
||||||
ret
|
|
@ -1,48 +0,0 @@
|
|||||||
window.Locomotive.tinyMCE =
|
|
||||||
|
|
||||||
defaultSettings:
|
|
||||||
theme: 'advanced'
|
|
||||||
skin: 'locomotive'
|
|
||||||
plugins: 'safari,jqueryinlinepopups,locomotive_media,fullscreen'
|
|
||||||
extended_valid_elements: 'iframe[width|height|frameborder|allowfullscreen|src|title]'
|
|
||||||
theme_advanced_buttons1: 'fullscreen,code,|,bold,italic,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,outdent,indent,blockquote,|,link,unlink,|,locomotive_media'
|
|
||||||
theme_advanced_buttons2: 'formatselect,fontselect,fontsizeselect'
|
|
||||||
theme_advanced_buttons3: ''
|
|
||||||
theme_advanced_toolbar_location: 'top'
|
|
||||||
theme_advanced_toolbar_align: 'left'
|
|
||||||
height: '300'
|
|
||||||
width: '709'
|
|
||||||
convert_urls: false
|
|
||||||
fullscreen_new_window: false
|
|
||||||
fullscreen_settings:
|
|
||||||
theme_advanced_path_location: 'top'
|
|
||||||
|
|
||||||
minimalSettings:
|
|
||||||
theme: 'advanced'
|
|
||||||
skin: 'locomotive'
|
|
||||||
plugins: 'safari,jqueryinlinepopups,locomotive_media'
|
|
||||||
theme_advanced_buttons1: 'code,|,bold,italic,strikethrough,|,fontselect,fontsizeselect,|,link,unlink,|,locomotive_media'
|
|
||||||
theme_advanced_buttons2: ''
|
|
||||||
theme_advanced_buttons3: ''
|
|
||||||
theme_advanced_toolbar_location: 'top'
|
|
||||||
theme_advanced_toolbar_align: 'left'
|
|
||||||
height: '20'
|
|
||||||
width: '709'
|
|
||||||
convert_urls: false
|
|
||||||
|
|
||||||
popupSettings:
|
|
||||||
theme: 'advanced'
|
|
||||||
skin: 'locomotive'
|
|
||||||
plugins: 'safari,jqueryinlinepopups,locomotive_media,fullscreen'
|
|
||||||
extended_valid_elements: 'iframe[width|height|frameborder|allowfullscreen|src|title]'
|
|
||||||
theme_advanced_buttons1: 'fullscreen,code,|,bold,italic,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,outdent,indent,blockquote,|,link,unlink,|,locomotive_media'
|
|
||||||
theme_advanced_buttons2: 'formatselect,fontselect,fontsizeselect'
|
|
||||||
theme_advanced_buttons3: ''
|
|
||||||
theme_advanced_toolbar_location: 'top'
|
|
||||||
theme_advanced_toolbar_align: 'left'
|
|
||||||
height: '300'
|
|
||||||
width: '545'
|
|
||||||
convert_urls: false
|
|
||||||
fullscreen_new_window: false
|
|
||||||
fullscreen_settings:
|
|
||||||
theme_advanced_path_location: 'top'
|
|
@ -1,92 +0,0 @@
|
|||||||
class Locomotive.Views.ApplicationView extends Backbone.View
|
|
||||||
|
|
||||||
el: 'body'
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
@render_flash_messages(@options.flash)
|
|
||||||
|
|
||||||
@add_submenu_behaviours()
|
|
||||||
|
|
||||||
@center_ui_dialog()
|
|
||||||
|
|
||||||
@enable_sites_picker()
|
|
||||||
|
|
||||||
@enable_content_locale_picker()
|
|
||||||
|
|
||||||
# render page view
|
|
||||||
if @options.view?
|
|
||||||
@view = new @options.view(@options.view_data || {})
|
|
||||||
@view.render()
|
|
||||||
|
|
||||||
window.Locomotive.tinyMCE.defaultSettings.language = window.locale # set the default tinyMCE language
|
|
||||||
window.Locomotive.tinyMCE.minimalSettings.language = window.locale
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
render_flash_messages: (messages) ->
|
|
||||||
_.each messages, (couple) ->
|
|
||||||
$.growl couple[0], couple[1]
|
|
||||||
|
|
||||||
center_ui_dialog: ->
|
|
||||||
$(window).resize ->
|
|
||||||
$('.ui-dialog-content:visible').dialog('option', 'position', 'center')
|
|
||||||
|
|
||||||
add_submenu_behaviours: ->
|
|
||||||
$('#submenu ul li.hoverable').each ->
|
|
||||||
timer = null
|
|
||||||
link = $(@)
|
|
||||||
(popup = link.find('.popup')).removeClass('popup').addClass('submenu-popup'
|
|
||||||
).bind('show', ->
|
|
||||||
link.find('a').addClass('hover') & popup.css(
|
|
||||||
top: link.offset().top + link.height() - 2
|
|
||||||
left: link.offset().left - parseInt(popup.css('padding-left'))
|
|
||||||
).show()
|
|
||||||
).bind('hide', ->
|
|
||||||
link.find('a').removeClass('hover') & $(@).hide()
|
|
||||||
).bind('mouseleave', -> popup.trigger('hide')
|
|
||||||
).bind 'mouseenter', -> clearTimeout(timer)
|
|
||||||
|
|
||||||
$(document.body).append(popup)
|
|
||||||
|
|
||||||
link.hover(
|
|
||||||
-> popup.trigger('show')
|
|
||||||
-> timer = window.setTimeout (-> popup.trigger('hide')), 30
|
|
||||||
)
|
|
||||||
|
|
||||||
css = $('#submenu > ul').attr('class')
|
|
||||||
$("#submenu > ul > li.#{css}").addClass('on') if css != ''
|
|
||||||
|
|
||||||
enable_sites_picker: ->
|
|
||||||
link = @$('#sites-picker-link')
|
|
||||||
picker = @$('#sites-picker')
|
|
||||||
|
|
||||||
return if picker.size() == 0
|
|
||||||
|
|
||||||
left = link.position().left + link.parent().position().left - (picker.width() - link.width())
|
|
||||||
picker.css('left', left)
|
|
||||||
|
|
||||||
link.bind 'click', (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
picker.toggle()
|
|
||||||
|
|
||||||
enable_content_locale_picker: ->
|
|
||||||
link = @$('#content-locale-picker-link')
|
|
||||||
picker = @$('#content-locale-picker')
|
|
||||||
|
|
||||||
return if picker.size() == 0
|
|
||||||
|
|
||||||
link.bind 'click', (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
picker.toggle()
|
|
||||||
|
|
||||||
picker.find('li').bind 'click', (event) ->
|
|
||||||
locale = $(@).attr('data-locale')
|
|
||||||
window.addParameterToURL 'content_locale', locale
|
|
||||||
|
|
||||||
unique_dialog_zindex: ->
|
|
||||||
# returns the number of jQuery UI modals created in order to set a valid zIndex for each of them.
|
|
||||||
# Each modal window should have a different zIndex, otherwise there will be conflicts between them.
|
|
||||||
window.Locomotive.jQueryModals ||= 0
|
|
||||||
|
|
||||||
998 + window.Locomotive.jQueryModals++
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
|||||||
Locomotive.Views.ContentAssets ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.ContentAssets.PickerItemView extends Backbone.View
|
|
||||||
|
|
||||||
tagName: 'li'
|
|
||||||
|
|
||||||
className: 'asset'
|
|
||||||
|
|
||||||
events:
|
|
||||||
'click h4 a, .icon, .image': 'select_asset'
|
|
||||||
'click a.remove': 'remove_asset'
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
$(@el).html(ich.content_asset(@model.toJSON()))
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
select_asset: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
@on_select(@model)
|
|
||||||
|
|
||||||
on_select: ->
|
|
||||||
@options.parent.options.on_select(@model) if @options.parent.options.on_select
|
|
||||||
|
|
||||||
remove_asset: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
message = $(event.target).attr('data-confirm') || $(event.target).parent().attr('data-confirm')
|
|
||||||
|
|
||||||
@model.destroy() if confirm(message)
|
|
@ -1,58 +0,0 @@
|
|||||||
#= require ../shared/asset_picker_view
|
|
||||||
|
|
||||||
Locomotive.Views.ContentAssets ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.ContentAssets.PickerView extends Locomotive.Views.Shared.AssetPickerView
|
|
||||||
|
|
||||||
number_items_per_row: 4
|
|
||||||
|
|
||||||
_item_views: []
|
|
||||||
|
|
||||||
template: ->
|
|
||||||
ich.content_asset_picker
|
|
||||||
|
|
||||||
fetch_assets: ->
|
|
||||||
@_reset()
|
|
||||||
@collection.fetch
|
|
||||||
success: () =>
|
|
||||||
@open()
|
|
||||||
|
|
||||||
build_uploader: (el, link) ->
|
|
||||||
link.bind 'click', (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
el.click()
|
|
||||||
|
|
||||||
el.bind 'change', (event) =>
|
|
||||||
_.each event.target.files, (file) =>
|
|
||||||
asset = new Locomotive.Models.ContentAsset(source: file)
|
|
||||||
asset.save {},
|
|
||||||
headers: { 'X-Flash': true }
|
|
||||||
success: (model, response) => @collection.add(model.prepare())
|
|
||||||
error: => @shake()
|
|
||||||
|
|
||||||
add_asset: (asset, first) ->
|
|
||||||
view = new Locomotive.Views.ContentAssets.PickerItemView model: asset, parent: @
|
|
||||||
|
|
||||||
(@_item_views ||= []).push(view)
|
|
||||||
@$('ul.list .clear').before(view.render().el)
|
|
||||||
|
|
||||||
@_refresh()
|
|
||||||
|
|
||||||
@_move_to_last_asset() unless first == true
|
|
||||||
|
|
||||||
remove_asset: (asset) ->
|
|
||||||
view = _.find @_item_views, (tmp) -> tmp.model == asset
|
|
||||||
view.remove() if view?
|
|
||||||
@_refresh()
|
|
||||||
|
|
||||||
_on_refresh: ->
|
|
||||||
self = @
|
|
||||||
@$('ul.list li.asset').each (index) ->
|
|
||||||
if (index + 1) % self.number_items_per_row == 0
|
|
||||||
$(@).addClass('last')
|
|
||||||
else
|
|
||||||
$(@).removeClass('last')
|
|
||||||
|
|
||||||
_reset: ->
|
|
||||||
_.each @_item_views || [], (view) -> view.remove()
|
|
||||||
super()
|
|
@ -1,117 +0,0 @@
|
|||||||
#= require ../shared/form_view
|
|
||||||
|
|
||||||
Locomotive.Views.ContentEntries ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.ContentEntries.FormView extends Locomotive.Views.Shared.FormView
|
|
||||||
|
|
||||||
el: '#content'
|
|
||||||
|
|
||||||
_file_field_views: []
|
|
||||||
|
|
||||||
_has_many_field_views: []
|
|
||||||
|
|
||||||
_many_to_many_field_views: []
|
|
||||||
|
|
||||||
events:
|
|
||||||
'submit': 'save'
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
@model ||= new Locomotive.Models.ContentEntry(@options.content_entry)
|
|
||||||
|
|
||||||
Backbone.ModelBinding.bind @
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
super()
|
|
||||||
|
|
||||||
@enable_checkboxes()
|
|
||||||
|
|
||||||
@enable_datepickers()
|
|
||||||
|
|
||||||
@enable_richtexteditor()
|
|
||||||
|
|
||||||
@enable_file_fields()
|
|
||||||
|
|
||||||
@enable_has_many_fields()
|
|
||||||
|
|
||||||
@enable_many_to_many_fields()
|
|
||||||
|
|
||||||
@slugify_label_field()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
enable_checkboxes: ->
|
|
||||||
@$('li.input.toggle input[type=checkbox]').checkToggle()
|
|
||||||
|
|
||||||
enable_datepickers: ->
|
|
||||||
@$('li.input.date input[type=text]').datepicker()
|
|
||||||
|
|
||||||
enable_richtexteditor: ->
|
|
||||||
_.each @$('li.input.rte textarea.html'), (textarea) =>
|
|
||||||
settings = _.extend {}, @tinyMCE_settings(),
|
|
||||||
oninit: ((editor) =>
|
|
||||||
$.cmd 'S', (() =>
|
|
||||||
editor.save()
|
|
||||||
$(textarea).trigger('changeSilently')
|
|
||||||
@$('form').trigger('submit')
|
|
||||||
), [], ignoreCase: true, document: editor.dom.doc),
|
|
||||||
onchange_callback: (editor) =>
|
|
||||||
editor.save()
|
|
||||||
$(textarea).trigger('changeSilently')
|
|
||||||
|
|
||||||
$(textarea).tinymce(settings)
|
|
||||||
|
|
||||||
enable_file_fields: ->
|
|
||||||
_.each @model.get('file_custom_fields'), (name) =>
|
|
||||||
view = new Locomotive.Views.Shared.Fields.FileView model: @model, name: name
|
|
||||||
|
|
||||||
@_file_field_views.push(view)
|
|
||||||
|
|
||||||
@$("##{@model.paramRoot}_#{name}_input label").after(view.render().el)
|
|
||||||
|
|
||||||
enable_has_many_fields: ->
|
|
||||||
unless @model.isNew()
|
|
||||||
_.each @model.get('has_many_custom_fields'), (field) =>
|
|
||||||
name = field[0]; inverse_of = field[1]
|
|
||||||
new_entry = new Locomotive.Models.ContentEntry(@options["#{name}_new_entry"])
|
|
||||||
view = new Locomotive.Views.Shared.Fields.HasManyView model: @model, name: name, new_entry: new_entry, inverse_of: inverse_of
|
|
||||||
|
|
||||||
if view.ui_enabled()
|
|
||||||
@_has_many_field_views.push(view)
|
|
||||||
|
|
||||||
@$("##{@model.paramRoot}_#{name}_input label").after(view.render().el)
|
|
||||||
|
|
||||||
enable_many_to_many_fields: ->
|
|
||||||
_.each @model.get('many_to_many_custom_fields'), (field) =>
|
|
||||||
name = field[0]
|
|
||||||
view = new Locomotive.Views.Shared.Fields.ManyToManyView model: @model, name: name, all_entries: @options["all_#{name}_entries"]
|
|
||||||
|
|
||||||
if view.ui_enabled()
|
|
||||||
@_many_to_many_field_views.push(view)
|
|
||||||
|
|
||||||
@$("##{@model.paramRoot}_#{name}_input label").after(view.render().el)
|
|
||||||
|
|
||||||
slugify_label_field: ->
|
|
||||||
@$('li.input.highlighted > input[type=text]').slugify(target: @$('#content_entry__slug'))
|
|
||||||
|
|
||||||
refresh_file_fields: ->
|
|
||||||
_.each @_file_field_views, (view) => view.refresh()
|
|
||||||
|
|
||||||
refresh: ->
|
|
||||||
@$('li.input.toggle input[type=checkbox]').checkToggle('sync')
|
|
||||||
_.each @_file_field_views, (view) => view.refresh()
|
|
||||||
|
|
||||||
reset: ->
|
|
||||||
@$('li.input.string input[type=text], li.input.text textarea, li.input.date input[type=text]').val('').trigger('change')
|
|
||||||
_.each @$('li.input.rte textarea.html'), (textarea) => $(textarea).tinymce().setContent(''); $(textarea).trigger('change')
|
|
||||||
_.each @_file_field_views, (view) => view.reset()
|
|
||||||
@$('li.input.toggle input[type=checkbox]').checkToggle('sync')
|
|
||||||
|
|
||||||
remove: ->
|
|
||||||
_.each @_file_field_views, (view) => view.remove()
|
|
||||||
_.each @_has_many_field_views, (view) => view.remove()
|
|
||||||
_.each @_many_to_many_field_views, (view) => view.remove()
|
|
||||||
super
|
|
||||||
|
|
||||||
tinyMCE_settings: ->
|
|
||||||
window.Locomotive.tinyMCE.defaultSettings
|
|
||||||
|
|
@ -1,84 +0,0 @@
|
|||||||
#= require ../shared/form_view
|
|
||||||
|
|
||||||
Locomotive.Views.ContentEntries ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.ContentEntries.PopupFormView extends Locomotive.Views.ContentEntries.FormView
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
@create_dialog()
|
|
||||||
|
|
||||||
super()
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
super()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
save: (event) ->
|
|
||||||
@save_in_ajax event,
|
|
||||||
headers: { 'X-Flash': true }
|
|
||||||
on_success: (response, xhr) =>
|
|
||||||
entry = new Locomotive.Models.ContentEntry(response)
|
|
||||||
@options.parent_view.insert_or_update_entry(entry)
|
|
||||||
@close()
|
|
||||||
|
|
||||||
create_dialog: ->
|
|
||||||
@dialog = $(@el).dialog
|
|
||||||
autoOpen: false
|
|
||||||
modal: true
|
|
||||||
zIndex: window.application_view.unique_dialog_zindex()
|
|
||||||
width: 770,
|
|
||||||
create: (event, ui) =>
|
|
||||||
$(@el).prev().find('.ui-dialog-title').html(@$('h2').html())
|
|
||||||
@$('h2').remove()
|
|
||||||
actions = @$('.dialog-actions').appendTo($(@el).parent()).addClass('ui-dialog-buttonpane ui-widget-content ui-helper-clearfix')
|
|
||||||
|
|
||||||
actions.find('#close-link').click (event) => @close(event)
|
|
||||||
actions.find('input[type=submit]').click (event) => @save(event)
|
|
||||||
|
|
||||||
open: (event, ui, extra) =>
|
|
||||||
$(@el).dialog('overlayEl').bind 'click', => @close()
|
|
||||||
# nothing to do
|
|
||||||
|
|
||||||
open: ->
|
|
||||||
parent_el = $(@el).parent()
|
|
||||||
if @model.isNew()
|
|
||||||
parent_el.find('.edit-section').hide()
|
|
||||||
parent_el.find('.new-section').show()
|
|
||||||
else
|
|
||||||
parent_el.find('.new-section').hide()
|
|
||||||
parent_el.find('.edit-section').show()
|
|
||||||
|
|
||||||
@clear_errors()
|
|
||||||
|
|
||||||
$(@el).dialog('open')
|
|
||||||
|
|
||||||
close: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault() if event?
|
|
||||||
@clear_errors()
|
|
||||||
$(@el).dialog('overlayEl').unbind('click')
|
|
||||||
$(@el).dialog('close')
|
|
||||||
|
|
||||||
center: ->
|
|
||||||
$(@el).dialog('option', 'position', 'center')
|
|
||||||
|
|
||||||
reset: (entry) =>
|
|
||||||
@model.set entry.attributes
|
|
||||||
|
|
||||||
if entry.isNew()
|
|
||||||
@model.id = null
|
|
||||||
super()
|
|
||||||
else
|
|
||||||
@refresh()
|
|
||||||
|
|
||||||
slugify_label_field: ->
|
|
||||||
# disabled in a popup form
|
|
||||||
|
|
||||||
enable_has_many_fields: ->
|
|
||||||
# disabled in a popup form
|
|
||||||
|
|
||||||
enable_many_to_many_fields: ->
|
|
||||||
# disabled in a popup form
|
|
||||||
|
|
||||||
tinyMCE_settings: ->
|
|
||||||
window.Locomotive.tinyMCE.popupSettings
|
|
@ -1,9 +0,0 @@
|
|||||||
Locomotive.Views.ContentEntries ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.ContentEntries.EditView extends Locomotive.Views.ContentEntries.FormView
|
|
||||||
|
|
||||||
save: (event) ->
|
|
||||||
@save_in_ajax event,
|
|
||||||
on_success: (response, xhr) =>
|
|
||||||
@model.update_attributes(response)
|
|
||||||
@refresh_file_fields()
|
|
@ -1,36 +0,0 @@
|
|||||||
Locomotive.Views.ContentEntries ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.ContentEntries.IndexView extends Backbone.View
|
|
||||||
|
|
||||||
el: '#content'
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
@make_sortable()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
make_sortable: ->
|
|
||||||
self = @
|
|
||||||
|
|
||||||
@$('ul#entries-list.sortable').sortable
|
|
||||||
handle: 'span.handle'
|
|
||||||
items: 'li.item'
|
|
||||||
axis: 'y'
|
|
||||||
update: (event, ui) -> self.call_sort $(@)
|
|
||||||
|
|
||||||
call_sort: (folder) ->
|
|
||||||
$.rails.ajax
|
|
||||||
url: folder.attr('data-url')
|
|
||||||
type: 'post'
|
|
||||||
dataType: 'json'
|
|
||||||
data:
|
|
||||||
entries: (_.map folder.sortable('toArray'), (el) -> el.replace('entry-', ''))
|
|
||||||
_method: 'put'
|
|
||||||
success: @.on_successful_sort
|
|
||||||
error: @.on_failed_sort
|
|
||||||
|
|
||||||
on_successful_sort: (data, status, xhr) ->
|
|
||||||
$.growl('success', xhr.getResponseHeader('X-Message'))
|
|
||||||
|
|
||||||
on_failed_sort: (data, status, xhr) ->
|
|
||||||
$.growl('error', xhr.getResponseHeader('X-Message'))
|
|
@ -1,8 +0,0 @@
|
|||||||
Locomotive.Views.ContentEntries ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.ContentEntries.NewView extends Locomotive.Views.ContentEntries.FormView
|
|
||||||
|
|
||||||
save: (event) ->
|
|
||||||
@save_in_ajax event,
|
|
||||||
on_success: (response, xhr) ->
|
|
||||||
window.location.href = xhr.getResponseHeader('location')
|
|
@ -1,83 +0,0 @@
|
|||||||
#= require ../shared/form_view
|
|
||||||
|
|
||||||
Locomotive.Views.ContentTypes ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.ContentTypes.FormView extends Locomotive.Views.Shared.FormView
|
|
||||||
|
|
||||||
el: '#content'
|
|
||||||
|
|
||||||
events:
|
|
||||||
'submit': 'save'
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
@model = new Locomotive.Models.ContentType(@options.content_type)
|
|
||||||
|
|
||||||
Backbone.ModelBinding.bind @
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
super()
|
|
||||||
|
|
||||||
@render_custom_fields()
|
|
||||||
|
|
||||||
@slugify_name() # slugify the slug field from name
|
|
||||||
|
|
||||||
@enable_liquid_editing() # turn textarea into editable liquid code zone
|
|
||||||
|
|
||||||
@enable_public_submission_checkbox()
|
|
||||||
|
|
||||||
@enable_order_by_toggler()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
render_custom_fields: ->
|
|
||||||
@custom_fields_view = new Locomotive.Views.ContentTypes.CustomFieldsView model: @model, inverse_of_list: @options.inverse_of_list
|
|
||||||
|
|
||||||
@$('#custom_fields_input').append(@custom_fields_view.render().el)
|
|
||||||
|
|
||||||
slugify_name: ->
|
|
||||||
@$('#content_type_name').slugify(target: @$('#content_type_slug'), sep: '_')
|
|
||||||
|
|
||||||
enable_liquid_editing: ->
|
|
||||||
input = @$('#content_type_raw_item_template')
|
|
||||||
@editor = CodeMirror.fromTextArea input.get()[0],
|
|
||||||
mode: 'liquid'
|
|
||||||
autoMatchParens: false
|
|
||||||
lineNumbers: false
|
|
||||||
passDelay: 50
|
|
||||||
tabMode: 'shift'
|
|
||||||
theme: 'default medium'
|
|
||||||
onChange: (editor) => @model.set(raw_item_template: editor.getValue())
|
|
||||||
|
|
||||||
enable_public_submission_checkbox: ->
|
|
||||||
@_enable_checkbox 'public_submission_enabled',
|
|
||||||
on_callback: => @$('#content_type_public_submission_accounts_input').show()
|
|
||||||
off_callback: => @$('#content_type_public_submission_accounts_input').hide()
|
|
||||||
|
|
||||||
enable_order_by_toggler: ->
|
|
||||||
@$('#content_type_order_by_input').bind 'change', (event) =>
|
|
||||||
target = @$('#content_type_order_direction_input')
|
|
||||||
if $(event.target).val() == '_position'
|
|
||||||
target.hide()
|
|
||||||
else
|
|
||||||
target.show()
|
|
||||||
|
|
||||||
show_error: (attribute, message, html) ->
|
|
||||||
if attribute != 'entries_custom_fields'
|
|
||||||
super
|
|
||||||
else
|
|
||||||
return if _.isEmpty(message)
|
|
||||||
|
|
||||||
_.each _.keys(message), (key) =>
|
|
||||||
_messages = message[key]
|
|
||||||
|
|
||||||
if key == 'base'
|
|
||||||
html = $("<div class=\"inline-errors\"><p>#{_messages[0]}</p></div>")
|
|
||||||
@$('#custom_fields_input .list').after(html)
|
|
||||||
else
|
|
||||||
view = @custom_fields_view.find_entry_view(key)
|
|
||||||
view.show_error(_messages[0]) if view?
|
|
||||||
|
|
||||||
remove: ->
|
|
||||||
@custom_fields_view.remove()
|
|
||||||
super
|
|
||||||
|
|
@ -1,104 +0,0 @@
|
|||||||
Locomotive.Views.ContentTypes ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.ContentTypes.CustomFieldEntryView extends Backbone.View
|
|
||||||
|
|
||||||
tagName: 'li'
|
|
||||||
|
|
||||||
className: 'custom-field'
|
|
||||||
|
|
||||||
events:
|
|
||||||
'click a.toggle': 'toggle'
|
|
||||||
'click a.remove': 'remove'
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
@inverse_of_list = @options.parent_view.options.inverse_of_list
|
|
||||||
|
|
||||||
@model.bind 'change', (custom_field) =>
|
|
||||||
@switch_to_type() if @model.hasChanged('type')
|
|
||||||
@fetch_inverse_of_list() if @model.hasChanged('class_name') && @model.get('class_name')?
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
$(@el).html(ich.custom_field_entry(@model.toJSON()))
|
|
||||||
|
|
||||||
@fetch_inverse_of_list() unless @model.isNew()
|
|
||||||
|
|
||||||
Backbone.ModelBinding.bind @, all: 'class'
|
|
||||||
|
|
||||||
@make_fields_editable()
|
|
||||||
|
|
||||||
@enable_behaviours()
|
|
||||||
|
|
||||||
@switch_to_type()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
enable_behaviours: ->
|
|
||||||
required_input = @$('.required-input input[type=checkbox]')
|
|
||||||
required_input.checkToggle(on_label: required_input.attr('data-on-label'), off_label: required_input.attr('data-off-label'))
|
|
||||||
@$('li.input.toggle input[type=checkbox]').checkToggle()
|
|
||||||
@render_select_options_view()
|
|
||||||
|
|
||||||
switch_to_type: ->
|
|
||||||
@$('li.input.extra').hide() # reset
|
|
||||||
|
|
||||||
switch @model.get('type')
|
|
||||||
when 'select'
|
|
||||||
@$('li.input.select-options').show()
|
|
||||||
when 'text'
|
|
||||||
@$('li.input.text-formatting').show()
|
|
||||||
when 'belongs_to'
|
|
||||||
@$('li.input.localized').hide()
|
|
||||||
@$('li.input.class-name').show()
|
|
||||||
when 'has_many', 'many_to_many'
|
|
||||||
@$('li.input.localized').hide()
|
|
||||||
@$('li.input.class-name').show()
|
|
||||||
@$('li.input.inverse-of').show()
|
|
||||||
@$('li.input.ui-enabled').show()
|
|
||||||
|
|
||||||
fetch_inverse_of_list: ->
|
|
||||||
@$('li.input.inverse-of select option').remove()
|
|
||||||
|
|
||||||
list = @inverse_of_list[@model.get('type')] || []
|
|
||||||
|
|
||||||
_.each list, (data) =>
|
|
||||||
if data.class_name == @model.get('class_name')
|
|
||||||
option = new Option(data.label, data.name, data.name == @model.get('inverse_of') || list.length == 1)
|
|
||||||
@$('li.input.inverse-of select').append(option)
|
|
||||||
|
|
||||||
# by default, select the first option
|
|
||||||
if !@model.get('inverse_of')? && list.length > 0
|
|
||||||
@model.set
|
|
||||||
inverse_of: list[0].name
|
|
||||||
|
|
||||||
render_select_options_view: ->
|
|
||||||
@select_options_view = new Locomotive.Views.ContentTypes.SelectOptionsView
|
|
||||||
model: @model
|
|
||||||
collection: @model.get('select_options')
|
|
||||||
|
|
||||||
@$('#content_type_contents_custom_field_select_options_input').append(@select_options_view.render().el)
|
|
||||||
|
|
||||||
make_fields_editable: ->
|
|
||||||
@$('.label-input input[type=text], .type-input select').editableField()
|
|
||||||
|
|
||||||
toggle: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
form = @$('ol')
|
|
||||||
|
|
||||||
if form.is(':hidden')
|
|
||||||
@$('a.toggle').addClass('open')
|
|
||||||
form.slideDown()
|
|
||||||
else
|
|
||||||
@$('a.toggle').removeClass('open')
|
|
||||||
form.slideUp()
|
|
||||||
|
|
||||||
show_error: (message) ->
|
|
||||||
html = $("<span class=\"inline-errors\">#{message}</span>")
|
|
||||||
@$('.required-input').after(html)
|
|
||||||
|
|
||||||
remove: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
if confirm($(event.target).attr('data-confirm'))
|
|
||||||
@$('.label-input input[type=text], .type-input select').editableField('destroy')
|
|
||||||
super()
|
|
||||||
@options.parent_view.remove_entry(@model, @)
|
|
@ -1,94 +0,0 @@
|
|||||||
Locomotive.Views.ContentTypes ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.ContentTypes.CustomFieldsView extends Backbone.View
|
|
||||||
|
|
||||||
tagName: 'div'
|
|
||||||
|
|
||||||
className: 'list'
|
|
||||||
|
|
||||||
_entry_views = []
|
|
||||||
|
|
||||||
events:
|
|
||||||
'click .new-entry a.add': 'add_entry'
|
|
||||||
'keypress .new-entry input[type=text]': 'add_on_entry_from_enter'
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
_.bindAll(@, 'refresh_position_entries')
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
$(@el).html(ich.custom_fields_list(@model.toJSON()))
|
|
||||||
|
|
||||||
@render_entries()
|
|
||||||
|
|
||||||
@make_list_sortable()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
make_list_sortable: ->
|
|
||||||
@sortable_list = @$('> ul').sortable
|
|
||||||
handle: '.handle'
|
|
||||||
items: 'li.custom-field'
|
|
||||||
axis: 'y'
|
|
||||||
update: @refresh_position_entries
|
|
||||||
|
|
||||||
refresh_position_entries: ->
|
|
||||||
_.each @_entry_views, (view) ->
|
|
||||||
view.model.set position: $(view.el).index()
|
|
||||||
|
|
||||||
find_entry_view: (key) ->
|
|
||||||
_.find @_entry_views, (view) ->
|
|
||||||
if key.length > 3
|
|
||||||
view.model.id == key
|
|
||||||
else
|
|
||||||
view.model.get('position') == parseInt(key)
|
|
||||||
|
|
||||||
add_entry: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
labelInput = @$('> .new-entry input[name=label]')
|
|
||||||
typeInput = @$('> .new-entry select')
|
|
||||||
|
|
||||||
if labelInput.val() != ''
|
|
||||||
custom_field = new Locomotive.Models.CustomField label: labelInput.val(), type: typeInput.val()
|
|
||||||
|
|
||||||
@model.get('entries_custom_fields').add(custom_field)
|
|
||||||
|
|
||||||
@_insert_entry(custom_field)
|
|
||||||
|
|
||||||
@$('> .empty').hide()
|
|
||||||
|
|
||||||
@sortable_list.sortable('refresh')
|
|
||||||
|
|
||||||
labelInput.val('') # reset for further entries
|
|
||||||
|
|
||||||
add_on_entry_from_enter: (event) ->
|
|
||||||
return if event.keyCode != 13
|
|
||||||
@add_entry(event)
|
|
||||||
|
|
||||||
remove_entry: (custom_field, view) ->
|
|
||||||
if custom_field.isNew()
|
|
||||||
@model.get('entries_custom_fields').remove(custom_field)
|
|
||||||
else
|
|
||||||
custom_field.set _destroy: true
|
|
||||||
|
|
||||||
@_entry_views = _.reject @_entry_views, (_view) -> _view == view
|
|
||||||
|
|
||||||
@refresh_position_entries()
|
|
||||||
|
|
||||||
@$('> .empty').show() if @_entry_views.length == 0
|
|
||||||
|
|
||||||
render_entries: ->
|
|
||||||
if @model.get('entries_custom_fields').length == 0
|
|
||||||
@$('> .empty').show()
|
|
||||||
else
|
|
||||||
@model.get('entries_custom_fields').each (custom_field) =>
|
|
||||||
@_insert_entry(custom_field)
|
|
||||||
|
|
||||||
_insert_entry: (custom_field) ->
|
|
||||||
view = new Locomotive.Views.ContentTypes.CustomFieldEntryView model: custom_field, parent_view: @
|
|
||||||
|
|
||||||
(@_entry_views ||= []).push(view)
|
|
||||||
|
|
||||||
@$('> ul').append(view.render().el)
|
|
||||||
|
|
||||||
@refresh_position_entries()
|
|
@ -1,14 +0,0 @@
|
|||||||
Locomotive.Views.ContentTypes ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.ContentTypes.EditView extends Locomotive.Views.ContentTypes.FormView
|
|
||||||
|
|
||||||
save: (event) ->
|
|
||||||
@save_in_ajax event, on_success: (response, xhr) =>
|
|
||||||
|
|
||||||
_.each response.entries_custom_fields, (data) =>
|
|
||||||
|
|
||||||
custom_field = @model.get('entries_custom_fields').detect (entry) => entry.get('name') == data.name
|
|
||||||
|
|
||||||
if custom_field.isNew() # assign an id for each new custom field
|
|
||||||
custom_field.set id: data._id, _id: data._id
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
|||||||
Locomotive.Views.ContentTypes ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.ContentTypes.NewView extends Locomotive.Views.ContentTypes.FormView
|
|
||||||
|
|
||||||
save: (event) ->
|
|
||||||
@save_in_ajax event,
|
|
||||||
on_success: (response, xhr) ->
|
|
||||||
window.location.href = xhr.getResponseHeader('location')
|
|
||||||
|
|
||||||
enable_liquid_editing: ->
|
|
||||||
true # do nothing
|
|
@ -1,85 +0,0 @@
|
|||||||
Locomotive.Views.ContentTypes ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.ContentTypes.SelectOptionsView extends Backbone.View
|
|
||||||
|
|
||||||
tagName: 'div'
|
|
||||||
|
|
||||||
className: 'list'
|
|
||||||
|
|
||||||
events:
|
|
||||||
'click a.add': 'add_entry'
|
|
||||||
'click span.name': 'edit_entry'
|
|
||||||
'click a.remove': 'remove_entry'
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
_.bindAll(@, 'refresh_position_entries', '_insert_entry')
|
|
||||||
|
|
||||||
@collection.bind 'add', @_insert_entry
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
$(@el).html(ich.select_options_list())
|
|
||||||
|
|
||||||
@prompt_message = @$('> ul').attr('data-prompt')
|
|
||||||
|
|
||||||
@render_entries()
|
|
||||||
|
|
||||||
@make_list_sortable()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
render_entries: ->
|
|
||||||
@collection.each @_insert_entry
|
|
||||||
|
|
||||||
make_list_sortable: ->
|
|
||||||
@sortable_list = @$('> ul').sortable
|
|
||||||
handle: 'a.drag'
|
|
||||||
items: 'li.entry'
|
|
||||||
update: @refresh_position_entries
|
|
||||||
|
|
||||||
refresh_position_entries: ->
|
|
||||||
@$('> ul li.entry').each (index, view_dom) =>
|
|
||||||
select_option = @collection.getByCid($(view_dom).attr('data-cid'))
|
|
||||||
select_option.set position: index
|
|
||||||
|
|
||||||
add_entry: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
name = prompt(@prompt_message)
|
|
||||||
|
|
||||||
if name != ''
|
|
||||||
@collection.add [{ name: name }]
|
|
||||||
|
|
||||||
edit_entry: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
span = $(event.target)
|
|
||||||
view_dom = span.closest('li')
|
|
||||||
select_option = @collection.getByCid(view_dom.attr('data-cid'))
|
|
||||||
|
|
||||||
if (name = prompt(@prompt_message, select_option.get('name'))) != ''
|
|
||||||
select_option.set(name: name)
|
|
||||||
span.html(name)
|
|
||||||
|
|
||||||
remove_entry: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
link = $(event.target)
|
|
||||||
view_dom = link.closest('li')
|
|
||||||
select_option = @collection.getByCid(view_dom.attr('data-cid'))
|
|
||||||
|
|
||||||
if confirm(link.attr('date-confirm'))
|
|
||||||
if select_option.isNew()
|
|
||||||
@collection.remove(select_option)
|
|
||||||
else
|
|
||||||
select_option.set _destroy: true
|
|
||||||
|
|
||||||
view_dom.remove()
|
|
||||||
|
|
||||||
_insert_entry: (select_option) ->
|
|
||||||
view_dom = ich.select_option_entry(select_option.toJSON())
|
|
||||||
|
|
||||||
view_dom.attr('data-cid', select_option.cid)
|
|
||||||
|
|
||||||
@$('> ul').append(view_dom)
|
|
||||||
|
|
||||||
@refresh_position_entries
|
|
@ -1,83 +0,0 @@
|
|||||||
#= require ../shared/form_view
|
|
||||||
#= require ../sites/domains_view
|
|
||||||
|
|
||||||
Locomotive.Views.CurrentSite ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.CurrentSite.EditView extends Locomotive.Views.Shared.FormView
|
|
||||||
|
|
||||||
el: '#content'
|
|
||||||
|
|
||||||
events:
|
|
||||||
'submit': 'save'
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
@model = new Locomotive.Models.CurrentSite(@options.site)
|
|
||||||
|
|
||||||
Backbone.ModelBinding.bind @, checkbox: 'class'
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
super()
|
|
||||||
|
|
||||||
@add_toggle_mode_for_locales()
|
|
||||||
|
|
||||||
@make_locales_sortable()
|
|
||||||
|
|
||||||
@render_domains()
|
|
||||||
|
|
||||||
@render_memberships()
|
|
||||||
|
|
||||||
@enable_liquid_editing()
|
|
||||||
|
|
||||||
add_toggle_mode_for_locales: ->
|
|
||||||
@$('#site_locales_input .list input[type=checkbox]').bind 'change', (event) ->
|
|
||||||
el = $(event.target)
|
|
||||||
if el.is(':checked')
|
|
||||||
el.closest('.entry').addClass('selected')
|
|
||||||
else
|
|
||||||
el.closest('.entry').removeClass('selected')
|
|
||||||
|
|
||||||
make_locales_sortable: ->
|
|
||||||
@sortable_locales_list = @$('#site_locales_input .list').sortable
|
|
||||||
items: '.entry'
|
|
||||||
tolerance: 'pointer'
|
|
||||||
update: =>
|
|
||||||
list = _.map @$('#site_locales_input .list input:checked'), (el) => $(el).val()
|
|
||||||
@model.set locales: list
|
|
||||||
|
|
||||||
render_domains: ->
|
|
||||||
@domains_view = new Locomotive.Views.Sites.DomainsView model: @model, errors: @options.errors
|
|
||||||
|
|
||||||
@$('#site_domains_input label').after(@domains_view.render().el)
|
|
||||||
|
|
||||||
render_memberships: ->
|
|
||||||
@memberships_view = new Locomotive.Views.Sites.MembershipsView model: @model
|
|
||||||
|
|
||||||
@$('#site_memberships_input').append(@memberships_view.render().el)
|
|
||||||
|
|
||||||
enable_liquid_editing: ->
|
|
||||||
if($('#site_robots_txt').length)
|
|
||||||
input = @$('#site_robots_txt')
|
|
||||||
@editor = CodeMirror.fromTextArea input.get()[0],
|
|
||||||
mode: 'liquid'
|
|
||||||
autoMatchParens: false
|
|
||||||
lineNumbers: false
|
|
||||||
passDelay: 50
|
|
||||||
tabMode: 'shift'
|
|
||||||
theme: 'default'
|
|
||||||
onChange: (editor) => @model.set(robots_txt: editor.getValue())
|
|
||||||
|
|
||||||
save: (event) ->
|
|
||||||
if @model.includes_domain(window.location.host)
|
|
||||||
@save_in_ajax(event)
|
|
||||||
|
|
||||||
show_error: (attribute, message, html) ->
|
|
||||||
if attribute == 'domains'
|
|
||||||
@domains_view.show_error(message)
|
|
||||||
else
|
|
||||||
super
|
|
||||||
|
|
||||||
remove: ->
|
|
||||||
@domains_view.remove()
|
|
||||||
@memberships_view.remove()
|
|
||||||
super
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
|||||||
Locomotive.Views.EditableElements ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.EditableElements.ControlView extends Backbone.View
|
|
||||||
|
|
||||||
tagName: 'li'
|
|
||||||
|
|
||||||
className: 'control input'
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
$(@el).html(ich.editable_control_input(@model.toJSON()))
|
|
||||||
|
|
||||||
@bind_model()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
after_render: ->
|
|
||||||
# do nothing
|
|
||||||
|
|
||||||
refresh: ->
|
|
||||||
@bind_model()
|
|
||||||
|
|
||||||
bind_model: ->
|
|
||||||
Backbone.ModelBinding.bind @, { select: 'class' }
|
|
||||||
|
|
@ -1,83 +0,0 @@
|
|||||||
Locomotive.Views.EditableElements ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.EditableElements.EditAllView extends Backbone.View
|
|
||||||
|
|
||||||
id: 'editable-elements'
|
|
||||||
|
|
||||||
tagName: 'div'
|
|
||||||
|
|
||||||
_editable_elements_views: []
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
window.bar = @
|
|
||||||
|
|
||||||
if @collection.isEmpty()
|
|
||||||
$(@el).hide()
|
|
||||||
else
|
|
||||||
@blocks = @collection.blocks()
|
|
||||||
|
|
||||||
$(@el).html(ich.editable_elements_edit(blocks: @blocks))
|
|
||||||
|
|
||||||
@render_elements()
|
|
||||||
|
|
||||||
@enable_nav()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
after_render: ->
|
|
||||||
_.each @_editable_elements_views, (view) => view.after_render()
|
|
||||||
|
|
||||||
refresh: ->
|
|
||||||
_.each @_editable_elements_views, (view) =>
|
|
||||||
view.model = @collection.get(view.model.get('id'))
|
|
||||||
view.refresh()
|
|
||||||
|
|
||||||
unbind_model: ->
|
|
||||||
_.each @_editable_elements_views, (view) => Backbone.ModelBinding.unbind(view)
|
|
||||||
|
|
||||||
render_elements: ->
|
|
||||||
index = 0
|
|
||||||
|
|
||||||
_.each @blocks, (block) =>
|
|
||||||
list = @collection.by_block block.name
|
|
||||||
|
|
||||||
_.each list, (element) =>
|
|
||||||
element.set(index: index)
|
|
||||||
|
|
||||||
view_class = switch element.get('type')
|
|
||||||
when 'EditableShortText' then Locomotive.Views.EditableElements.ShortTextView
|
|
||||||
when 'EditableLongText' then Locomotive.Views.EditableElements.LongTextView
|
|
||||||
when 'EditableFile' then Locomotive.Views.EditableElements.FileView
|
|
||||||
when 'EditableControl' then Locomotive.Views.EditableElements.ControlView
|
|
||||||
|
|
||||||
view = new view_class(model: element)
|
|
||||||
@$("#block-#{block.index} > fieldset > ol").append(view.render().el)
|
|
||||||
|
|
||||||
@_editable_elements_views.push(view)
|
|
||||||
|
|
||||||
index += 1
|
|
||||||
|
|
||||||
enable_nav: ->
|
|
||||||
@$('.nav a').click (event) =>
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
link = $(event.target)
|
|
||||||
index = parseInt(link.attr('href').match(/block-(.+)/)[1])
|
|
||||||
|
|
||||||
@$('.wrapper ul li.block').hide()
|
|
||||||
@$("#block-#{index}").show()
|
|
||||||
@_hide_last_separator()
|
|
||||||
|
|
||||||
link.parent().find('.on').removeClass('on')
|
|
||||||
link.addClass('on')
|
|
||||||
|
|
||||||
_hide_last_separator: ->
|
|
||||||
_.each @$('fieldset'), (fieldset) =>
|
|
||||||
$(fieldset).find('li.last').removeClass('last')
|
|
||||||
$(_.last($(fieldset).find('li.input:visible'))).addClass('last')
|
|
||||||
|
|
||||||
remove: ->
|
|
||||||
_.each @_editable_elements_views, (view) => view.remove()
|
|
||||||
@_editable_elements_views.length = 0
|
|
||||||
super
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
|||||||
Locomotive.Views.EditableElements ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.EditableElements.FileView extends Backbone.View
|
|
||||||
|
|
||||||
tagName: 'li'
|
|
||||||
|
|
||||||
className: 'file input'
|
|
||||||
|
|
||||||
states:
|
|
||||||
change: false
|
|
||||||
delete: false
|
|
||||||
|
|
||||||
events:
|
|
||||||
'click a.change': 'toggle_change'
|
|
||||||
'click a.delete': 'toggle_delete'
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
$(@el).html(ich.editable_file_input(@model.toJSON()))
|
|
||||||
|
|
||||||
# only in HTML 5
|
|
||||||
@$('input[type=file]').bind 'change', (event) =>
|
|
||||||
input = $(event.target)[0]
|
|
||||||
if input.files?
|
|
||||||
@model.set(source: input.files[0])
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
after_render: ->
|
|
||||||
# do nothing
|
|
||||||
|
|
||||||
refresh: ->
|
|
||||||
@$('input[type=file]').unbind 'change'
|
|
||||||
@states = { 'change': false, 'delete': false }
|
|
||||||
@render()
|
|
||||||
|
|
||||||
toggle_change: (event) ->
|
|
||||||
@_toggle event, 'change',
|
|
||||||
on_change: =>
|
|
||||||
@$('a:first').hide() & @$('input[type=file]').show() & @$('a.delete').hide()
|
|
||||||
on_cancel: =>
|
|
||||||
@model.set(source: null)
|
|
||||||
@$('a:first').show() & @$('input[type=file]').val('').hide() & @$('a.delete').show()
|
|
||||||
|
|
||||||
toggle_delete: (event) ->
|
|
||||||
@_toggle event, 'delete',
|
|
||||||
on_change: =>
|
|
||||||
@$('a:first').addClass('deleted') & @$('a.change').hide()
|
|
||||||
@$('input[type=hidden].remove-flag').val('1')
|
|
||||||
@model.set('remove_source': true)
|
|
||||||
on_cancel: =>
|
|
||||||
@$('a:first').removeClass('deleted') & @$('a.change').show()
|
|
||||||
@$('input[type=hidden].remove-flag').val('0')
|
|
||||||
@model.set('remove_source': false)
|
|
||||||
|
|
||||||
_toggle: (event, state, options) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
button = $(event.target)
|
|
||||||
label = button.attr('data-alt-label')
|
|
||||||
|
|
||||||
unless @states[state]
|
|
||||||
options.on_change()
|
|
||||||
else
|
|
||||||
options.on_cancel()
|
|
||||||
|
|
||||||
button.attr('data-alt-label', button.html())
|
|
||||||
|
|
||||||
button.html(label)
|
|
||||||
|
|
||||||
@states[state] = !@states[state]
|
|
||||||
|
|
||||||
remove: ->
|
|
||||||
@$('input[type=file]').unbind 'change'
|
|
||||||
super
|
|
@ -1,36 +0,0 @@
|
|||||||
#= require ./short_text_view
|
|
||||||
|
|
||||||
Locomotive.Views.EditableElements ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.EditableElements.LongTextView extends Backbone.View
|
|
||||||
|
|
||||||
tagName: 'li'
|
|
||||||
|
|
||||||
className: 'text input html'
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
$(@el).html(ich.editable_text_input(@model.toJSON()))
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
after_render: ->
|
|
||||||
settings = _.extend {}, @tinymce_settings(),
|
|
||||||
oninit: ((editor) =>
|
|
||||||
$.cmd 'S', (() =>
|
|
||||||
@model.set(content: editor.getBody().innerHTML)
|
|
||||||
$(@el).parents('form').trigger('submit')
|
|
||||||
), [], ignoreCase: true, document: editor.dom.doc),
|
|
||||||
onchange_callback: (editor) =>
|
|
||||||
@model.set(content: editor.getBody().innerHTML)
|
|
||||||
|
|
||||||
@$('textarea').tinymce(settings)
|
|
||||||
|
|
||||||
tinymce_settings: ->
|
|
||||||
window.Locomotive.tinyMCE.defaultSettings
|
|
||||||
|
|
||||||
refresh: ->
|
|
||||||
# do nothing
|
|
||||||
|
|
||||||
remove: ->
|
|
||||||
@$('textarea').tinymce().destroy()
|
|
||||||
super
|
|
@ -1,22 +0,0 @@
|
|||||||
Locomotive.Views.EditableElements ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.EditableElements.ShortTextView extends Backbone.View
|
|
||||||
|
|
||||||
tagName: 'li'
|
|
||||||
|
|
||||||
className: 'text input short'
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
$(@el).html(ich.editable_text_input(@model.toJSON()))
|
|
||||||
|
|
||||||
@$('textarea').bind 'keyup', (event) =>
|
|
||||||
input = $(event.target)
|
|
||||||
@model.set(content: input.val())
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
after_render: ->
|
|
||||||
# do nothing
|
|
||||||
|
|
||||||
refresh: ->
|
|
||||||
# do nothing
|
|
@ -1,103 +0,0 @@
|
|||||||
Locomotive.Views.InlineEditor ||= {}
|
|
||||||
|
|
||||||
#= require ./toolbar_view
|
|
||||||
|
|
||||||
class Locomotive.Views.InlineEditor.ApplicationView extends Backbone.View
|
|
||||||
|
|
||||||
el: 'body'
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
super
|
|
||||||
|
|
||||||
@iframe = @$('#page iframe')
|
|
||||||
|
|
||||||
_.bindAll(@, '_$')
|
|
||||||
|
|
||||||
@toolbar_view = new Locomotive.Views.InlineEditor.ToolbarView(target: @iframe)
|
|
||||||
|
|
||||||
@content_assets_picker_view = new Locomotive.Views.ContentAssets.PickerView(collection: new Locomotive.Models.ContentAssetsCollection())
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
super
|
|
||||||
|
|
||||||
@enable_iframe_autoheight()
|
|
||||||
|
|
||||||
@toolbar_view.render()
|
|
||||||
|
|
||||||
@content_assets_picker_view.render()
|
|
||||||
|
|
||||||
enable_iframe_autoheight: ->
|
|
||||||
iframe = @iframe
|
|
||||||
|
|
||||||
iframe.load =>
|
|
||||||
if @_$('meta[name=inline-editor]').size() > 0
|
|
||||||
# bind the resize event. When the iFrame's size changes, update its height
|
|
||||||
iframe_content = iframe.contents()
|
|
||||||
iframe_content.resize ->
|
|
||||||
elem = $(this)
|
|
||||||
|
|
||||||
if elem.outerHeight(true) > iframe.outerHeight(true) # Resize the iFrame.
|
|
||||||
iframe.css height: elem.outerHeight(true)
|
|
||||||
|
|
||||||
# Resize the iFrame immediately.
|
|
||||||
iframe_content.resize()
|
|
||||||
else
|
|
||||||
@toolbar_view.show_status('disabled', true).hide_editing_mode_block()
|
|
||||||
|
|
||||||
# keep the user in the admin mode
|
|
||||||
@enhance_iframe_links()
|
|
||||||
|
|
||||||
set_page: (attributes) ->
|
|
||||||
@page = new Locomotive.Models.Page(attributes)
|
|
||||||
|
|
||||||
@toolbar_view.model = @page
|
|
||||||
|
|
||||||
@enhance_iframe()
|
|
||||||
|
|
||||||
@toolbar_view.refresh()
|
|
||||||
|
|
||||||
enhance_iframe: ->
|
|
||||||
_window = @iframe[0].contentWindow
|
|
||||||
_window.Aloha.settings.locale = window.locale
|
|
||||||
|
|
||||||
# set main window title
|
|
||||||
window.document.title = _window.document.title
|
|
||||||
|
|
||||||
# keep the user in the admin mode
|
|
||||||
@enhance_iframe_links _window.Aloha.jQuery
|
|
||||||
|
|
||||||
# notify the toolbar about changes
|
|
||||||
_window.Aloha.bind 'aloha-editable-deactivated', (event, editable) =>
|
|
||||||
@toolbar_view.notify editable.editable
|
|
||||||
|
|
||||||
enhance_iframe_links: (_jQuery) ->
|
|
||||||
|
|
||||||
toolbar_view = @toolbar_view
|
|
||||||
_jQuery ||= @_$
|
|
||||||
|
|
||||||
_jQuery('a').each ->
|
|
||||||
link = _jQuery(this)
|
|
||||||
url = link.attr('href')
|
|
||||||
if url? && url.indexOf('#') != 0 && /^(www|http)/.exec(url) == null && /(\/_edit)$/.exec(url) == null && /^\/sites\//.exec(url) == null
|
|
||||||
url = '/index' if url == '/'
|
|
||||||
|
|
||||||
unless url.indexOf('_edit') > 0
|
|
||||||
if url.indexOf('?') > 0
|
|
||||||
link.attr('href', url.replace('?', '/_edit?'))
|
|
||||||
else
|
|
||||||
link.attr('href', "#{url}/_edit")
|
|
||||||
|
|
||||||
link.bind 'click', ->
|
|
||||||
toolbar_view.show_status 'loading'
|
|
||||||
window.history.pushState('Object', 'Title', link.attr('href').replace('_edit', '_admin'))
|
|
||||||
|
|
||||||
unique_dialog_zindex: ->
|
|
||||||
# returns the number of jQuery UI modals created in order to set a valid zIndex for each of them.
|
|
||||||
# Each modal window should have a different zIndex, otherwise there will be conflicts between them.
|
|
||||||
window.Locomotive.jQueryModals ||= 0
|
|
||||||
|
|
||||||
1050 + window.Locomotive.jQueryModals++
|
|
||||||
|
|
||||||
_$: (selector) ->
|
|
||||||
$(selector, @iframe[0].contentWindow.document)
|
|
||||||
|
|
@ -1,131 +0,0 @@
|
|||||||
Locomotive.Views.InlineEditor ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.InlineEditor.ToolbarView extends Backbone.View
|
|
||||||
|
|
||||||
el: '#toolbar .inner'
|
|
||||||
|
|
||||||
events:
|
|
||||||
'change .editing-mode input[type=checkbox]': 'toggle_editing_mode'
|
|
||||||
'click .back a': 'back'
|
|
||||||
'click .element-actions a.save': 'save_changes'
|
|
||||||
'click .element-actions a.cancel': 'cancel_changes'
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
super
|
|
||||||
|
|
||||||
@enable_editing_mode_checkbox()
|
|
||||||
|
|
||||||
@enable_content_locale_picker()
|
|
||||||
|
|
||||||
@
|
|
||||||
|
|
||||||
notify: (aloha_editable) ->
|
|
||||||
window.bar = aloha_editable
|
|
||||||
|
|
||||||
element_id = aloha_editable.obj.attr('data-element-id')
|
|
||||||
@model.get('editable_elements').get(element_id).set
|
|
||||||
content: aloha_editable.getContents()
|
|
||||||
|
|
||||||
@$('.element-actions').show()
|
|
||||||
|
|
||||||
@hide_editing_mode_block()
|
|
||||||
|
|
||||||
show_status: (status, growl) ->
|
|
||||||
growl ||= false
|
|
||||||
|
|
||||||
message = @$('h1').attr("data-#{status}-status")
|
|
||||||
@$('h1').html(message).removeClass().addClass(status)
|
|
||||||
|
|
||||||
$.growl('error', message) if growl
|
|
||||||
|
|
||||||
@
|
|
||||||
|
|
||||||
save_changes: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
previous_attributes = _.clone @model.attributes
|
|
||||||
|
|
||||||
@model.save {},
|
|
||||||
success: (model, response, xhr) =>
|
|
||||||
model.attributes = previous_attributes
|
|
||||||
@$('.element-actions').hide()
|
|
||||||
@show_editing_mode_block()
|
|
||||||
error: (model, xhr) =>
|
|
||||||
@$('.element-actions').hide()
|
|
||||||
|
|
||||||
cancel_changes: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
@options.target[0].contentWindow.location.href = @options.target[0].contentWindow.location.href
|
|
||||||
|
|
||||||
back: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
if @model
|
|
||||||
window.location.href = @model.get('edit_url')
|
|
||||||
else
|
|
||||||
window.location.href = window.Locomotive.mounted_on + '/pages'
|
|
||||||
|
|
||||||
show_editing_mode_block: ->
|
|
||||||
@$('.editing-mode').show()
|
|
||||||
|
|
||||||
hide_editing_mode_block: ->
|
|
||||||
@$('.editing-mode').hide()
|
|
||||||
|
|
||||||
toggle_editing_mode: (event) ->
|
|
||||||
return if @editable_elements() == null
|
|
||||||
|
|
||||||
if $(event.target).is(':checked')
|
|
||||||
@editable_elements().aloha()
|
|
||||||
else
|
|
||||||
@editable_elements().removeClass('aloha-editable-highlight').mahalo()
|
|
||||||
|
|
||||||
editable_elements: ->
|
|
||||||
if @options.target[0].contentWindow.Aloha
|
|
||||||
@options.target[0].contentWindow.Aloha.jQuery('.editable-long-text, .editable-short-text')
|
|
||||||
else
|
|
||||||
null
|
|
||||||
|
|
||||||
enable_editing_mode_checkbox: ->
|
|
||||||
@$('.editing-mode input[type=checkbox]').checkToggle
|
|
||||||
on_label_color: '#fff'
|
|
||||||
off_label_color: '#bbb'
|
|
||||||
|
|
||||||
enable_content_locale_picker: ->
|
|
||||||
_window = @options.target[0].contentWindow
|
|
||||||
link = @$('#content-locale-picker-link')
|
|
||||||
picker = $('#content-locale-picker')
|
|
||||||
|
|
||||||
return if picker.size() == 0
|
|
||||||
|
|
||||||
link.bind 'click', (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
picker.toggle()
|
|
||||||
|
|
||||||
picker.find('li').bind 'click', (event) =>
|
|
||||||
current = @get_locale_attributes(link)
|
|
||||||
selected = @get_locale_attributes($(event.target).closest('li'))
|
|
||||||
|
|
||||||
@set_locale_attributes(link, selected)
|
|
||||||
@set_locale_attributes($(event.target).closest('li'), current)
|
|
||||||
|
|
||||||
picker.toggle()
|
|
||||||
|
|
||||||
window.content_locale = selected[1]
|
|
||||||
|
|
||||||
_window.location.href = '/' + @model.get('localized_fullpaths')[selected[1]] + '/_edit'
|
|
||||||
|
|
||||||
get_locale_attributes: (context) ->
|
|
||||||
[context.find('img').attr('src'), context.find('span.text').html()]
|
|
||||||
|
|
||||||
set_locale_attributes: (context, values) ->
|
|
||||||
context.find('img').attr('src', values[0])
|
|
||||||
context.find('span.text').html(values[1])
|
|
||||||
|
|
||||||
refresh: ->
|
|
||||||
@$('h1').html(@model.get('title')).removeClass()
|
|
||||||
|
|
||||||
if @$('.editing-mode input[type=checkbox]').is(':checked')
|
|
||||||
@$('.editing-mode div.switchArea').trigger('click')
|
|
||||||
|
|
||||||
@$('.element-actions').hide()
|
|
||||||
|
|
||||||
@show_editing_mode_block()
|
|
@ -1,24 +0,0 @@
|
|||||||
#= require ../shared/form_view
|
|
||||||
|
|
||||||
Locomotive.Views.MyAccount ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.MyAccount.EditView extends Locomotive.Views.Shared.FormView
|
|
||||||
|
|
||||||
el: '#content'
|
|
||||||
|
|
||||||
events:
|
|
||||||
'submit': 'save'
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
@model = new Locomotive.Models.CurrentAccount(@options.account)
|
|
||||||
|
|
||||||
Backbone.ModelBinding.bind @
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
super()
|
|
||||||
|
|
||||||
save: (event) ->
|
|
||||||
if @model.get('locale') == window.locale
|
|
||||||
@save_in_ajax(event)
|
|
||||||
|
|
||||||
|
|
@ -1,149 +0,0 @@
|
|||||||
#= require ../shared/form_view
|
|
||||||
|
|
||||||
Locomotive.Views.Pages ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Pages.FormView extends Locomotive.Views.Shared.FormView
|
|
||||||
|
|
||||||
el: '#content'
|
|
||||||
|
|
||||||
events:
|
|
||||||
'change #page_parent_id': 'change_page_url'
|
|
||||||
'click a#image-picker-link': 'open_image_picker'
|
|
||||||
'submit': 'save'
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
_.bindAll(@, 'insert_image')
|
|
||||||
|
|
||||||
@model = new Locomotive.Models.Page(@options.page)
|
|
||||||
|
|
||||||
@touched_url = false
|
|
||||||
|
|
||||||
@image_picker_view = new Locomotive.Views.ThemeAssets.ImagePickerView
|
|
||||||
collection: new Locomotive.Models.ThemeAssetsCollection()
|
|
||||||
on_select: @insert_image
|
|
||||||
|
|
||||||
@image_picker_view.render()
|
|
||||||
|
|
||||||
Backbone.ModelBinding.bind @
|
|
||||||
|
|
||||||
@editable_elements_view = new Locomotive.Views.EditableElements.EditAllView(collection: @model.get('editable_elements'))
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
super()
|
|
||||||
|
|
||||||
# slugify the slug field from title
|
|
||||||
@slugify_title()
|
|
||||||
|
|
||||||
# the url gets modified by different ways so reflect the changes in the UI
|
|
||||||
@listen_for_url_changes()
|
|
||||||
|
|
||||||
# enable response type
|
|
||||||
@enable_response_type_select()
|
|
||||||
|
|
||||||
# enable check boxes
|
|
||||||
@enable_templatized_checkbox()
|
|
||||||
|
|
||||||
@enable_redirect_checkbox()
|
|
||||||
|
|
||||||
@enable_other_checkboxes()
|
|
||||||
|
|
||||||
# liquid code textarea
|
|
||||||
@enable_liquid_editing()
|
|
||||||
|
|
||||||
# editable elements
|
|
||||||
@render_editable_elements()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
open_image_picker: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
@image_picker_view.editor = @editor
|
|
||||||
@image_picker_view.fetch_assets()
|
|
||||||
|
|
||||||
insert_image: (path) ->
|
|
||||||
text = "{{ '#{path}' | theme_image_url }}"
|
|
||||||
@editor.replaceSelection(text)
|
|
||||||
@image_picker_view.close()
|
|
||||||
|
|
||||||
enable_liquid_editing: ->
|
|
||||||
input = @$('#page_raw_template')
|
|
||||||
|
|
||||||
if input.size() > 0
|
|
||||||
@editor = CodeMirror.fromTextArea input.get()[0],
|
|
||||||
mode: 'liquid'
|
|
||||||
autoMatchParens: false
|
|
||||||
lineNumbers: false
|
|
||||||
passDelay: 50
|
|
||||||
tabMode: 'shift'
|
|
||||||
theme: 'default'
|
|
||||||
onChange: (editor) => @model.set(raw_template: editor.getValue())
|
|
||||||
|
|
||||||
after_inputs_fold: ->
|
|
||||||
@editor.refresh()
|
|
||||||
|
|
||||||
render_editable_elements: ->
|
|
||||||
@$('.formtastic fieldset.inputs:first').before(@editable_elements_view.render().el)
|
|
||||||
@editable_elements_view.after_render()
|
|
||||||
|
|
||||||
# Remove the editable elements and rebuild them
|
|
||||||
reset_editable_elements: ->
|
|
||||||
@editable_elements_view.remove()
|
|
||||||
@editable_elements_view.collection = @model.get('editable_elements')
|
|
||||||
@render_editable_elements()
|
|
||||||
|
|
||||||
# Just re-connect the model and the views (+ redraw the file fields)
|
|
||||||
refresh_editable_elements: ->
|
|
||||||
@editable_elements_view.unbind_model()
|
|
||||||
@editable_elements_view.collection = @model.get('editable_elements')
|
|
||||||
@editable_elements_view.refresh()
|
|
||||||
|
|
||||||
slugify_title: ->
|
|
||||||
@$('#page_title').slugify(target: @$('#page_slug'))
|
|
||||||
@$('#page_slug').bind 'change', ((event) => @touched_url = true)
|
|
||||||
|
|
||||||
listen_for_url_changes: ->
|
|
||||||
setInterval (=> (@change_page_url() & @touched_url = false) if @touched_url), 2000
|
|
||||||
|
|
||||||
change_page_url: ->
|
|
||||||
$.rails.ajax
|
|
||||||
url: @$('#page_slug').attr('data-url')
|
|
||||||
type: 'get'
|
|
||||||
dataType: 'json'
|
|
||||||
data: { parent_id: @$('#page_parent_id').val(), slug: @$('#page_slug').val() }
|
|
||||||
success: (data) =>
|
|
||||||
@$('#page_slug_input .inline-hints').html(data.url).effect('highlight')
|
|
||||||
if data.templatized_parent
|
|
||||||
@$('li#page_slug_input').show()
|
|
||||||
@$('li#page_templatized_input, li#page_target_klass_name_input').hide()
|
|
||||||
else
|
|
||||||
@$('li#page_templatized_input').show() unless @model.get('redirect')
|
|
||||||
|
|
||||||
enable_response_type_select: ->
|
|
||||||
@$('li#page_response_type_input').change (event) =>
|
|
||||||
if $(event.target).val() == 'text/html'
|
|
||||||
@$('li#page_redirect_input, li#page_redirect_url_input').show()
|
|
||||||
else
|
|
||||||
@model.set redirect: false
|
|
||||||
@$('li#page_redirect_input, li#page_redirect_url_input').hide()
|
|
||||||
|
|
||||||
enable_templatized_checkbox: ->
|
|
||||||
@_enable_checkbox 'templatized',
|
|
||||||
features: ['slug', 'redirect', 'listed']
|
|
||||||
on_callback: =>
|
|
||||||
@$('li#page_target_klass_name_input').show()
|
|
||||||
off_callback: =>
|
|
||||||
@$('li#page_target_klass_name_input').hide()
|
|
||||||
|
|
||||||
@$('li#page_templatized_input').hide() if @model.get('templatized_from_parent') == true
|
|
||||||
|
|
||||||
enable_redirect_checkbox: ->
|
|
||||||
@_enable_checkbox 'redirect',
|
|
||||||
features: ['templatized', 'cache_strategy']
|
|
||||||
on_callback: =>
|
|
||||||
@$('li#page_redirect_url_input').show()
|
|
||||||
off_callback: =>
|
|
||||||
@$('li#page_redirect_url_input').hide()
|
|
||||||
|
|
||||||
enable_other_checkboxes: ->
|
|
||||||
_.each ['published', 'listed'], (exp) =>
|
|
||||||
@$('li#page_' + exp + '_input input[type=checkbox]').checkToggle()
|
|
@ -1,28 +0,0 @@
|
|||||||
Locomotive.Views.Pages ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Pages.EditView extends Locomotive.Views.Pages.FormView
|
|
||||||
|
|
||||||
save: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
form = $(event.target).trigger('ajax:beforeSend')
|
|
||||||
|
|
||||||
@clear_errors()
|
|
||||||
|
|
||||||
@model.save {},
|
|
||||||
success: (model, response, xhr) =>
|
|
||||||
form.trigger('ajax:complete')
|
|
||||||
|
|
||||||
model._normalize()
|
|
||||||
|
|
||||||
if model.get('template_changed') == true
|
|
||||||
@reset_editable_elements()
|
|
||||||
else
|
|
||||||
@refresh_editable_elements()
|
|
||||||
|
|
||||||
error: (model, xhr) =>
|
|
||||||
form.trigger('ajax:complete')
|
|
||||||
|
|
||||||
errors = JSON.parse(xhr.responseText)
|
|
||||||
|
|
||||||
@show_errors errors
|
|
@ -1,11 +0,0 @@
|
|||||||
Locomotive.Views.Pages ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Pages.IndexView extends Backbone.View
|
|
||||||
|
|
||||||
el: '#content'
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
@index_view = new Locomotive.Views.Pages.ListView()
|
|
||||||
@index_view.render()
|
|
||||||
|
|
||||||
return @
|
|
@ -1,40 +0,0 @@
|
|||||||
Locomotive.Views.Pages ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Pages.ListView extends Backbone.View
|
|
||||||
|
|
||||||
el: '#pages-list'
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
@make_foldable()
|
|
||||||
|
|
||||||
@make_sortable()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
make_foldable: ->
|
|
||||||
@$('ul.folder img.toggler').toggleMe()
|
|
||||||
|
|
||||||
make_sortable: ->
|
|
||||||
self = @
|
|
||||||
|
|
||||||
@$('ul.folder').sortable
|
|
||||||
handle: 'em'
|
|
||||||
axis: 'y'
|
|
||||||
update: (event, ui) -> self.call_sort $(@)
|
|
||||||
|
|
||||||
call_sort: (folder) ->
|
|
||||||
$.rails.ajax
|
|
||||||
url: folder.attr('data-url')
|
|
||||||
type: 'post'
|
|
||||||
dataType: 'json'
|
|
||||||
data:
|
|
||||||
children: (_.map folder.sortable('toArray'), (el) -> el.replace('item-', ''))
|
|
||||||
_method: 'put'
|
|
||||||
success: @.on_successful_sort
|
|
||||||
error: @.on_failed_sort
|
|
||||||
|
|
||||||
on_successful_sort: (data, status, xhr) ->
|
|
||||||
$.growl('success', xhr.getResponseHeader('X-Message'))
|
|
||||||
|
|
||||||
on_failed_sort: (data, status, xhr) ->
|
|
||||||
$.growl('error', xhr.getResponseHeader('X-Message'))
|
|
@ -1,8 +0,0 @@
|
|||||||
Locomotive.Views.Pages ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Pages.NewView extends Locomotive.Views.Pages.FormView
|
|
||||||
|
|
||||||
save: (event) ->
|
|
||||||
@save_in_ajax event,
|
|
||||||
on_success: (response, xhr) ->
|
|
||||||
window.location.href = xhr.getResponseHeader('location')
|
|
@ -1,92 +0,0 @@
|
|||||||
Locomotive.Views.Shared ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Shared.AssetPickerView extends Backbone.View
|
|
||||||
|
|
||||||
tag: 'div'
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
_.bindAll(@, 'add_assets', 'add_asset', 'remove_asset')
|
|
||||||
@collection.bind('reset', @add_assets)
|
|
||||||
@collection.bind('add', @add_asset)
|
|
||||||
@collection.bind('remove', @remove_asset)
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
$(@el).html(@template()())
|
|
||||||
|
|
||||||
@create_dialog()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
template: ->
|
|
||||||
# please overide template
|
|
||||||
|
|
||||||
fetch_assets: ->
|
|
||||||
# please overide fetch_assets
|
|
||||||
|
|
||||||
build_uploader: (el, link) ->
|
|
||||||
# please overide build_uploader
|
|
||||||
|
|
||||||
create_dialog: ->
|
|
||||||
@dialog ||= $(@el).dialog
|
|
||||||
autoOpen: false
|
|
||||||
modal: true
|
|
||||||
zIndex: window.application_view.unique_dialog_zindex()
|
|
||||||
width: 650,
|
|
||||||
create: (event, ui) =>
|
|
||||||
$(@el).prev().find('.ui-dialog-title').html(@$('h2').html())
|
|
||||||
@$('h2').remove()
|
|
||||||
actions = @$('.dialog-actions').appendTo($(@el).parent()).addClass('ui-dialog-buttonpane ui-widget-content ui-helper-clearfix')
|
|
||||||
|
|
||||||
actions.find('#close-link').click (event) => @close(event)
|
|
||||||
|
|
||||||
input = actions.find('input[type=file]')
|
|
||||||
link = actions.find('#upload-link')
|
|
||||||
|
|
||||||
@build_uploader(input, link)
|
|
||||||
|
|
||||||
open: (event, ui, extra) =>
|
|
||||||
$(@el).dialog('overlayEl').bind 'click', => @close()
|
|
||||||
|
|
||||||
open: ->
|
|
||||||
$(@el).dialog('open')
|
|
||||||
|
|
||||||
close: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault() if event?
|
|
||||||
$(@el).dialog('overlayEl').unbind('click')
|
|
||||||
$(@el).dialog('close')
|
|
||||||
|
|
||||||
shake: ->
|
|
||||||
$(@el).parents('.ui-dialog').effect('shake', { times: 4 }, 100)
|
|
||||||
|
|
||||||
center: ->
|
|
||||||
$(@el).dialog('option', 'position', 'center')
|
|
||||||
|
|
||||||
add_assets: (collection) ->
|
|
||||||
collection.each (asset) =>
|
|
||||||
@add_asset(asset, true)
|
|
||||||
|
|
||||||
@_refresh()
|
|
||||||
|
|
||||||
add_asset: (asset, first) ->
|
|
||||||
# please overide add_asset (the 'first' param is to know if it comes from the first collection fetch)
|
|
||||||
|
|
||||||
remove_asset: (asset) ->
|
|
||||||
# please overide remove_asset
|
|
||||||
|
|
||||||
_move_to_last_asset: ->
|
|
||||||
limit = @$('ul.list li.clear').position()
|
|
||||||
@$('ul.list').animate(scrollTop: limit.top, 100) if limit?
|
|
||||||
|
|
||||||
_refresh: ->
|
|
||||||
if @collection.length == 0
|
|
||||||
@$('ul.list').hide() & @$('p.no-items').show()
|
|
||||||
else
|
|
||||||
@$('p.no-items').hide() & @$('ul.list').show()
|
|
||||||
@_on_refresh()
|
|
||||||
|
|
||||||
@center() if @dialog?
|
|
||||||
|
|
||||||
_on_refresh: ->
|
|
||||||
|
|
||||||
_reset: ->
|
|
||||||
# for nothing to do
|
|
@ -1,88 +0,0 @@
|
|||||||
Locomotive.Views.Shared ||= {}
|
|
||||||
Locomotive.Views.Shared.Fields ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Shared.Fields.FileView extends Backbone.View
|
|
||||||
|
|
||||||
tagName: 'span'
|
|
||||||
|
|
||||||
className: 'file'
|
|
||||||
|
|
||||||
states:
|
|
||||||
change: false
|
|
||||||
delete: false
|
|
||||||
|
|
||||||
events:
|
|
||||||
'click a.change': 'toggle_change'
|
|
||||||
'click a.delete': 'toggle_delete'
|
|
||||||
|
|
||||||
template: ->
|
|
||||||
ich["#{@options.name}_file_input"]
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
url = @model.get("#{@options.name}_url") || ''
|
|
||||||
data =
|
|
||||||
filename: url.split('/').pop()
|
|
||||||
url: url
|
|
||||||
|
|
||||||
$(@el).html(@template()(data))
|
|
||||||
|
|
||||||
# only in HTML 5
|
|
||||||
@$('input[type=file]').bind 'change', (event) =>
|
|
||||||
input = $(event.target)[0]
|
|
||||||
|
|
||||||
if input.files?
|
|
||||||
name = $(input).attr('name')
|
|
||||||
hash = {}
|
|
||||||
hash[name.replace("#{@model.paramRoot}[", '').replace(/]$/, '')] = input.files[0]
|
|
||||||
@model.set(hash)
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
refresh: ->
|
|
||||||
@$('input[type=file]').unbind 'change'
|
|
||||||
@states = { 'change': false, 'delete': false }
|
|
||||||
@render()
|
|
||||||
|
|
||||||
reset: ->
|
|
||||||
@model.set_attribute @options.name, null
|
|
||||||
@model.set_attribute "#{@options.name}_url", null
|
|
||||||
@refresh()
|
|
||||||
|
|
||||||
toggle_change: (event) ->
|
|
||||||
@_toggle event, 'change',
|
|
||||||
on_change: =>
|
|
||||||
@$('a:first').hide() & @$('input[type=file]').show() & @$('a.delete').hide()
|
|
||||||
on_cancel: =>
|
|
||||||
@$('a:first').show() & @$('input[type=file]').hide() & @$('a.delete').show()
|
|
||||||
|
|
||||||
toggle_delete: (event) ->
|
|
||||||
@_toggle event, 'delete',
|
|
||||||
on_change: =>
|
|
||||||
@$('a:first').addClass('deleted') & @$('a.change').hide()
|
|
||||||
@$('input[type=hidden].remove-flag').val('1')
|
|
||||||
@model.set_attribute("remove_#{@options.name}", true)
|
|
||||||
on_cancel: =>
|
|
||||||
@$('a:first').removeClass('deleted') & @$('a.change').show()
|
|
||||||
@$('input[type=hidden].remove-flag').val('0')
|
|
||||||
@model.set_attribute("remove_#{@options.name}", false)
|
|
||||||
|
|
||||||
_toggle: (event, state, options) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
button = $(event.target)
|
|
||||||
label = button.attr('data-alt-label')
|
|
||||||
|
|
||||||
unless @states[state]
|
|
||||||
options.on_change()
|
|
||||||
else
|
|
||||||
options.on_cancel()
|
|
||||||
|
|
||||||
button.attr('data-alt-label', button.html())
|
|
||||||
|
|
||||||
button.html(label)
|
|
||||||
|
|
||||||
@states[state] = !@states[state]
|
|
||||||
|
|
||||||
remove: ->
|
|
||||||
@$('input[type=file]').unbind 'change'
|
|
||||||
super
|
|
@ -1,125 +0,0 @@
|
|||||||
Locomotive.Views.Shared ||= {}
|
|
||||||
Locomotive.Views.Shared.Fields ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Shared.Fields.HasManyView extends Backbone.View
|
|
||||||
|
|
||||||
tagName: 'div'
|
|
||||||
|
|
||||||
className: 'list'
|
|
||||||
|
|
||||||
events:
|
|
||||||
'click p.actions a.add': 'open_new_entry_view'
|
|
||||||
'click ul span.actions a.edit': 'edit_entry'
|
|
||||||
'click ul span.actions a.remove': 'remove_entry'
|
|
||||||
|
|
||||||
template: ->
|
|
||||||
ich["#{@options.name}_list"]
|
|
||||||
|
|
||||||
entry_template: ->
|
|
||||||
ich["#{@options.name}_entry"]
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
_.bindAll(@, 'refresh_position_entries')
|
|
||||||
|
|
||||||
@collection = @model.get(@options.name)
|
|
||||||
|
|
||||||
@build_target_entry_view()
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
$(@el).html(@template()())
|
|
||||||
|
|
||||||
@insert_entries()
|
|
||||||
|
|
||||||
@make_entries_sortable()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
ui_enabled: ->
|
|
||||||
@template()?
|
|
||||||
|
|
||||||
insert_entries: ->
|
|
||||||
if @collection.length > 0
|
|
||||||
@collection.each (entry) => @insert_entry(entry)
|
|
||||||
else
|
|
||||||
@$('.empty').show()
|
|
||||||
|
|
||||||
insert_entry: (entry) ->
|
|
||||||
unless @collection.get(entry.get('_id'))?
|
|
||||||
@collection.add(entry)
|
|
||||||
|
|
||||||
@$('.empty').hide()
|
|
||||||
entry_html = $(@entry_template()(label: entry.get('_label')))
|
|
||||||
entry_html.data('data-entry-id', entry.id)
|
|
||||||
@$('> ul').append(entry_html)
|
|
||||||
|
|
||||||
make_entries_sortable: ->
|
|
||||||
@sortable_list = @$('> ul').sortable
|
|
||||||
handle: '.handle'
|
|
||||||
items: 'li'
|
|
||||||
axis: 'y'
|
|
||||||
update: @refresh_position_entries
|
|
||||||
|
|
||||||
refresh_position_entries: ->
|
|
||||||
@$('> ul > li').each (index, entry_html) =>
|
|
||||||
id = $(entry_html).data('data-entry-id')
|
|
||||||
entry = @collection.get(id)
|
|
||||||
entry.set_attribute "position_in_#{@options.inverse_of}", index
|
|
||||||
|
|
||||||
build_target_entry_view: ->
|
|
||||||
@target_entry_view = new Locomotive.Views.ContentEntries.PopupFormView
|
|
||||||
el: $("##{@options.name}-template-entry")
|
|
||||||
parent_view: @
|
|
||||||
model: @options.new_entry.clone() # by default, it does not matter
|
|
||||||
|
|
||||||
@target_entry_view.render()
|
|
||||||
|
|
||||||
edit_entry: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
entry = @get_entry_from_element($(event.target))
|
|
||||||
|
|
||||||
@target_entry_view.reset(entry)
|
|
||||||
@target_entry_view.open()
|
|
||||||
|
|
||||||
update_entry: (entry) ->
|
|
||||||
entry_html = $(_.detect @$('> ul > li'), (_entry_html) -> $(_entry_html).data('data-entry-id') == entry.id)
|
|
||||||
|
|
||||||
@collection.get(entry.id).set(entry.attributes) # sync
|
|
||||||
|
|
||||||
new_entry_html = $(@entry_template()(label: entry.get('_label')))
|
|
||||||
new_entry_html.data('data-entry-id', entry.id)
|
|
||||||
|
|
||||||
entry_html.replaceWith(new_entry_html)
|
|
||||||
|
|
||||||
insert_or_update_entry: (entry) ->
|
|
||||||
if @collection.get(entry.id)?
|
|
||||||
@update_entry(entry)
|
|
||||||
else
|
|
||||||
@insert_entry(entry)
|
|
||||||
|
|
||||||
remove_entry: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
if confirm($(event.target).attr('data-confirm'))
|
|
||||||
entry = @get_entry_from_element($(event.target))
|
|
||||||
entry.set _destroy: true
|
|
||||||
|
|
||||||
$(event.target).closest('li').remove()
|
|
||||||
@$('.empty').show() if @$('> ul > li').size() == 0
|
|
||||||
@refresh_position_entries()
|
|
||||||
|
|
||||||
open_new_entry_view: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
@target_entry_view.reset(@options.new_entry.clone())
|
|
||||||
@target_entry_view.open()
|
|
||||||
|
|
||||||
get_entry_from_element: (element) =>
|
|
||||||
entry_html = $(element).closest('li')
|
|
||||||
id = $(entry_html).data('data-entry-id')
|
|
||||||
@collection.get(id)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,131 +0,0 @@
|
|||||||
Locomotive.Views.Shared ||= {}
|
|
||||||
Locomotive.Views.Shared.Fields ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Shared.Fields.ManyToManyView extends Backbone.View
|
|
||||||
|
|
||||||
tagName: 'div'
|
|
||||||
|
|
||||||
className: 'list'
|
|
||||||
|
|
||||||
events:
|
|
||||||
'click .new-entry a.add': 'add_entry'
|
|
||||||
'keypress .new-entry select': 'add_entry'
|
|
||||||
'click ul span.actions a.remove': 'remove_entry'
|
|
||||||
|
|
||||||
template: ->
|
|
||||||
ich["#{@options.name}_list"]
|
|
||||||
|
|
||||||
entry_template: ->
|
|
||||||
ich["#{@options.name}_entry"]
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
_.bindAll(@, 'refresh_position_entries')
|
|
||||||
|
|
||||||
@collection = @model.get(@options.name)
|
|
||||||
@all_entries = @options.all_entries
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
$(@el).html(@template()())
|
|
||||||
|
|
||||||
@insert_entries()
|
|
||||||
|
|
||||||
@make_entries_sortable()
|
|
||||||
|
|
||||||
@refresh_select_field()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
ui_enabled: ->
|
|
||||||
@template()?
|
|
||||||
|
|
||||||
insert_entries: ->
|
|
||||||
if @collection.length > 0
|
|
||||||
@collection.each (entry) => @insert_entry(entry)
|
|
||||||
else
|
|
||||||
@$('.empty').show()
|
|
||||||
|
|
||||||
insert_entry: (entry) ->
|
|
||||||
unless @collection.get(entry.get('_id'))?
|
|
||||||
@collection.add(entry)
|
|
||||||
|
|
||||||
@$('.empty').hide()
|
|
||||||
entry_html = $(@entry_template()(label: entry.get('_label')))
|
|
||||||
entry_html.data('data-entry-id', entry.id)
|
|
||||||
@$('> ul').append(entry_html)
|
|
||||||
|
|
||||||
make_entries_sortable: ->
|
|
||||||
@sortable_list = @$('> ul').sortable
|
|
||||||
handle: '.handle'
|
|
||||||
items: 'li'
|
|
||||||
axis: 'y'
|
|
||||||
update: @refresh_position_entries
|
|
||||||
|
|
||||||
refresh_position_entries: ->
|
|
||||||
@$('> ul > li').each (index, entry_html) =>
|
|
||||||
id = $(entry_html).data('data-entry-id')
|
|
||||||
entry = @collection.get(id)
|
|
||||||
entry.set_attribute "__position", index
|
|
||||||
|
|
||||||
add_entry: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
entry_id = @$('.new-entry select').val()
|
|
||||||
entry = @get_entry_from_id(entry_id)
|
|
||||||
|
|
||||||
return unless entry?
|
|
||||||
|
|
||||||
@insert_entry(entry)
|
|
||||||
@refresh_select_field()
|
|
||||||
|
|
||||||
remove_entry: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
if confirm($(event.target).attr('data-confirm'))
|
|
||||||
entry = @get_entry_from_element($(event.target))
|
|
||||||
@collection.remove(entry)
|
|
||||||
|
|
||||||
$(event.target).closest('li').remove()
|
|
||||||
@$('.empty').show() if @$('> ul > li').size() == 0
|
|
||||||
|
|
||||||
@refresh_position_entries() & @refresh_select_field()
|
|
||||||
|
|
||||||
refresh_select_field: ->
|
|
||||||
@$('.new-entry select optgroup, .new-entry select option').remove()
|
|
||||||
|
|
||||||
_.each @all_entries, (entry_or_group) =>
|
|
||||||
if _.isArray(entry_or_group.entries)
|
|
||||||
group_html = $('<optgroup/>').attr('label', entry_or_group.name)
|
|
||||||
|
|
||||||
_.each entry_or_group.entries, (entry) =>
|
|
||||||
unless @collection.get(entry._id)?
|
|
||||||
option = new Option(entry._label, entry._id, false)
|
|
||||||
group_html.append(option)
|
|
||||||
|
|
||||||
@$('.new-entry select').append(group_html)
|
|
||||||
else
|
|
||||||
unless @collection.get(entry_or_group._id)?
|
|
||||||
option = new Option(entry_or_group._label, entry_or_group._id, false)
|
|
||||||
@$('.new-entry select').append(option)
|
|
||||||
|
|
||||||
get_entry_from_element: (element) ->
|
|
||||||
entry_html = $(element).closest('li')
|
|
||||||
id = $(entry_html).data('data-entry-id')
|
|
||||||
@collection.get(id)
|
|
||||||
|
|
||||||
get_entry_from_id: (id) ->
|
|
||||||
entry = null
|
|
||||||
|
|
||||||
_.each @all_entries, (entry_or_group) =>
|
|
||||||
if _.isArray(entry_or_group.entries)
|
|
||||||
entry ||= _.detect(entry_or_group.entries, (_entry) => _entry._id == id)
|
|
||||||
else
|
|
||||||
entry = entry_or_group if entry_or_group._id == id
|
|
||||||
|
|
||||||
if entry?
|
|
||||||
new Locomotive.Models.ContentEntry(entry)
|
|
||||||
else
|
|
||||||
null
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,131 +0,0 @@
|
|||||||
Locomotive.Views.Shared ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Shared.FormView extends Backbone.View
|
|
||||||
|
|
||||||
el: '#content'
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
# make title editable (if possible)
|
|
||||||
@make_title_editable()
|
|
||||||
|
|
||||||
@_hide_last_separator()
|
|
||||||
|
|
||||||
# make inputs foldable (if specified)
|
|
||||||
@make_inputs_foldable()
|
|
||||||
|
|
||||||
# allow users to save with CTRL+S or CMD+s
|
|
||||||
@enable_save_with_keys_combination()
|
|
||||||
|
|
||||||
# enable form notifications
|
|
||||||
@enable_form_notifications()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
save: (event) ->
|
|
||||||
# by default, follow the default behaviour
|
|
||||||
|
|
||||||
save_in_ajax: (event, options) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
form = $(event.target).trigger('ajax:beforeSend')
|
|
||||||
|
|
||||||
@clear_errors()
|
|
||||||
|
|
||||||
options ||= { headers: {}, on_success: null, on_error: null }
|
|
||||||
|
|
||||||
previous_attributes = _.clone @model.attributes
|
|
||||||
|
|
||||||
@model.save {},
|
|
||||||
headers: options.headers
|
|
||||||
silent: true # since we pass an empty hash above, no need to trigger the callbacks
|
|
||||||
success: (model, response, xhr) =>
|
|
||||||
form.trigger('ajax:complete')
|
|
||||||
|
|
||||||
model.attributes = previous_attributes
|
|
||||||
|
|
||||||
options.on_success(response, xhr) if options.on_success
|
|
||||||
|
|
||||||
error: (model, xhr) =>
|
|
||||||
form.trigger('ajax:complete')
|
|
||||||
|
|
||||||
errors = JSON.parse(xhr.responseText)
|
|
||||||
|
|
||||||
@show_errors errors
|
|
||||||
|
|
||||||
options.on_error() if options.on_error
|
|
||||||
|
|
||||||
make_title_editable: ->
|
|
||||||
title = @$('h2 a.editable')
|
|
||||||
|
|
||||||
if title.size() > 0
|
|
||||||
target = @$("##{title.attr('rel')}")
|
|
||||||
target.parent().hide()
|
|
||||||
|
|
||||||
title.click (event) =>
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
newValue = prompt(title.attr('title'), title.html());
|
|
||||||
if newValue && newValue != ''
|
|
||||||
title.html(newValue)
|
|
||||||
target.val(newValue).trigger('change')
|
|
||||||
|
|
||||||
make_inputs_foldable: ->
|
|
||||||
self = @
|
|
||||||
@$('.formtastic fieldset.foldable.folded ol').hide()
|
|
||||||
@$('.formtastic fieldset.foldable legend').click ->
|
|
||||||
parent = $(@).parent()
|
|
||||||
content = $(@).next()
|
|
||||||
|
|
||||||
if parent.hasClass 'folded'
|
|
||||||
parent.removeClass 'folded'
|
|
||||||
content.slideDown 100, -> self.after_inputs_fold(parent)
|
|
||||||
else
|
|
||||||
content.slideUp 100, -> parent.addClass('folded')
|
|
||||||
|
|
||||||
enable_save_with_keys_combination: ->
|
|
||||||
$.cmd 'S', (() => @$('form input[type=submit]').trigger('click')), [], ignoreCase: true
|
|
||||||
|
|
||||||
enable_form_notifications: ->
|
|
||||||
@$('form').formSubmitNotification()
|
|
||||||
|
|
||||||
after_inputs_fold: ->
|
|
||||||
# overide this method if necessary
|
|
||||||
|
|
||||||
clear_errors: ->
|
|
||||||
@$('.inline-errors').remove()
|
|
||||||
|
|
||||||
show_errors: (errors) ->
|
|
||||||
for attribute, message of errors
|
|
||||||
if _.isString(message[0])
|
|
||||||
html = $("<div class=\"inline-errors\"><p>#{message[0]}</p></div>")
|
|
||||||
@show_error attribute, message[0], html
|
|
||||||
else
|
|
||||||
@show_error attribute, message
|
|
||||||
|
|
||||||
show_error: (attribute, message, html) ->
|
|
||||||
input = @$("##{@model.paramRoot}_#{attribute}")
|
|
||||||
input = @$("##{@model.paramRoot}_#{attribute}_id") if input.size() == 0
|
|
||||||
|
|
||||||
return unless input.size() > 0
|
|
||||||
|
|
||||||
anchor = input.parent().find('.error-anchor')
|
|
||||||
anchor = input if anchor.size() == 0
|
|
||||||
anchor.after(html)
|
|
||||||
|
|
||||||
_enable_checkbox: (name, options) ->
|
|
||||||
options ||= {}
|
|
||||||
model_name = options.model_name || @model.paramRoot
|
|
||||||
|
|
||||||
@$("li##{model_name}_#{name}_input input[type=checkbox]").checkToggle
|
|
||||||
on_callback: =>
|
|
||||||
_.each options.features, (exp) -> @$("li##{model_name}_#{exp}_input").hide()
|
|
||||||
options.on_callback() if options.on_callback?
|
|
||||||
@_hide_last_separator()
|
|
||||||
off_callback: =>
|
|
||||||
_.each options.features, (exp) -> @$("li##{model_name}_#{exp}_input").show()
|
|
||||||
options.off_callback() if options.off_callback?
|
|
||||||
@_hide_last_separator()
|
|
||||||
|
|
||||||
_hide_last_separator: ->
|
|
||||||
_.each @$('fieldset'), (fieldset) =>
|
|
||||||
$(fieldset).find('li.last').removeClass('last')
|
|
||||||
$(_.last($(fieldset).find('li.input:visible'))).addClass('last')
|
|
@ -1,22 +0,0 @@
|
|||||||
Locomotive.Views.Shared ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Shared.ListItemView extends Backbone.View
|
|
||||||
|
|
||||||
tagName: 'li'
|
|
||||||
|
|
||||||
events:
|
|
||||||
'click a.remove': 'remove_item'
|
|
||||||
|
|
||||||
template: ->
|
|
||||||
# please overide template
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
$(@el).html(@template()(@model.toJSON()))
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
remove_item: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
if confirm $(event.target).attr('data-confirm')
|
|
||||||
@model.destroy()
|
|
@ -1,53 +0,0 @@
|
|||||||
Locomotive.Views.Shared ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Shared.ListView extends Backbone.View
|
|
||||||
|
|
||||||
tagName: 'div'
|
|
||||||
|
|
||||||
_item_views = []
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
_.bindAll(@, 'insert_item', 'remove_item')
|
|
||||||
@collection.bind('add', @insert_item)
|
|
||||||
@collection.bind('remove', @remove_item)
|
|
||||||
|
|
||||||
template: ->
|
|
||||||
# please overide template
|
|
||||||
|
|
||||||
item_view_class: ->
|
|
||||||
# please overide item_view_class
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
$(@el).html(@template()())
|
|
||||||
|
|
||||||
@render_items()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
render_items: ->
|
|
||||||
if @collection.length == 0
|
|
||||||
@$('.no-items').show()
|
|
||||||
else
|
|
||||||
@collection.each (item) =>
|
|
||||||
@insert_item(item)
|
|
||||||
|
|
||||||
insert_item: (item) ->
|
|
||||||
klass = @item_view_class()
|
|
||||||
view = new klass model: item, parent_view: @
|
|
||||||
|
|
||||||
(@_item_views ||= []).push(view)
|
|
||||||
|
|
||||||
@$('.no-items').hide()
|
|
||||||
@$('ul').append(view.render().el)
|
|
||||||
|
|
||||||
remove_item: (item) ->
|
|
||||||
@$('.no-items').show() if @collection.length == 0
|
|
||||||
view = _.find @_item_views, (tmp) -> tmp.model == item
|
|
||||||
view.remove() if view?
|
|
||||||
|
|
||||||
remove: ->
|
|
||||||
_.each @_item_views, (view) => view.remove()
|
|
||||||
super
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
|||||||
Locomotive.Views.Sites ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Sites.DomainEntryView extends Backbone.View
|
|
||||||
|
|
||||||
tagName: 'li'
|
|
||||||
|
|
||||||
className: 'domain'
|
|
||||||
|
|
||||||
events:
|
|
||||||
'change input[type=text]' : 'change'
|
|
||||||
'click a.remove': 'remove'
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
$(@el).html(ich.domain_entry(@model.toJSON()))
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
change: (event) ->
|
|
||||||
value = $(event.target).val()
|
|
||||||
@options.parent_view.change_entry(@model, value)
|
|
||||||
|
|
||||||
remove: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
@$('input[type=text]').editableField('destroy')
|
|
||||||
@options.parent_view.remove_entry(@model)
|
|
||||||
super()
|
|
@ -1,84 +0,0 @@
|
|||||||
Locomotive.Views.Sites ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Sites.DomainsView extends Backbone.View
|
|
||||||
|
|
||||||
tagName: 'div'
|
|
||||||
|
|
||||||
className: 'list'
|
|
||||||
|
|
||||||
_entry_views = []
|
|
||||||
|
|
||||||
events:
|
|
||||||
'click .new-entry a.add': 'add_entry'
|
|
||||||
'keypress .new-entry input[type=text]': 'add_on_entry_from_enter'
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
$(@el).html(ich.domains_list(@model.toJSON()))
|
|
||||||
|
|
||||||
@render_entries()
|
|
||||||
|
|
||||||
@enable_ui_effects()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
add_entry: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
input = @$('.new-entry input[name=domain]')
|
|
||||||
|
|
||||||
if input.val() != ''
|
|
||||||
domain = new Locomotive.Models.Domain name: input.val()
|
|
||||||
|
|
||||||
@model.get('domains').push(domain)
|
|
||||||
|
|
||||||
@_insert_entry(domain)
|
|
||||||
|
|
||||||
@$('ul li.domain:last input[type=text]').editableField()
|
|
||||||
@$('.empty').hide()
|
|
||||||
|
|
||||||
input.val('') # reset for further entries
|
|
||||||
|
|
||||||
add_on_entry_from_enter: (event) ->
|
|
||||||
return if event.keyCode != 13
|
|
||||||
@add_entry(event)
|
|
||||||
|
|
||||||
change_entry: (domain, value) ->
|
|
||||||
domain.set name: value
|
|
||||||
|
|
||||||
remove_entry: (domain) ->
|
|
||||||
list = _.reject @model.get('domains'), (_domain) => _domain == domain
|
|
||||||
@model.set domains: list
|
|
||||||
@$('.empty').show() if @model.get('domains').length == 0
|
|
||||||
|
|
||||||
render_entries: ->
|
|
||||||
if @model.get('domains').length == 0
|
|
||||||
@$('.empty').show()
|
|
||||||
else
|
|
||||||
_.each @model.get('domains'), (domain) =>
|
|
||||||
@_insert_entry(domain)
|
|
||||||
|
|
||||||
@show_errors()
|
|
||||||
|
|
||||||
show_errors: ->
|
|
||||||
_.each @options.errors.domain || [], (message) => @show_error(message)
|
|
||||||
|
|
||||||
show_error: (message) ->
|
|
||||||
_.each (@_entry_views || []), (view) ->
|
|
||||||
if new RegExp("^#{view.model.get('name')}").test message
|
|
||||||
html = $('<span></span>').addClass('inline-errors').html(message)
|
|
||||||
view.$('input[type=text].path').after(html)
|
|
||||||
|
|
||||||
enable_ui_effects: ->
|
|
||||||
@$('.domain input[type=text]').editableField()
|
|
||||||
|
|
||||||
_insert_entry: (domain) ->
|
|
||||||
view = new Locomotive.Views.Sites.DomainEntryView model: domain, parent_view: @
|
|
||||||
|
|
||||||
(@_entry_views ||= []).push(view)
|
|
||||||
|
|
||||||
@$('ul').append(view.render().el)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
|||||||
Locomotive.Views.Sites ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Sites.MembershipEntryView extends Backbone.View
|
|
||||||
|
|
||||||
className: 'entry'
|
|
||||||
|
|
||||||
events:
|
|
||||||
'change select' : 'change'
|
|
||||||
'click a.remove': 'remove'
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
data = @model.toJSON()
|
|
||||||
data.index = @options.index
|
|
||||||
|
|
||||||
$(@el).html(ich.membership_entry(data))
|
|
||||||
|
|
||||||
$(@el).attr('data-role', @model.get('role'))
|
|
||||||
|
|
||||||
@$('select').val(@model.get('role'))
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
change: (event) ->
|
|
||||||
value = $(event.target).val()
|
|
||||||
@options.parent_view.change_entry(@model, value)
|
|
||||||
|
|
||||||
remove: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
@$('select').editableField('destroy')
|
|
||||||
@options.parent_view.remove_entry(@model)
|
|
||||||
super()
|
|
@ -1,41 +0,0 @@
|
|||||||
Locomotive.Views.Sites ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Sites.MembershipsView extends Backbone.View
|
|
||||||
|
|
||||||
tagName: 'div'
|
|
||||||
|
|
||||||
className: 'list'
|
|
||||||
|
|
||||||
_entry_views = []
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
@render_entries()
|
|
||||||
|
|
||||||
@enable_ui_effects()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
change_entry: (membership, value) ->
|
|
||||||
membership.set role: value
|
|
||||||
|
|
||||||
remove_entry: (membership) ->
|
|
||||||
membership.set _destroy: true
|
|
||||||
|
|
||||||
render_entries: ->
|
|
||||||
@model.get('memberships').each (membership, index) =>
|
|
||||||
@_insert_entry(membership, index)
|
|
||||||
|
|
||||||
enable_ui_effects: ->
|
|
||||||
@$('.entry select').editableField()
|
|
||||||
|
|
||||||
_insert_entry: (membership, index) ->
|
|
||||||
view = new Locomotive.Views.Sites.MembershipEntryView model: membership, parent_view: @, index: index
|
|
||||||
|
|
||||||
(@_entry_views ||= []).push(view)
|
|
||||||
|
|
||||||
$(@el).append(view.render().el)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
|||||||
#= require ../shared/form_view
|
|
||||||
#= require ../sites/domains_view
|
|
||||||
|
|
||||||
Locomotive.Views.Sites ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Sites.NewView extends Locomotive.Views.Shared.FormView
|
|
||||||
|
|
||||||
el: '#content'
|
|
||||||
|
|
||||||
events:
|
|
||||||
'submit': 'save'
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
@model = new Locomotive.Models.Site()
|
|
||||||
|
|
||||||
Backbone.ModelBinding.bind @
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
super()
|
|
||||||
|
|
||||||
@render_domains()
|
|
||||||
|
|
||||||
render_domains: ->
|
|
||||||
@domains_view = new Locomotive.Views.Sites.DomainsView model: @model, errors: @options.errors
|
|
||||||
|
|
||||||
@$('#site_domains_input label').after(@domains_view.render().el)
|
|
||||||
|
|
||||||
save: (event) ->
|
|
||||||
@save_in_ajax event,
|
|
||||||
on_success: (response, xhr) ->
|
|
||||||
window.location.href = xhr.getResponseHeader('location')
|
|
||||||
|
|
||||||
show_error: (attribute, message, html) ->
|
|
||||||
if attribute == 'domains'
|
|
||||||
@domains_view.show_error(message)
|
|
||||||
else
|
|
||||||
super
|
|
||||||
|
|
||||||
remove: ->
|
|
||||||
@domains_view.remove()
|
|
||||||
super
|
|
||||||
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
|||||||
#= require ../shared/form_view
|
|
||||||
|
|
||||||
Locomotive.Views.Snippets ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Snippets.FormView extends Locomotive.Views.Shared.FormView
|
|
||||||
|
|
||||||
el: '#content'
|
|
||||||
|
|
||||||
events:
|
|
||||||
'click a#image-picker-link': 'open_image_picker'
|
|
||||||
'submit': 'save'
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
_.bindAll(@, 'insert_image')
|
|
||||||
|
|
||||||
@model = new Locomotive.Models.Snippet(@options.snippet)
|
|
||||||
|
|
||||||
@image_picker_view = new Locomotive.Views.ThemeAssets.ImagePickerView
|
|
||||||
collection: new Locomotive.Models.ThemeAssetsCollection()
|
|
||||||
on_select: @insert_image
|
|
||||||
|
|
||||||
@image_picker_view.render()
|
|
||||||
|
|
||||||
Backbone.ModelBinding.bind @
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
super()
|
|
||||||
|
|
||||||
# slugify the slug field from name
|
|
||||||
@slugify_name()
|
|
||||||
|
|
||||||
# liquid code textarea
|
|
||||||
@enable_liquid_editing()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
slugify_name: ->
|
|
||||||
@$('#snippet_name').slugify(target: @$('#snippet_slug'))
|
|
||||||
|
|
||||||
open_image_picker: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
@image_picker_view.editor = @editor
|
|
||||||
@image_picker_view.fetch_assets()
|
|
||||||
|
|
||||||
insert_image: (path) ->
|
|
||||||
text = "{{ '#{path}' | theme_image_url }}"
|
|
||||||
@editor.replaceSelection(text)
|
|
||||||
@image_picker_view.close()
|
|
||||||
|
|
||||||
enable_liquid_editing: ->
|
|
||||||
input = @$('#snippet_template')
|
|
||||||
@editor = CodeMirror.fromTextArea input.get()[0],
|
|
||||||
mode: 'liquid'
|
|
||||||
autoMatchParens: false
|
|
||||||
lineNumbers: false
|
|
||||||
passDelay: 50
|
|
||||||
tabMode: 'shift'
|
|
||||||
theme: 'default medium'
|
|
||||||
onChange: (editor) => @model.set(template: editor.getValue())
|
|
||||||
|
|
||||||
after_inputs_fold: ->
|
|
||||||
@editor.refresh()
|
|
@ -1,6 +0,0 @@
|
|||||||
Locomotive.Views.Snippets ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Snippets.EditView extends Locomotive.Views.Snippets.FormView
|
|
||||||
|
|
||||||
save: (event) ->
|
|
||||||
@save_in_ajax event
|
|
@ -1,8 +0,0 @@
|
|||||||
#= require ../shared/list_item_view
|
|
||||||
|
|
||||||
Locomotive.Views.Snippets ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Snippets.ListItemView extends Locomotive.Views.Shared.ListItemView
|
|
||||||
|
|
||||||
template: ->
|
|
||||||
ich.snippet_item
|
|
@ -1,17 +0,0 @@
|
|||||||
#= require ../shared/list_view
|
|
||||||
|
|
||||||
Locomotive.Views.Snippets ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Snippets.ListView extends Locomotive.Views.Shared.ListView
|
|
||||||
|
|
||||||
className: 'box'
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
@collection = new Locomotive.Models.SnippetsCollection(@options.collection)
|
|
||||||
super
|
|
||||||
|
|
||||||
template: ->
|
|
||||||
ich.snippets_list
|
|
||||||
|
|
||||||
item_view_class: ->
|
|
||||||
Locomotive.Views.Snippets.ListItemView
|
|
@ -1,8 +0,0 @@
|
|||||||
Locomotive.Views.Snippets ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.Snippets.NewView extends Locomotive.Views.Snippets.FormView
|
|
||||||
|
|
||||||
save: (event) ->
|
|
||||||
@save_in_ajax event,
|
|
||||||
on_success: (response, xhr) ->
|
|
||||||
window.location.href = xhr.getResponseHeader('location')
|
|
@ -1,104 +0,0 @@
|
|||||||
#= require ../shared/form_view
|
|
||||||
|
|
||||||
Locomotive.Views.ThemeAssets ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.ThemeAssets.FormView extends Locomotive.Views.Shared.FormView
|
|
||||||
|
|
||||||
el: '#content'
|
|
||||||
|
|
||||||
events:
|
|
||||||
'click a#image-picker-link': 'open_image_picker'
|
|
||||||
'submit': 'save'
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
_.bindAll(@, 'insert_image')
|
|
||||||
|
|
||||||
@model = new Locomotive.Models.ThemeAsset(@options.theme_asset)
|
|
||||||
|
|
||||||
@image_picker_view = new Locomotive.Views.ThemeAssets.ImagePickerView on_select: @insert_image
|
|
||||||
|
|
||||||
@image_picker_view.render()
|
|
||||||
|
|
||||||
Backbone.ModelBinding.bind @
|
|
||||||
|
|
||||||
render: ->
|
|
||||||
super()
|
|
||||||
|
|
||||||
@enable_toggle_between_file_and_text()
|
|
||||||
|
|
||||||
@enable_source_editing()
|
|
||||||
|
|
||||||
@bind_source_mode()
|
|
||||||
|
|
||||||
@enable_source_file()
|
|
||||||
|
|
||||||
return @
|
|
||||||
|
|
||||||
enable_toggle_between_file_and_text: ->
|
|
||||||
@$('div.hidden').hide()
|
|
||||||
|
|
||||||
@model.set(performing_plain_text: @$('#theme_asset_performing_plain_text').val())
|
|
||||||
|
|
||||||
@$('.selector > a.alt').click (event) =>
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
|
|
||||||
if @$('#file-selector').is(':hidden')
|
|
||||||
@$('#text-selector').slideUp 'normal', =>
|
|
||||||
@$('#file-selector').slideDown()
|
|
||||||
@model.set(performing_plain_text: false)
|
|
||||||
@$('input#theme_asset_performing_plain_text').val(false)
|
|
||||||
else
|
|
||||||
@$('#file-selector').slideUp 'normal', =>
|
|
||||||
@$('#text-selector').slideDown 'normal', => @editor.refresh()
|
|
||||||
@model.set(performing_plain_text: true)
|
|
||||||
@$('#theme_asset_performing_plain_text').val(true)
|
|
||||||
|
|
||||||
enable_source_file: ->
|
|
||||||
# only in HTML 5
|
|
||||||
@$('.formtastic #theme_asset_source').bind 'change', (event) =>
|
|
||||||
input = $(event.target)[0]
|
|
||||||
if input.files?
|
|
||||||
@model.set(source: input.files[0])
|
|
||||||
|
|
||||||
show_error: (attribute, message, html) ->
|
|
||||||
switch attribute
|
|
||||||
when 'source'
|
|
||||||
@$(if @model.get('performing_plain_text')
|
|
||||||
'#theme_asset_plain_text_input .CodeMirror'
|
|
||||||
else
|
|
||||||
'#theme_asset_source').after(html)
|
|
||||||
else super
|
|
||||||
|
|
||||||
open_image_picker: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
@image_picker_view.editor = @editor
|
|
||||||
@image_picker_view.fetch_assets()
|
|
||||||
|
|
||||||
insert_image: (path) ->
|
|
||||||
text = "'#{path}'"
|
|
||||||
@editor.replaceSelection(text)
|
|
||||||
@image_picker_view.close()
|
|
||||||
|
|
||||||
source_mode: ->
|
|
||||||
if @model.get('plain_text_type') == 'javascript' then 'javascript' else 'css'
|
|
||||||
|
|
||||||
enable_source_editing: ->
|
|
||||||
input = @$('#theme_asset_plain_text')
|
|
||||||
|
|
||||||
return if input.size() == 0
|
|
||||||
|
|
||||||
@editor = CodeMirror.fromTextArea input.get()[0],
|
|
||||||
mode: @source_mode()
|
|
||||||
autoMatchParens: false
|
|
||||||
lineNumbers: false
|
|
||||||
passDelay: 50
|
|
||||||
tabMode: 'shift'
|
|
||||||
theme: 'default'
|
|
||||||
onChange: (editor) => @model.set(plain_text: editor.getValue())
|
|
||||||
|
|
||||||
bind_source_mode: ->
|
|
||||||
@$('#theme_asset_plain_text_type').bind 'change', (event) =>
|
|
||||||
@editor.setOption 'mode', @source_mode()
|
|
||||||
|
|
||||||
after_inputs_fold: ->
|
|
||||||
@editor.refresh() if @editor?
|
|
@ -1,16 +0,0 @@
|
|||||||
Locomotive.Views.ThemeAssets ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.ThemeAssets.EditView extends Locomotive.Views.ThemeAssets.FormView
|
|
||||||
|
|
||||||
save: (event) ->
|
|
||||||
@save_in_ajax event, on_success: (response, xhr) =>
|
|
||||||
window.response = response
|
|
||||||
window.xhr = xhr
|
|
||||||
help = @$('.inner > p.help')
|
|
||||||
help.find('b').html(response.dimensions)
|
|
||||||
help.find('a').html(response.url).attr('href', response.url)
|
|
||||||
|
|
||||||
window.editor = @editor
|
|
||||||
|
|
||||||
if response.plain_text?
|
|
||||||
@editor.setValue response.plain_text
|
|
@ -1,48 +0,0 @@
|
|||||||
#= require ../shared/asset_picker_view
|
|
||||||
|
|
||||||
Locomotive.Views.ThemeAssets ||= {}
|
|
||||||
|
|
||||||
class Locomotive.Views.ThemeAssets.ImagePickerView extends Locomotive.Views.Shared.AssetPickerView
|
|
||||||
|
|
||||||
events:
|
|
||||||
'click ul.list a': 'select_asset'
|
|
||||||
|
|
||||||
initialize: ->
|
|
||||||
@collection ||= new Locomotive.Models.ThemeAssetsCollection()
|
|
||||||
super
|
|
||||||
|
|
||||||
template: ->
|
|
||||||
ich.theme_image_picker
|
|
||||||
|
|
||||||
fetch_assets: ->
|
|
||||||
@_reset()
|
|
||||||
@collection.fetch
|
|
||||||
data:
|
|
||||||
content_type: 'image'
|
|
||||||
success: () =>
|
|
||||||
@open()
|
|
||||||
|
|
||||||
build_uploader: (el, link) ->
|
|
||||||
link.bind 'click', (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
el.click()
|
|
||||||
|
|
||||||
el.bind 'change', (event) =>
|
|
||||||
_.each event.target.files, (file) =>
|
|
||||||
asset = new Locomotive.Models.ThemeAsset(source: file)
|
|
||||||
asset.save {},
|
|
||||||
headers: { 'X-Flash': true }
|
|
||||||
success: (model) => @collection.add(model)
|
|
||||||
error: => @shake()
|
|
||||||
|
|
||||||
select_asset: (event) ->
|
|
||||||
event.stopPropagation() & event.preventDefault()
|
|
||||||
if @options.on_select
|
|
||||||
@options.on_select($(event.target).html())
|
|
||||||
|
|
||||||
add_asset: (asset) ->
|
|
||||||
@$('ul.list').append(ich.theme_asset(asset.toJSON()))
|
|
||||||
@_refresh()
|
|
||||||
|
|
||||||
_reset: ->
|
|
||||||
@$('ul.list').empty()
|
|