image_viewer_rails 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. data/README.md +3 -1
  2. data/app/assets/javascripts/image_viewer_rails/image_viewer.js +10 -6
  3. data/app/assets/stylesheets/image_viewer_rails/image_viewer_rails.css.scss +2 -1
  4. data/lib/image_viewer_rails/version.rb +1 -1
  5. data/spec/dummy/log/development.log +123 -0
  6. data/spec/dummy/log/test.log +0 -0
  7. data/spec/dummy/spec/javascripts/rotate_spec.js.coffee +9 -0
  8. data/spec/dummy/tmp/cache/assets/C78/CF0/sprockets%2F4c1182626f663c405915d434b32a1f7f +0 -0
  9. data/spec/dummy/tmp/cache/assets/CBE/0E0/sprockets%2F60437498c8b738df7ca548c194c5c404 +0 -0
  10. data/spec/dummy/tmp/cache/assets/D18/390/sprockets%2F56ba9fd12901f581bed04627d782eb88 +0 -0
  11. data/spec/dummy/tmp/cache/assets/D26/1F0/sprockets%2F5323df7e62538575d8c46bec5f37cf49 +0 -0
  12. data/spec/dummy/tmp/cache/assets/D29/F20/sprockets%2F30bec94a7aeb240d3b4643ed218018d2 +0 -0
  13. data/spec/dummy/tmp/cache/assets/D35/660/sprockets%2F73a76ae2db798148aac4b73d032b0e45 +0 -0
  14. data/spec/dummy/tmp/cache/assets/D4A/0A0/sprockets%2F54bb86eb7a7328694996b3a30ffdaf14 +0 -0
  15. data/spec/dummy/tmp/cache/assets/D64/9D0/sprockets%2F2057bd6bd0256a7b4b9d47ef0802a5bf +0 -0
  16. data/spec/dummy/tmp/cache/assets/D7B/630/sprockets%2F8b1d98cdb28a579c80c8e40f0173c9ee +0 -0
  17. data/spec/dummy/tmp/cache/assets/D90/E10/sprockets%2F3eef7d0e134d1a4bdb68173d2710ebf3 +0 -0
  18. data/spec/dummy/tmp/cache/assets/D93/5F0/sprockets%2F5a9c4a80c5a143e82cb33e0bd2ce786c +0 -0
  19. data/spec/dummy/tmp/cache/assets/DCA/6E0/sprockets%2F39615bd6ae519bf36ba6af7a0aa76c7c +0 -0
  20. data/spec/dummy/tmp/cache/assets/DCD/050/sprockets%2Fc025d36b6fa943b07cd5243f8cecf7eb +0 -0
  21. data/spec/dummy/tmp/cache/assets/DD1/F20/sprockets%2Fffd9cc2905ac7a5c93b5233e1cfa884c +0 -0
  22. data/spec/dummy/tmp/cache/assets/DE7/770/sprockets%2F056c18c8e967dd4b9e9cf85eadac64f5 +0 -0
  23. data/spec/dummy/tmp/cache/assets/E12/900/sprockets%2Fcda5325200faa03dfc104fd3fe67ceba +0 -0
  24. metadata +4 -4
  25. data/spec/dummy/tmp/pids/server.pid +0 -1
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  This project rocks and uses MIT-LICENSE.
4
4
 
5
+ #[View Live Demo](http://jonathan-jackson.net/image_viewer_rails/)
6
+
5
7
  A rails engine to serve imageviewer js files easily and ubiquitiously
6
8
 
7
9
  ImageViewerRails is simply a wrapper for a javascript library that will load an array of images to your screen and offer controls for manipulating those images. It was designed to be used with forms on pages for quick and efficient data entry. It provides a nav bar that allows for rotation, zooming, and more. Most of the allowable manipulations have corrolary key listeners which we'll cover a little more below.
@@ -38,7 +40,7 @@ Clicking the info link in the nav section will display a modal legend with all o
38
40
  Since this mostly just serves up commonly used js files for internal use all you need to do is add the following lines to your `Gemfile`
39
41
 
