suri_modal 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +38 -0
  4. data/lib/assets/javascripts/model_alert.js +88 -0
  5. data/lib/assets/javascripts/model_view.js +95 -0
  6. data/lib/assets/javascripts/option_list.js +148 -0
  7. data/lib/assets/javascripts/suri_model.js +4 -0
  8. data/lib/assets/stylesheets/model_alert.css +0 -0
  9. data/lib/assets/stylesheets/model_view.css +0 -0
  10. data/lib/assets/stylesheets/option_list.css +34 -0
  11. data/lib/assets/stylesheets/suri_model.css +3 -0
  12. data/lib/suri_modal/engine.rb +5 -0
  13. data/lib/suri_modal/version.rb +3 -0
  14. data/lib/suri_modal.rb +3 -0
  15. data/lib/tasks/suri_modal_tasks.rake +4 -0
  16. data/test/dummy/README.rdoc +261 -0
  17. data/test/dummy/Rakefile +7 -0
  18. data/test/dummy/app/assets/javascripts/application.js +16 -0
  19. data/test/dummy/app/assets/stylesheets/application.css +14 -0
  20. data/test/dummy/app/controllers/application_controller.rb +3 -0
  21. data/test/dummy/app/controllers/welcomes_controller.rb +83 -0
  22. data/test/dummy/app/helpers/application_helper.rb +2 -0
  23. data/test/dummy/app/helpers/welcomes_helper.rb +2 -0
  24. data/test/dummy/app/models/welcome.rb +3 -0
  25. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  26. data/test/dummy/app/views/welcomes/_form.html.erb +17 -0
  27. data/test/dummy/app/views/welcomes/edit.html.erb +6 -0
  28. data/test/dummy/app/views/welcomes/index.html.erb +288 -0
  29. data/test/dummy/app/views/welcomes/new.html.erb +5 -0
  30. data/test/dummy/app/views/welcomes/show.html.erb +5 -0
  31. data/test/dummy/config/application.rb +59 -0
  32. data/test/dummy/config/boot.rb +10 -0
  33. data/test/dummy/config/database.yml +25 -0
  34. data/test/dummy/config/environment.rb +5 -0
  35. data/test/dummy/config/environments/development.rb +37 -0
  36. data/test/dummy/config/environments/production.rb +67 -0
  37. data/test/dummy/config/environments/test.rb +37 -0
  38. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  39. data/test/dummy/config/initializers/inflections.rb +15 -0
  40. data/test/dummy/config/initializers/mime_types.rb +5 -0
  41. data/test/dummy/config/initializers/secret_token.rb +7 -0
  42. data/test/dummy/config/initializers/session_store.rb +8 -0
  43. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  44. data/test/dummy/config/locales/en.yml +5 -0
  45. data/test/dummy/config/routes.rb +61 -0
  46. data/test/dummy/config.ru +4 -0
  47. data/test/dummy/db/development.sqlite3 +0 -0
  48. data/test/dummy/db/migrate/20130808174512_create_welcomes.rb +8 -0
  49. data/test/dummy/db/schema.rb +21 -0
  50. data/test/dummy/db/test.sqlite3 +0 -0
  51. data/test/dummy/log/development.log +5455 -0
  52. data/test/dummy/public/404.html +26 -0
  53. data/test/dummy/public/422.html +26 -0
  54. data/test/dummy/public/500.html +25 -0
  55. data/test/dummy/public/favicon.ico +0 -0
  56. data/test/dummy/script/rails +6 -0
  57. data/test/dummy/test/fixtures/welcomes.yml +11 -0
  58. data/test/dummy/test/functional/welcomes_controller_test.rb +49 -0
  59. data/test/dummy/test/unit/helpers/welcomes_helper_test.rb +4 -0
  60. data/test/dummy/test/unit/welcome_test.rb +7 -0
  61. data/test/dummy/tmp/cache/assets/C8C/B80/sprockets%2F371bf96e99717688ed7313a0c53f4212 +0 -0
  62. data/test/dummy/tmp/cache/assets/C8D/650/sprockets%2Fd0998c0a623370d6e9ba382b97408668 +0 -0
  63. data/test/dummy/tmp/cache/assets/CA5/100/sprockets%2F8e84a5d11d42d15c1a1569455be11078 +0 -0
  64. data/test/dummy/tmp/cache/assets/CA5/440/sprockets%2Fdd342586c562ed6d028b0d34165a4730 +0 -0
  65. data/test/dummy/tmp/cache/assets/CB5/520/sprockets%2F4a549f54b706a014d89a58e49de04273 +0 -0
  66. data/test/dummy/tmp/cache/assets/CD0/460/sprockets%2F660081ed362bd10dc701d5b94a438a75 +0 -0
  67. data/test/dummy/tmp/cache/assets/CD7/A50/sprockets%2Fda14ec03eb2e824f33b1b09718686642 +0 -0
  68. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  69. data/test/dummy/tmp/cache/assets/CE0/E20/sprockets%2F3b5796e8432708fbd210f150259cfee1 +0 -0
  70. data/test/dummy/tmp/cache/assets/CE4/700/sprockets%2F9d60a6f873bb146c06fb77b269920d60 +0 -0
  71. data/test/dummy/tmp/cache/assets/CF0/1D0/sprockets%2F6fc757c2c8329244ca95d6909865bbc2 +0 -0
  72. data/test/dummy/tmp/cache/assets/CFC/1D0/sprockets%2F59c017c3dd0a51d95af3e802200729ba +0 -0
  73. data/test/dummy/tmp/cache/assets/D0D/2C0/sprockets%2F9e4c000cfa2d749428af0c75cb672718 +0 -0
  74. data/test/dummy/tmp/cache/assets/D12/310/sprockets%2F2fcee59c7d6a49c0016d39913d0319d5 +0 -0
  75. data/test/dummy/tmp/cache/assets/D31/580/sprockets%2F8a00ff20ef2fed1156c118a8b724636a +0 -0
  76. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  77. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  78. data/test/dummy/tmp/cache/assets/D52/190/sprockets%2F8bd7a83053d0fe937d997ecd2565eb09 +0 -0
  79. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  80. data/test/dummy/tmp/cache/assets/D77/C60/sprockets%2F28c70642bf7a2c79809fea6d0d0e87be +0 -0
  81. data/test/dummy/tmp/cache/assets/D8D/C50/sprockets%2Feebf28a43407f4f610ba982ddd0401ca +0 -0
  82. data/test/dummy/tmp/cache/assets/D98/A30/sprockets%2F6e3dd276ad175fa0ef35b33dab9a7056 +0 -0
  83. data/test/dummy/tmp/cache/assets/D9A/D10/sprockets%2F32bd556c5adaedebe27e4c8d81648022 +0 -0
  84. data/test/dummy/tmp/cache/assets/D9F/A30/sprockets%2F6ec7dc231f5505cf2ae1b66be9b4729d +0 -0
  85. data/test/dummy/tmp/cache/assets/DA0/C80/sprockets%2F967c6096ec22de62aa5dd5cdc28cb282 +0 -0
  86. data/test/dummy/tmp/cache/assets/DD8/260/sprockets%2F7b1b9ea7a90e255e759bfce74892adaa +0 -0
  87. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  88. data/test/dummy/tmp/cache/assets/DF6/210/sprockets%2Fa2dd5ddb3ba66aa77c757333ea16f5be +0 -0
  89. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  90. data/test/dummy/tmp/cache/assets/E10/F30/sprockets%2F38c888ceee40a1a7dfe6f6f6657debd0 +0 -0
  91. data/test/dummy/tmp/cache/assets/E1A/9F0/sprockets%2F0c9e95ffa7c8ba8089be6eeed3935bf8 +0 -0
  92. data/test/dummy/tmp/cache/assets/E21/A80/sprockets%2Faeb483c2ceaa318f46a67a7b2d2fef0b +0 -0
  93. data/test/suri_modal_test.rb +7 -0
  94. data/test/test_helper.rb +15 -0
  95. metadata +250 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
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.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = SuriModal
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'SuriModal'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
28
+ require 'rake/testtask'
29
+
30
+ Rake::TestTask.new(:test) do |t|
31
+ t.libs << 'lib'
32
+ t.libs << 'test'
33
+ t.pattern = 'test/**/*_test.rb'
34
+ t.verbose = false
35
+ end
36
+
37
+
38
+ task :default => :test
@@ -0,0 +1,88 @@
1
+ /**
2
+ * User: Suraj Pratap
3
+ * Email: suraj.pratap24@gmail.com
4
+ * Date: 03/08/13
5
+ * Time: 9:24 PM
6
+ */
7
+
8
+
9
+
10
+
11
+ function modelAlert(data, type, time){
12
+
13
+ removeAlertBox();
14
+
15
+ var $model_alert_box = createModelAlertBox(data);
16
+
17
+ $('body').append($model_alert_box);
18
+
19
+ $model_alert_box.show().animate({'top': '+=120px'}, 200);
20
+
21
+ if( type && type == 'fluid' ){
22
+ setTimeout(function(){
23
+ $model_alert_box.animate({ 'top': '-=120px' }, 800, function(){ $(this).remove() });
24
+ }, time);
25
+ }
26
+
27
+ if( type && type == 'error'){
28
+ $model_alert_box.css({
29
+ 'color': 'red'
30
+ });
31
+ }
32
+
33
+ }
34
+
35
+ function removeAlertBox(){
36
+ $('#model-alert-box').animate({ 'top': '-=120px' }, 200, function(){ $(this).remove() });
37
+ }
38
+
39
+ function createModelAlertBox(data){
40
+ var $cross_button = $("<span id='model-alert-cross' >X</span>");
41
+
42
+ $cross_button.css({
43
+ 'fontFamily': 'sans-serif',
44
+ 'float': 'right',
45
+ 'color': 'violet',
46
+ 'cursor': 'pointer'
47
+ });
48
+
49
+ var $alert_data = $("<div id='model-alert-data' >"+ data +"</div>");
50
+
51
+ var $model_alert_box = $("<div id='model-alert-box'></div>");
52
+
53
+ $model_alert_box.css({
54
+ 'position': 'fixed',
55
+ 'width': '60%',
56
+ 'top': '-100px',
57
+ 'left': '20%',
58
+ 'padding': '10px',
59
+ 'border': '1px lightgray solid',
60
+ 'border-radius': '6px',
61
+ 'box-shadow': '0 4px 23px 5px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(0,0,0,0.15)',
62
+ 'background-color': 'white',
63
+ 'display': 'none',
64
+ 'color': 'green'
65
+ });
66
+
67
+ return $model_alert_box.append($cross_button).append($alert_data);
68
+ }
69
+
70
+ // add events
71
+
72
+ $(document).ready(function(){
73
+ $(document).on('mouseenter', '#model-alert-cross', function(){
74
+ $(this).css({
75
+ 'color': 'red'
76
+ });
77
+ });
78
+
79
+ $(document).on('mouseout', '#model-alert-cross', function(){
80
+ $(this).css({
81
+ 'color': 'violet'
82
+ });
83
+ });
84
+
85
+ $(document).on('click', '#model-alert-cross', function(){
86
+ removeAlertBox();
87
+ });
88
+ });
@@ -0,0 +1,95 @@
1
+
2
+ function modelView(){
3
+ this.container = $("<div id='model-view-container' class='suri-model-view'></div>");
4
+ this.dataWrapper = $("<div id='model-view-data-wrapper' class='suri-model-view' ></div>");
5
+
6
+ this.launch = function(){
7
+ // remove previous
8
+ removeModelView();
9
+
10
+ setContainer(this.container);
11
+
12
+ setDataWrapper(this.dataWrapper);
13
+
14
+ // on window resize change the dimensions of container
15
+ $(window).resize(function(){
16
+ var tmp = $(window);
17
+ $('#model-view-container').css({
18
+ 'min-height': tmp.height(),
19
+ 'min-width': tmp.width()
20
+ });
21
+ });
22
+
23
+ // cross button css and js
24
+ $('.cross-button').on({
25
+ 'mouseenter': function(){
26
+ $(this).css({'color':'green'});
27
+ },
28
+ 'mouseout': function(){
29
+ $(this).css({
30
+ 'color': 'red'
31
+ });
32
+ },
33
+ 'mouseup': function(){
34
+ removeModelView();
35
+ }
36
+ });
37
+
38
+ };
39
+
40
+ this.setData = function(data){
41
+ var $data = $("<div id='data-holder-model' ></div>").append(data);
42
+ $data.css({
43
+ 'margin': '20px 20px 20px 20px'
44
+ });
45
+ this.dataWrapper.append($data);
46
+ };
47
+
48
+ function setDataWrapper($dataWrapper){
49
+
50
+ $dataWrapper.find('#data-holder-model').before("<span class='cross-button' style='font-family: sans-serif;font-size: 15px;float: right;margin-top: 3px;margin-right: 5px;cursor: pointer;color: red' >X</span>");
51
+
52
+ $dataWrapper.css({
53
+ 'display': 'inline-block',
54
+ 'min-height': '200px',
55
+ 'min-width': '200px',
56
+ 'border': '1px lightgray solid',
57
+ 'box-shadow': '0 4px 23px 5px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(0,0,0,0.15)',
58
+ 'max-height': '80%',
59
+ 'max-width': '80%',
60
+ 'border-radius': '6px',
61
+ 'background-color': 'white'
62
+ });
63
+
64
+ $dataWrapper = $("<div class='suri-model-view' id='data-wrap-holder'></div>").append($dataWrapper);
65
+
66
+ $dataWrapper.css({
67
+ 'text-align': 'center',
68
+ 'position': 'fixed',
69
+ 'z-index': 15,
70
+ 'width': '100%',
71
+ 'top': '20%'
72
+ });
73
+
74
+ $('body').append($dataWrapper);
75
+ }
76
+
77
+ function setContainer(container){
78
+ var tmp = $(window);
79
+ container.css({
80
+ 'min-height': tmp.height()+'px',
81
+ 'min-width': tmp.width()+'px',
82
+ 'position': 'fixed',
83
+ 'z-index': 10,
84
+ 'top': '0px',
85
+ 'background-color': 'white',
86
+ 'opacity': 0.8
87
+ });
88
+ $('body').append(container);
89
+ }
90
+
91
+ // remove the model
92
+ function removeModelView(){
93
+ $('.suri-model-view').remove();
94
+ }
95
+ }
@@ -0,0 +1,148 @@
1
+ /**
2
+ * User: Suraj Pratap
3
+ * Email: suraj.pratap24@gmail.com
4
+ * Date: 04/08/13
5
+ * Time: 1:04 PM
6
+ */
7
+
8
+
9
+ // initialize global identifier for recording calls
10
+ Identifier = 1;
11
+
12
+ (function($){
13
+
14
+
15
+
16
+
17
+ $.fn.option_list = function (options) {
18
+
19
+ Identifier++;
20
+
21
+ var container = "<div class='popup_ option_list" + Identifier + "'><ul class='options_"+ Identifier +"' style='list-style-type: none;padding: 0px 0px 0px 0px;margin: 0px 0px 0px 0px'>";
22
+
23
+ $.each(options, function(index, value){
24
+ container = container + "<li>"+ value[0] +"</li>";
25
+ });
26
+
27
+ container = container + "</ul></div>";
28
+ this.parents('body').append(container);
29
+
30
+ $('.option_list'+Identifier).css('position', 'absolute').hide();
31
+
32
+ var tmp = Identifier;
33
+
34
+ $.each($('.options_'+tmp).children(), function(index, element){
35
+ if(options[index][1]){
36
+
37
+ element.onclick = options[index][1];
38
+
39
+ // hide when any option is clicked
40
+
41
+ $(element).mouseup(function(){
42
+ $('.popup_').hide();
43
+ });
44
+ }
45
+ });
46
+ //
47
+ // show options menu when element is clicked
48
+
49
+ this.on({
50
+ 'click': function(){
51
+ var position = $(this).offset();
52
+
53
+ position.top += $(this).height();
54
+
55
+ $('.option_list'+tmp).css(position).show();
56
+ }
57
+ });
58
+
59
+ // return this for chaining
60
+ return this;
61
+ }; // plugin ends
62
+
63
+ // ----------------------------------------------------
64
+
65
+ $.fn.mouseenterOptionList = function(options){
66
+ Identifier++;
67
+
68
+ var container = "<div class='popup_ option_list" + Identifier + "'><ul class='block-ul options_"+ Identifier +"' style='list-style-type: none;padding: 0px 0px 0px 0px;margin: 0px 0px 0px 0px'>";
69
+
70
+ $.each(options, function(index, value){
71
+ container = container + "<li class='block-li' >"+ value[0] +"</li>";
72
+ });
73
+
74
+ container = container + "</ul></div>";
75
+ this.parents('body').append(container);
76
+
77
+ $('.option_list'+Identifier).css('position', 'absolute').hide();
78
+
79
+ var tmp = Identifier;
80
+
81
+ $.each($('.options_'+tmp).children(), function(index, element){
82
+ if(options[index][1]){
83
+
84
+ element.onclick = options[index][1];
85
+
86
+ // hide when any option is clicked
87
+
88
+ $(element).mouseup(function(){
89
+ $('.popup_').hide();
90
+ });
91
+
92
+ // when cursor goes out of option list, it hides
93
+ // $(element).mouseout(function(){
94
+ // $(this).parents('.option_list'+tmp).hide();
95
+ // });
96
+ }
97
+ });
98
+
99
+ // $('.option_list'+tmp).mouseout(function(){
100
+ // $(this).hide();
101
+ // });
102
+ //
103
+ // show options menu when element is clicked
104
+
105
+ this.on({
106
+ 'mouseenter': function(){
107
+ var position = $(this).offset();
108
+
109
+ position.top += $(this).height();
110
+
111
+ $('.option_list'+tmp).css(position).show();
112
+ },
113
+
114
+ 'mouseout': function(){
115
+ var flag = true;
116
+ var target = $('.option_list'+tmp);
117
+ target.mouseenter(function(){
118
+ flag = false;
119
+ });
120
+ setTimeout(
121
+ function(){
122
+ if(flag){
123
+ target.hide();
124
+ }
125
+ },
126
+ 100
127
+ );
128
+ }
129
+ });
130
+
131
+ // return this for chaining
132
+ return this;
133
+ };
134
+
135
+
136
+
137
+
138
+ $(document).mouseup(function (e)
139
+ {
140
+ var container = $(".popup_");
141
+ if (!container.is(e.target) // if the target of the click isn't the container...
142
+ && container.has(e.target).length === 0)
143
+ {
144
+ container.hide();
145
+ }
146
+ });
147
+ // }
148
+ }(jQuery));
@@ -0,0 +1,4 @@
1
+ //= require model_alert
2
+ //= require model_view
3
+ //= require option_list
4
+ //= require model_prompt
File without changes
File without changes
@@ -0,0 +1,34 @@
1
+ .popup_{
2
+ background-color: white;
3
+ z-index: 10;
4
+ border: 1px lightgray solid;
5
+ box-shadow: 0px 0px 6px #AAA;
6
+ max-width: 200px;
7
+ }
8
+
9
+ .popup_ li{
10
+ cursor: pointer;
11
+ padding: 2px 4px;
12
+ border: 1px lightgray solid;
13
+ border-collapse: collapse;
14
+ }
15
+
16
+ .popup_ li:hover{
17
+ background-color: lightgray;
18
+ }
19
+
20
+ .block-ul{
21
+ display: block;
22
+ }
23
+
24
+ .block-li{
25
+ display: inline-block;
26
+ min-height: 21px;
27
+ min-width: 21px;
28
+ }
29
+
30
+ .block-li img{
31
+ display: block;
32
+ min-width: 20px;
33
+ min-height: 20px;
34
+ }
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require option_list
3
+ */
@@ -0,0 +1,5 @@
1
+ module SuriModal
2
+ class Engine < ::Rails::Engine
3
+
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module SuriModal
2
+ VERSION = "0.0.1"
3
+ end
data/lib/suri_modal.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'suri_modal/engine'
2
+ module SuriModal
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :suri_modal do
3
+ # # Task goes here
4
+ # end