overlay_me 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/CHANGELOG.md +37 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +70 -0
- data/LICENSE +21 -0
- data/README.md +136 -0
- data/Rakefile +115 -0
- data/addons/layout_resizer.js +51 -0
- data/demo_page.html +33 -0
- data/javascripts/addons/layout_resizer.js.coffee +42 -0
- data/javascripts/basics.js.coffee +25 -0
- data/javascripts/draggable.js.coffee +51 -0
- data/javascripts/init.js.coffee +24 -0
- data/javascripts/lib/backbone.js +1154 -0
- data/javascripts/lib/html5slider.js +268 -0
- data/javascripts/lib/jquery.js +9404 -0
- data/javascripts/lib/underscore.js +807 -0
- data/javascripts/menu.js.coffee +29 -0
- data/javascripts/menu_item.js.coffee +42 -0
- data/javascripts/overlay_me.js.coffee +3 -0
- data/javascripts/overlays/content_div_mngmt.js.coffee +91 -0
- data/javascripts/overlays/draggable_image.js.coffee +34 -0
- data/javascripts/overlays/dynamic_images_mngmt.js.coffee +48 -0
- data/javascripts/overlays/image.js.coffee +100 -0
- data/javascripts/overlays/images_mngt_div.js.coffee +103 -0
- data/javascripts/overlays/init.js.coffee +13 -0
- data/javascripts/overlays.js.coffee +49 -0
- data/lib/overlay_me/version.rb +7 -0
- data/lib/overlay_me.rb +22 -0
- data/overlay_me.css +232 -0
- data/overlay_me.gemspec +23 -0
- data/overlay_me.js +12565 -0
- data/stylesheets/overlay_me.css.scss +213 -0
- data/vendor/assets/javascripts/overlay_me/addons/layout_resizer.js +51 -0
- data/vendor/assets/javascripts/overlay_me/overlay_me.min.js +733 -0
- metadata +200 -0
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
### Coming up
|
2
|
+
..?
|
3
|
+
|
4
|
+
### 0.12.0 - [Diff](https://github.com/frontfoot/overlay_me/compare/v0.11.1...v0.12.0)
|
5
|
+
- changed the file structure, gem now includes only the minified javascript
|
6
|
+
- minifying process became a bit cleaner
|
7
|
+
- add RakeTask :watch to compile on the flow
|
8
|
+
|
9
|
+
### 0.11.1 - [Diff](https://github.com/frontfoot/overlay_me/compare/v0.11.0...v0.11.1)
|
10
|
+
- fix dynamic images duplication bug
|
11
|
+
- fix hidden menu and content on top retention bug
|
12
|
+
- update header of minified file to include sub-projects
|
13
|
+
|
14
|
+
### 0.11.0 - [Diff](https://github.com/frontfoot/overlay_me/compare/v0.10.1...v0.11.0)
|
15
|
+
- moving the original page content in a controlled sub div
|
16
|
+
|
17
|
+
### 0.10.1 - [Diff](https://github.com/frontfoot/overlay_me/compare/v0.10.0...v0.10.1)
|
18
|
+
- improved usability: image cells clickable, display mouseovers
|
19
|
+
- some design
|
20
|
+
|
21
|
+
### 0.10.0 - [Diff](https://github.com/frontfoot/overlay_me/compare/v0.9.2...v0.10.0)
|
22
|
+
- js + css all in one UNIQUE minified overlay_me.min.js file
|
23
|
+
- a bit of styling
|
24
|
+
- fix style and events for Firefox
|
25
|
+
- load an image by default at first use
|
26
|
+
|
27
|
+
### 0.9.2 - [Diff](https://github.com/frontfoot/overlay_me/compare/v0.9.1...v0.9.2)
|
28
|
+
- bookmarklet access
|
29
|
+
- load only once
|
30
|
+
- minified assets available
|
31
|
+
|
32
|
+
### 0.9.1 - [Diff](https://github.com/frontfoot/overlay_me/compare/v0.9...v0.9.1)
|
33
|
+
- added the global image dynamic add/remove/storing
|
34
|
+
- rename the project to overlay_me
|
35
|
+
|
36
|
+
### 0.9
|
37
|
+
- first commited/shared/published version, prior to that, the script was local to some projects
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
overlay_me (0.12.0)
|
5
|
+
coffee-script
|
6
|
+
compass
|
7
|
+
haml
|
8
|
+
json
|
9
|
+
rack
|
10
|
+
rake
|
11
|
+
sprockets-sass
|
12
|
+
|
13
|
+
GEM
|
14
|
+
remote: http://www.rubygems.org/
|
15
|
+
specs:
|
16
|
+
POpen4 (0.1.4)
|
17
|
+
Platform (>= 0.4.0)
|
18
|
+
open4
|
19
|
+
Platform (0.4.0)
|
20
|
+
chunky_png (1.2.5)
|
21
|
+
coffee-script (2.2.0)
|
22
|
+
coffee-script-source
|
23
|
+
execjs
|
24
|
+
coffee-script-source (1.3.1)
|
25
|
+
compass (0.12.1)
|
26
|
+
chunky_png (~> 1.2)
|
27
|
+
fssm (>= 0.2.7)
|
28
|
+
sass (~> 3.1)
|
29
|
+
execjs (1.3.1)
|
30
|
+
multi_json (~> 1.0)
|
31
|
+
ffi (1.0.11)
|
32
|
+
fssm (0.2.9)
|
33
|
+
haml (3.1.4)
|
34
|
+
hike (1.2.1)
|
35
|
+
jsmin (1.0.1)
|
36
|
+
json (1.7.0)
|
37
|
+
listen (0.4.2)
|
38
|
+
rb-fchange (~> 0.0.5)
|
39
|
+
rb-fsevent (~> 0.9.1)
|
40
|
+
rb-inotify (~> 0.8.8)
|
41
|
+
multi_json (1.3.4)
|
42
|
+
open4 (1.3.0)
|
43
|
+
rack (1.4.1)
|
44
|
+
rake (0.9.2.2)
|
45
|
+
rb-fchange (0.0.5)
|
46
|
+
ffi
|
47
|
+
rb-fsevent (0.9.1)
|
48
|
+
rb-inotify (0.8.8)
|
49
|
+
ffi (>= 0.5.0)
|
50
|
+
sass (3.1.15)
|
51
|
+
sprockets (2.4.1)
|
52
|
+
hike (~> 1.2)
|
53
|
+
multi_json (~> 1.0)
|
54
|
+
rack (~> 1.0)
|
55
|
+
tilt (~> 1.1, != 1.3.0)
|
56
|
+
sprockets-sass (0.8.0)
|
57
|
+
sprockets (~> 2.0)
|
58
|
+
tilt (~> 1.1)
|
59
|
+
tilt (1.3.3)
|
60
|
+
yui-compressor (0.9.6)
|
61
|
+
POpen4 (>= 0.1.4)
|
62
|
+
|
63
|
+
PLATFORMS
|
64
|
+
ruby
|
65
|
+
|
66
|
+
DEPENDENCIES
|
67
|
+
jsmin
|
68
|
+
listen
|
69
|
+
overlay_me!
|
70
|
+
yui-compressor
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2012 Joseph Boiteau, FrontFoot Media Solutions
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
data/README.md
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
## Use it now!
|
2
|
+
|
3
|
+
Store the bookmarklet from [this page](http://dev.frontfoot.com.au/overlay_me/demo_page.html) and load OverlayMe on top of any web page!
|
4
|
+
|
5
|
+
If you just want download the compiled, minified archive: [overlay_me.min.js](https://raw.github.com/frontfoot/overlay_me/master/vendor/assets/javascripts/overlay_me/overlay_me.min.js) (CSS embedded!)
|
6
|
+
|
7
|
+
note: overlay_me.js and overlay_me.css are both generated unminified archives, original source code is in javascripts/ and stylesheets/ folders
|
8
|
+
|
9
|
+
## Screenshot
|
10
|
+
|
11
|
+
![Screenshot](http://github.com/frontfoot/overlay_me/raw/master/screenshot_frontfoot_website.jpg)
|
12
|
+
|
13
|
+
|
14
|
+
## Features
|
15
|
+
|
16
|
+
- overlay images over a web page saving their position/opacity locally (using HTML5 localStorage)
|
17
|
+
- images can be loaded from a project local directory (see Project base use)
|
18
|
+
- an image can be added on the fly with its absolute url
|
19
|
+
- bring back your HTML on top of the overlays
|
20
|
+
- control the opacity of the page content
|
21
|
+
- keep on playing with the CSS while having with a visual overlay
|
22
|
+
- addon layout_resizer, to switch between pre-recorded devices format
|
23
|
+
|
24
|
+
|
25
|
+
## Why
|
26
|
+
|
27
|
+
The purpose of this tool is to help the developer to meet designers requirements by overlaying images on the page.
|
28
|
+
|
29
|
+
We were struggling to see the gap between designers photoshop files and our HTML/CSS implementation, the best way to figure it out was to load their rendered work in the page and play with opacity to see the differences, that's what this tool facilitate.
|
30
|
+
|
31
|
+
|
32
|
+
## Todo
|
33
|
+
|
34
|
+
- allow local image uploading (a temporary hosting on amazon s3 ?), [makiapp.com](http://makiapp.com/) does it!
|
35
|
+
- overlays
|
36
|
+
- make a cycling system, by click or keypress, to iterate through overlays one by one
|
37
|
+
- overlay images sub-sets (sub-directories) should appear as nested blocks
|
38
|
+
- make another version of the toolbar fixed on top of the screen
|
39
|
+
|
40
|
+
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
- You can use this tool on the go, over any site, via [the bookmarket](http://dev.frontfoot.com.au/overlay_me/demo_page.html)
|
44
|
+
|
45
|
+
- If you want to include it in a non-Ruby project, use the precompiled/minified script ([overlay_me.min.js](https://raw.github.com/frontfoot/overlay_me/master/vendor/assets/javascripts/overlay_me/overlay_me.min.js))
|
46
|
+
|
47
|
+
- And if you're using Ruby, install the gem :)
|
48
|
+
|
49
|
+
if using bundler:
|
50
|
+
|
51
|
+
# Gemfile
|
52
|
+
|
53
|
+
gem "overlay_me", :git => "git://github.com/frontfoot/overlay_me.git"
|
54
|
+
|
55
|
+
|
56
|
+
### Load the script at the end of your body tag
|
57
|
+
|
58
|
+
under a rails app:
|
59
|
+
|
60
|
+
= javascript_include_tag 'overlay_me/overlay_me.min.js'
|
61
|
+
|
62
|
+
or in a simpler project, (we are using [middleman](http://middlemanapp.com/))
|
63
|
+
|
64
|
+
%script{ :src => '/javascripts/overlay_me/overlay_me.min.js', :type => 'text/javascript', :charset => 'utf-8' }
|
65
|
+
|
66
|
+
|
67
|
+
### Extended use - share overlay images to your work team, keep images sets per project
|
68
|
+
|
69
|
+
By default the script will try to load the list of images from /overlay_images
|
70
|
+
|
71
|
+
List your images in JSON, simply:
|
72
|
+
|
73
|
+
[
|
74
|
+
"/images/overlays/Home_1024r_1.png",
|
75
|
+
"/images/overlays/Home_1100r_1.jpg",
|
76
|
+
"/images/overlays/Home_1300r_1.png",
|
77
|
+
"/images/overlays/Home_320r_1.jpg",
|
78
|
+
"/images/overlays/Home_480r_1.png",
|
79
|
+
"/images/overlays/Home_720r_1.png",
|
80
|
+
"/images/overlays/Home_768r_1.png"
|
81
|
+
]
|
82
|
+
|
83
|
+
If you're using the gem, I made a simple Rack app to build that JSON list for you
|
84
|
+
|
85
|
+
Here is how to initialise the path and the feed route
|
86
|
+
|
87
|
+
using rails
|
88
|
+
|
89
|
+
#config/initializers/overlay_me.rb
|
90
|
+
|
91
|
+
if defined?(OverlayMe)
|
92
|
+
OverlayMe.root_dir = Dir[Rails.root.join("public")].to_s
|
93
|
+
OverlayMe.overlays_directory = 'images/overlays'
|
94
|
+
end
|
95
|
+
|
96
|
+
#config/routes.rb
|
97
|
+
|
98
|
+
if ["development", "test"].include? Rails.env
|
99
|
+
match "/overlay_images" => OverlayMe::App
|
100
|
+
end
|
101
|
+
|
102
|
+
using middleman
|
103
|
+
|
104
|
+
#config.rb:
|
105
|
+
|
106
|
+
OverlayMe.root_dir = Dir.pwd + '/source'
|
107
|
+
OverlayMe.overlays_directory = 'images/overlays'
|
108
|
+
|
109
|
+
map "/overlay_images" do
|
110
|
+
run OverlayMe::App
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
## Plug on!
|
116
|
+
|
117
|
+
You can add some app specific menu for specific project.. Have a look at layout_resizer.coffee addon to have a quick view of how to use OverlayMe.Menu and OverlayMe.MenuItem
|
118
|
+
|
119
|
+
= javascript_include_tag 'overlay_me/addons/layout_resizer.js'
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
## Known problems
|
124
|
+
|
125
|
+
- you can't find the panel? it's probably hidden aside (previous bigger screen location) or hidden (press 'h')
|
126
|
+
- you see the overlay but can't drag it? the 'Content on Top' option is probably on (press 'c')
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
## Authors / Contributors
|
131
|
+
|
132
|
+
- Rufus Post - former workmate who founded the ovelaying concept
|
133
|
+
- Joseph Boiteau - taking Rufus's idea to 11 (and loving it) - FrontFoot Media Solutions
|
134
|
+
- Lachlan Sylvester - Ruby advisor - Frontfoot Media Solutions
|
135
|
+
- Dan Smith - User Experience Strategist and Califloridian - FrontFoot Media Solutions
|
136
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require "bundler/setup"
|
3
|
+
require 'sprockets'
|
4
|
+
require 'sprockets-sass'
|
5
|
+
require 'compass'
|
6
|
+
require 'rake/sprocketstask'
|
7
|
+
require 'jsmin'
|
8
|
+
require 'yui/compressor'
|
9
|
+
require 'listen'
|
10
|
+
|
11
|
+
ENV['js_sprocket'] = "overlay_me.js"
|
12
|
+
ENV['js_minified'] = "vendor/assets/javascripts/overlay_me/overlay_me.min.js"
|
13
|
+
ENV['css_sprocket'] = "overlay_me.css"
|
14
|
+
ENV['css_minified'] = "style.min.css"
|
15
|
+
|
16
|
+
ENV['addon_layout_resizer'] = "addons/layout_resizer.js"
|
17
|
+
|
18
|
+
desc "default sprockets [:assets] compiling"
|
19
|
+
Rake::SprocketsTask.new do |t|
|
20
|
+
environment = Sprockets::Environment.new
|
21
|
+
environment.append_path 'javascripts'
|
22
|
+
environment.append_path 'stylesheets'
|
23
|
+
|
24
|
+
t.environment = environment
|
25
|
+
t.output = "./"
|
26
|
+
t.assets = [ ENV['js_sprocket'], ENV['css_sprocket'], ENV['addon_layout_resizer'] ]
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "remove DIGEST from filenames"
|
30
|
+
task :remove_digest do
|
31
|
+
puts "\n** Rename compiled files without generated DIGEST **"
|
32
|
+
Dir["{.,addons}/*-*.{js,css}"].each do |file|
|
33
|
+
new_file = file.sub /(.*)-[^\.]+(\.[^\.]+)/, '\1\2'
|
34
|
+
puts "#{file} -> #{new_file}"
|
35
|
+
`mv #{file} #{new_file}`
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "compile assets with Sprockets, remove DIGEST, move some files"
|
40
|
+
task :compile => [:assets, :remove_digest] do
|
41
|
+
puts "\n** Move addons into vendor/asssets/ **"
|
42
|
+
`mv addons vendor/assets/javascripts/overlay_me/`
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
desc "minify the assets"
|
47
|
+
namespace :minify do
|
48
|
+
|
49
|
+
task :css do
|
50
|
+
puts "\n** Minify CSS file #{ENV['css_sprocket']} -> #{ENV['css_minified']} **"
|
51
|
+
File.open(ENV['css_minified'], 'w') do |file|
|
52
|
+
file.write(YUI::CssCompressor.new.compress(File.read(ENV['css_sprocket'])))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
task :add_minified_css_to_js do
|
57
|
+
puts "\n** Add CSS minified blob inline in the javascript :! **"
|
58
|
+
|
59
|
+
css_blob = File.read(ENV['css_minified'])
|
60
|
+
js_string = File.read(ENV['js_sprocket']).gsub(/#CSS_BLOB#/, css_blob)
|
61
|
+
File.open(ENV['js_sprocket'], 'w') { |f| f.write(js_string) }
|
62
|
+
`rm #{ENV['css_minified']}` # remove minified css file
|
63
|
+
end
|
64
|
+
|
65
|
+
task :js do
|
66
|
+
puts "\n** Minify JS file #{ENV['js_sprocket']} -> #{ENV['js_minified']} **"
|
67
|
+
File.open(ENV['js_minified'], 'w') do |file|
|
68
|
+
file.write(JSMin.minify(File.read(ENV['js_sprocket'])))
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
desc "add a header on the minified js file to properly redirect curious"
|
73
|
+
task :prepend_header do
|
74
|
+
puts "\n** Prepend header to compiled files **"
|
75
|
+
|
76
|
+
header = "// OverlayMe v#{OverlayMe::VERSION}\n"
|
77
|
+
header += "// http://github.com/frontfoot/overlay_me\n"
|
78
|
+
header += "//\n"
|
79
|
+
header += "// #{File.open('LICENSE'){|f| f.readline().chomp() }}\n"
|
80
|
+
header += "// OverlayMe is freely distributable under the MIT license.\n"
|
81
|
+
header += "//\n"
|
82
|
+
header += "// Includes:\n"
|
83
|
+
header += "// - jQuery - http://jquery.com/ - Copyright 2011, John Resig\n"
|
84
|
+
header += "// - Backbone.js - http://documentcloud.github.com/backbone - (c) 2010 Jeremy Ashkenas, DocumentCloud Inc.\n"
|
85
|
+
header += "// - Underscore.js - http://documentcloud.github.com/underscore - (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.\n"
|
86
|
+
header += "// - html5slider - https://github.com/fryn/html5slider - Copyright (c) 2010-2011 Frank Yan\n"
|
87
|
+
header += "\n"
|
88
|
+
puts header
|
89
|
+
|
90
|
+
original_content = File.read(ENV['js_minified'])
|
91
|
+
File.open(ENV['js_minified'], 'w') do |f|
|
92
|
+
f.write(header)
|
93
|
+
f.write(original_content)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
task :all_in_one => [:css, :add_minified_css_to_js, :js, :prepend_header]
|
98
|
+
end
|
99
|
+
|
100
|
+
desc "package, aka prepare the minified .js"
|
101
|
+
task :package => [:compile, 'minify:all_in_one']
|
102
|
+
|
103
|
+
desc "Watch javascripts and stylesheets folders re-package the assets at each change"
|
104
|
+
task :watch do
|
105
|
+
callback = Proc.new do
|
106
|
+
`rake package` # trust me I'm not proud... but couldn't find any better
|
107
|
+
puts 'done'
|
108
|
+
end
|
109
|
+
listener = Listen.to('stylesheets', 'javascripts')
|
110
|
+
listener.latency(0.5)
|
111
|
+
listener.change(&callback)
|
112
|
+
listener.start
|
113
|
+
end
|
114
|
+
|
115
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
(function() {
|
2
|
+
var layout_menu, layouts;
|
3
|
+
|
4
|
+
layouts = {
|
5
|
+
smartphone_portrait: 320,
|
6
|
+
smartphone_landscape: 480,
|
7
|
+
tablet_port: 768,
|
8
|
+
tablet_land: 1024,
|
9
|
+
none: null
|
10
|
+
};
|
11
|
+
|
12
|
+
window.resize_page = function(width) {
|
13
|
+
if (width === null || isNaN(width)) {
|
14
|
+
$('#overlay_me_page_container').css({
|
15
|
+
width: 'auto'
|
16
|
+
});
|
17
|
+
} else {
|
18
|
+
$('#overlay_me_page_container').css({
|
19
|
+
width: "" + width + "px"
|
20
|
+
});
|
21
|
+
}
|
22
|
+
_.each(layouts, function(_width, name) {
|
23
|
+
if (width === _width) {
|
24
|
+
return $('body').addClass(name);
|
25
|
+
} else {
|
26
|
+
return $('body').removeClass(name);
|
27
|
+
}
|
28
|
+
});
|
29
|
+
return localStorage.setItem("layout-width", width);
|
30
|
+
};
|
31
|
+
|
32
|
+
window.resize_page(parseInt(localStorage.getItem("layout-width")));
|
33
|
+
|
34
|
+
layout_menu = new OverlayMe.MenuItem({
|
35
|
+
id: "layout-buttons",
|
36
|
+
title: "Layout Resizing"
|
37
|
+
});
|
38
|
+
|
39
|
+
_.each(layouts, function(width, name) {
|
40
|
+
var button;
|
41
|
+
button = (new Backbone.View).make('button', {}, name);
|
42
|
+
$(button).addClass(name);
|
43
|
+
$(button).bind('click', function(e) {
|
44
|
+
return window.resize_page("" + width);
|
45
|
+
});
|
46
|
+
return layout_menu.append(button);
|
47
|
+
});
|
48
|
+
|
49
|
+
$(OverlayMe.Menu).append(layout_menu.render());
|
50
|
+
|
51
|
+
}).call(this);
|
data/demo_page.html
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<style type="text/css">
|
4
|
+
a.this_link {
|
5
|
+
display: inline-block;
|
6
|
+
width: 75px;
|
7
|
+
vertical-align: bottom;
|
8
|
+
height: 18px;
|
9
|
+
}
|
10
|
+
a.this_link:before {
|
11
|
+
content: "this link";
|
12
|
+
text-align: center;
|
13
|
+
text-decoration: underline;
|
14
|
+
background: white;
|
15
|
+
width: 75px;
|
16
|
+
height: 18px;
|
17
|
+
position: absolute;
|
18
|
+
}
|
19
|
+
</style>
|
20
|
+
</head>
|
21
|
+
<body>
|
22
|
+
<div id="container">
|
23
|
+
|
24
|
+
<h2>OverlayMe bookmarklet</h2>
|
25
|
+
|
26
|
+
<p>Drag and drop <a class="this_link" href="javascript:(function(){if(!window.overlay_me_loaded){document.body.appendChild(document.createElement('script')).src='https://raw.github.com/frontfoot/overlay_me/master/vendor/assets/javascripts/overlay_me/overlay_me.min.js';}})();">overlay_me</a> to your bookmarks, then go on any web page and click it!</p>
|
27
|
+
|
28
|
+
<p>Full project here: <a href="https://github.com/frontfoot/overlay_me">https://github.com/frontfoot/overlay_me</a></p>
|
29
|
+
|
30
|
+
</div>
|
31
|
+
</body>
|
32
|
+
</html>
|
33
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
## require menu.coffee and menu_item.coffee to be loaded first !!
|
2
|
+
# Need the page content to be in #content
|
3
|
+
|
4
|
+
|
5
|
+
# available layouts
|
6
|
+
layouts = {
|
7
|
+
smartphone_portrait: 320,
|
8
|
+
smartphone_landscape: 480,
|
9
|
+
tablet_port: 768,
|
10
|
+
tablet_land: 1024,
|
11
|
+
none: null
|
12
|
+
}
|
13
|
+
|
14
|
+
window.resize_page = (width) ->
|
15
|
+
if width == null || isNaN(width)
|
16
|
+
$('#overlay_me_page_container').css { width: 'auto' }
|
17
|
+
else
|
18
|
+
$('#overlay_me_page_container').css { width: "#{width}px" }
|
19
|
+
|
20
|
+
_.each layouts, (_width, name) ->
|
21
|
+
if width == _width
|
22
|
+
$('body').addClass name
|
23
|
+
else
|
24
|
+
$('body').removeClass name
|
25
|
+
localStorage.setItem "layout-width", width
|
26
|
+
|
27
|
+
#load previous state (or null if empty)
|
28
|
+
window.resize_page parseInt(localStorage.getItem("layout-width"))
|
29
|
+
|
30
|
+
# add the buttons to the menu_item
|
31
|
+
layout_menu = new OverlayMe.MenuItem({id: "layout-buttons", title: "Layout Resizing" })
|
32
|
+
_.each layouts, (width, name) ->
|
33
|
+
button = (new Backbone.View).make 'button', {}, name
|
34
|
+
$(button).addClass name
|
35
|
+
$(button).bind 'click', (e) ->
|
36
|
+
window.resize_page "#{width}"
|
37
|
+
layout_menu.append button
|
38
|
+
|
39
|
+
# add the element to the page menu
|
40
|
+
$(OverlayMe.Menu).append layout_menu.render()
|
41
|
+
|
42
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#= require 'menu'
|
2
|
+
#= require 'menu_item'
|
3
|
+
|
4
|
+
if OverlayMe.mustLoad()
|
5
|
+
|
6
|
+
basics_panel = new OverlayMe.MenuItem({id: "bacis-options", title: "Basics" })
|
7
|
+
|
8
|
+
clear_all_button = (new Backbone.View).make 'button', { onClick: "javascript: localStorage.clear(); window.location.reload()" }, 'Reset All'
|
9
|
+
basics_panel.append clear_all_button
|
10
|
+
|
11
|
+
hide_button = (new Backbone.View).make 'button', {}, 'Hide menu (touch "h")'
|
12
|
+
$(hide_button).bind 'click', (event) =>
|
13
|
+
$(OverlayMe.menu_box).trigger 'toggle:visibility'
|
14
|
+
basics_panel.append hide_button
|
15
|
+
|
16
|
+
# add the element to the page menu
|
17
|
+
$(OverlayMe.Menu).append basics_panel.render()
|
18
|
+
|
19
|
+
# add listener for keypress
|
20
|
+
$(window).bind('keypress', (event) =>
|
21
|
+
#console.log event.keyCode, event.charCode
|
22
|
+
if event.charCode == 104 # H
|
23
|
+
$(OverlayMe.menu_box).trigger 'toggle:visibility'
|
24
|
+
)
|
25
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class OverlayMe.Draggable extends Backbone.View
|
2
|
+
|
3
|
+
tagName: 'div'
|
4
|
+
|
5
|
+
initialize: (attributes, options) ->
|
6
|
+
super(attributes, options)
|
7
|
+
if ( cssData = localStorage.getItem(@id) )
|
8
|
+
$(@el).css(JSON.parse(cssData))
|
9
|
+
else
|
10
|
+
$(@el).css(options.default_css) unless options.default_css == undefined
|
11
|
+
|
12
|
+
engageMove: (event) ->
|
13
|
+
event.preventDefault()
|
14
|
+
@moving = true
|
15
|
+
@lastX = event.clientX
|
16
|
+
@lastY = event.clientY
|
17
|
+
$(window).bind 'mymousemove', (event, mouseEvent) =>
|
18
|
+
@updateOverlay(mouseEvent.clientX - @lastX, mouseEvent.clientY - @lastY)
|
19
|
+
@lastX = mouseEvent.clientX
|
20
|
+
@lastY = mouseEvent.clientY
|
21
|
+
$(@el).addClass 'on-move'
|
22
|
+
|
23
|
+
endMove: (event) ->
|
24
|
+
@moving = false
|
25
|
+
$(window).unbind('mymousemove')
|
26
|
+
$(@el).removeClass 'on-move'
|
27
|
+
|
28
|
+
toggleMove: (event) ->
|
29
|
+
if @moving
|
30
|
+
@endMove(event)
|
31
|
+
else
|
32
|
+
@engageMove(event)
|
33
|
+
|
34
|
+
updateOverlay: (x, y) ->
|
35
|
+
newX = parseInt($(@el).css('left')) + x
|
36
|
+
newY = parseInt($(@el).css('top')) + y
|
37
|
+
$(@el).css({ top:"#{newY}px", left:"#{newX}px", right: "auto"})
|
38
|
+
@saveCss()
|
39
|
+
|
40
|
+
saveCss: () ->
|
41
|
+
cssData = {
|
42
|
+
top:$(@el).css('top'),
|
43
|
+
left:$(@el).css('left'),
|
44
|
+
visibility:$(@el).css('visibility'),
|
45
|
+
opacity: $(@el).css('opacity')
|
46
|
+
}
|
47
|
+
localStorage.setItem(@id, JSON.stringify(cssData))
|
48
|
+
|
49
|
+
render: ->
|
50
|
+
@el
|
51
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#= require 'lib/jquery.js'
|
2
|
+
#= require 'lib/underscore.js'
|
3
|
+
#= require 'lib/backbone.js'
|
4
|
+
#= require 'lib/html5slider.js'
|
5
|
+
|
6
|
+
# to build the 1 file minified version, we insert the minified CSS directly there
|
7
|
+
# dirty but so convenient!
|
8
|
+
$('head').append('<style rel="stylesheet" type="text/css">#CSS_BLOB#</style>')
|
9
|
+
|
10
|
+
# initialize Models/Views namespace
|
11
|
+
window.OverlayMe = {}
|
12
|
+
|
13
|
+
# add a flag to stop crazy bookmarklet clicking
|
14
|
+
OverlayMe.isLoaded = ->
|
15
|
+
window.overlay_me_loaded
|
16
|
+
|
17
|
+
# check if browser is a mobile device
|
18
|
+
OverlayMe.isMobile = ->
|
19
|
+
return navigator.userAgent.match /(iPhone|iPod|iPad|Android)/
|
20
|
+
|
21
|
+
# give a shortName method for checks in the app
|
22
|
+
OverlayMe.mustLoad = ->
|
23
|
+
return !OverlayMe.isLoaded() && !OverlayMe.isMobile()
|
24
|
+
|