40
42
  ```ruby
41
- gem "image_viewer_rails", "~> 0.0.1"
43
+ gem "image_viewer_rails", "~> 0.1.0"
42
44
  ```
43
45
 
44
46
  In your `app/assets/javascripts/application.js` (manifest file) add the following:
@@ -510,13 +510,16 @@
510
510
  */
511
511
  function rotate(increment, imageIndex){
512
512
  if (imageIndex === undefined) imageIndex = settings["imageIndex"];
513
- var image = $('#' + settings["mainDiv"].attr("id") + '-full-image-' + imageIndex);
514
- var current_angle = parseInt(image.attr('angle'),10);
513
+ var image = $('#' + settings["mainDiv"].attr("id") + '-full-image-' + imageIndex),
514
+ currentAngle = parseInt(image.attr('angle'),10),
515
+ initialImageIndex = settings['imageIndex'];
515
516
 
516
- image.rotate(current_angle + increment);
517
- current_angle = parseInt(image.getRotateAngle(),10) % 360;
518
517
 
519
- if (current_angle === 90 || current_angle === 270) {
518
+ showPage(imageIndex);
519
+ image.rotate(currentAngle + increment);
520
+ currentAngle = parseInt(image.getRotateAngle(),10) % 360;
521
+
522
+ if (currentAngle === 90 || currentAngle === 270) {
520
523
  var offset = image.height()/2 - image.width()/2;
521
524
  image.css('margin-top', -1 * offset);
522
525
  image.css('margin-left', offset);
@@ -525,7 +528,8 @@
525
528
  image.css('margin-left', 0);
526
529
  }
527
530
 
528
- image.attr('angle',current_angle);
531
+ image.attr('angle',currentAngle);
532
+ showPage(initialImageIndex);
529
533
  }
530
534
 
531
535
  /** if argument passed to IIFE aren't a method defined on imageViewer then pass the arguments to initialize. */
@@ -7,11 +7,12 @@
7
7
  }
8
8
 
9
9
  .image-viewer {
10
+ height: 95%; /* fallback for browsers withouth support for calc */
10
11
  height: -moz-calc(100% - 24px); /* Firefox */
11
12
  height: -webkit-calc(100% - 24px); /* WebKit */
12
13
  height: -o-calc(100% - 24px); /* Opera */
13
14
  height: calc(100% - 24px); /* Standard */
14
- width: 99%;
15
+ width: 100%;
15
16
  overflow: auto;
16
17
  margin-right:auto;
17
18
  margin-left:auto;
@@ -1,3 +1,3 @@
1
1
  module ImageViewerRails
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -33477,3 +33477,126 @@ Served asset /test_image_2.jpeg - 200 OK (0ms)
33477
33477
 
33478
33478
  Started GET "/assets/image_viewer_rails/glyphicons-halflings.png" for 127.0.0.1 at 2013-03-28 16:53:55 -0400
33479
33479
  Served asset /image_viewer_rails/glyphicons-halflings.png - 200 OK (0ms)
33480
+ Connecting to database specified by database.yml
33481
+
33482
+
33483
+ Started GET "/jasmine" for 127.0.0.1 at 2013-03-29 09:37:03 -0400
33484
+ Processing by Jasminerice::SpecController#index as */*
33485
+ Compiled image_viewer_rails/image_viewer_rails.css (754ms) (pid 28725)
33486
+ Compiled image_viewer_rails.css (13ms) (pid 28725)
33487
+ Compiled spec.css (15ms) (pid 28725)
33488
+ Compiled image_viewer_rails/image_viewer.js (0ms) (pid 28725)
33489
+ Compiled image_viewer_rails.js (5ms) (pid 28725)
33490
+ Compiled rotate_spec.js (685ms) (pid 28725)
33491
+ Compiled spec.js (361ms) (pid 28725)
33492
+ Rendered /Users/jjackson/.rvm/gems/ruby-1.9.3-p327/gems/jasminerice-0.0.10/app/views/jasminerice/spec/index.html.haml (2421.8ms)
33493
+ Completed 200 OK in 2439ms (Views: 2438.7ms | ActiveRecord: 0.0ms)
33494
+
33495
+
33496
+ Started GET "/jasmine" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33497
+ Processing by Jasminerice::SpecController#index as HTML
33498
+ Rendered /Users/jjackson/.rvm/gems/ruby-1.9.3-p327/gems/jasminerice-0.0.10/app/views/jasminerice/spec/index.html.haml (563.6ms)
33499
+ Completed 200 OK in 570ms (Views: 569.6ms | ActiveRecord: 0.0ms)
33500
+
33501
+
33502
+ Started GET "/assets/jasmine.css?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33503
+ Served asset /jasmine.css - 200 OK (5ms)
33504
+
33505
+
33506
+ Started GET "/assets/image_viewer_rails.css?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33507
+ Served asset /image_viewer_rails.css - 200 OK (10ms)
33508
+
33509
+
33510
+ Started GET "/assets/jasmine.js?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33511
+ Served asset /jasmine.js - 200 OK (3ms)
33512
+
33513
+
33514
+ Started GET "/assets/image_viewer_rails/image_viewer_rails.css?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33515
+ Served asset /image_viewer_rails/image_viewer_rails.css - 200 OK (4ms)
33516
+
33517
+
33518
+ Started GET "/assets/spec.css?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33519
+ Served asset /spec.css - 200 OK (7ms)
33520
+
33521
+
33522
+ Started GET "/assets/jasmine-html.js?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33523
+ Served asset /jasmine-html.js - 200 OK (5ms)
33524
+
33525
+
33526
+ Started GET "/assets/jasmine-jquery-1.4.2.js?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33527
+ Served asset /jasmine-jquery-1.4.2.js - 200 OK (19ms)
33528
+
33529
+
33530
+ Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33531
+ Served asset /jquery.js - 200 OK (3ms)
33532
+
33533
+
33534
+ Started GET "/assets/image_viewer_rails/keymaster.js?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33535
+ Served asset /image_viewer_rails/keymaster.js - 200 OK (6ms)
33536
+
33537
+
33538
+ Started GET "/assets/jasminerice.js?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33539
+ Served asset /jasminerice.js - 200 OK (11ms)
33540
+
33541
+
33542
+ Started GET "/assets/image_viewer_rails/jquery.rotate.js?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33543
+ Served asset /image_viewer_rails/jquery.rotate.js - 200 OK (6ms)
33544
+
33545
+
33546
+ Started GET "/assets/image_viewer_rails/image_viewer.js?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33547
+ Served asset /image_viewer_rails/image_viewer.js - 200 OK (7ms)
33548
+
33549
+
33550
+ Started GET "/assets/image_viewer_rails/keymaster_filter.js?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33551
+ Served asset /image_viewer_rails/keymaster_filter.js - 200 OK (5ms)
33552
+
33553
+
33554
+ Started GET "/assets/image_viewer_rails.js?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33555
+ Served asset /image_viewer_rails.js - 200 OK (10ms)
33556
+
33557
+
33558
+ Started GET "/assets/legend_spec.js?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33559
+ Served asset /legend_spec.js - 200 OK (4ms)
33560
+
33561
+
33562
+ Started GET "/assets/next_previous_spec.js?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33563
+ Served asset /next_previous_spec.js - 200 OK (6ms)
33564
+
33565
+
33566
+ Started GET "/assets/rotate_spec.js?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33567
+ Served asset /rotate_spec.js - 200 OK (3ms)
33568
+
33569
+
33570
+ Started GET "/assets/image_viewer_spec.js?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33571
+ Served asset /image_viewer_spec.js - 200 OK (7ms)
33572
+
33573
+
33574
+ Started GET "/assets/up_down_left_right_spec.js?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33575
+ Served asset /up_down_left_right_spec.js - 200 OK (3ms)
33576
+
33577
+
33578
+ Started GET "/assets/zoom_spec.js?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33579
+ Served asset /zoom_spec.js - 200 OK (3ms)
33580
+
33581
+
33582
+ Started GET "/assets/spec.js?body=1" for 127.0.0.1 at 2013-03-29 09:37:09 -0400
33583
+ Served asset /spec.js - 200 OK (23ms)
33584
+
33585
+
33586
+ Started GET "/jasmine/fixtures/image_viewer_index?1364564230033" for 127.0.0.1 at 2013-03-29 09:37:10 -0400
33587
+ Processing by Jasminerice::SpecController#fixtures as */*
33588
+ Parameters: {"1364564230033"=>nil, "filename"=>"image_viewer_index"}
33589
+ Rendered spec/javascripts/fixtures/image_viewer_index.html (0.7ms)
33590
+ Completed 200 OK in 19ms (Views: 18.3ms | ActiveRecord: 0.0ms)
33591
+
33592
+
33593
+ Started GET "/assets/test_image_1.jpeg" for 127.0.0.1 at 2013-03-29 09:37:10 -0400
33594
+ Served asset /test_image_1.jpeg - 200 OK (2ms)
33595
+
33596
+
33597
+ Started GET "/assets/image_viewer_rails/glyphicons-halflings.png" for 127.0.0.1 at 2013-03-29 09:37:10 -0400
33598
+ Served asset /image_viewer_rails/glyphicons-halflings.png - 200 OK (17ms)
33599
+
33600
+
33601
+ Started GET "/assets/test_image_2.jpeg" for 127.0.0.1 at 2013-03-29 09:37:10 -0400
33602
+ Served asset /test_image_2.jpeg - 200 OK (4ms)
File without changes
@@ -40,3 +40,12 @@ describe "Rotate Page / Rotate All Pages", ->
40
40
  viewer.rotate_all(90)
41
41
  expect(currentPage()).toBe(1)
42
42
 
43
+ it "shouldn't use an offset of 50px (because width was 0)", ->
44
+ viewer.rotate_all(90)
45
+
46
+ $('img').each (index)->
47
+ image = $(this)
48
+ console.log image.css('margin-top')
49
+
50
+ expect(image.css('margin-top')).not.toBe("50px")
51
+ expect(image.css('margin-left')).not.toBe("-50px")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: image_viewer_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-03-28 00:00:00.000000000 Z
13
+ date: 2013-03-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -226,6 +226,7 @@ files:
226
226
  - spec/dummy/db/schema.rb
227
227
  - spec/dummy/Guardfile
228
228
  - spec/dummy/log/development.log
229
+ - spec/dummy/log/test.log
229
230
  - spec/dummy/public/404.html
230
231
  - spec/dummy/public/422.html
231
232
  - spec/dummy/public/500.html
@@ -315,7 +316,6 @@ files:
315
316
  - spec/dummy/tmp/cache/assets/E2F/AA0/sprockets%2F863db5f4a3eba66229ef23cbeeed9cb2
316
317
  - spec/dummy/tmp/cache/assets/E34/8A0/sprockets%2Fdcd8b4c62858ccacc994381b6cadb7cd
317
318
  - spec/dummy/tmp/cache/assets/E52/B30/sprockets%2F73ba6bee6c4e4e37ea2ccceb9c230cf0
318
- - spec/dummy/tmp/pids/server.pid
319
319
  homepage: http://jonathan-jackson.net
320
320
  licenses: []
321
321
  post_install_message:
@@ -369,6 +369,7 @@ test_files:
369
369
  - spec/dummy/db/schema.rb
370
370
  - spec/dummy/Guardfile
371
371
  - spec/dummy/log/development.log
372
+ - spec/dummy/log/test.log
372
373
  - spec/dummy/public/404.html
373
374
  - spec/dummy/public/422.html
374
375
  - spec/dummy/public/500.html
@@ -458,5 +459,4 @@ test_files:
458
459
  - spec/dummy/tmp/cache/assets/E2F/AA0/sprockets%2F863db5f4a3eba66229ef23cbeeed9cb2
459
460
  - spec/dummy/tmp/cache/assets/E34/8A0/sprockets%2Fdcd8b4c62858ccacc994381b6cadb7cd
460
461
  - spec/dummy/tmp/cache/assets/E52/B30/sprockets%2F73ba6bee6c4e4e37ea2ccceb9c230cf0
461
- - spec/dummy/tmp/pids/server.pid
462
462
  has_rdoc:
@@ -1 +0,0 @@
1
- 77363