integratedscaffold 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. data/Gemfile +6 -0
  2. data/Manifest +85 -0
  3. data/README +1 -0
  4. data/README.rdoc +1 -0
  5. data/Rakefile +14 -0
  6. data/integratedscaffold.gemspec +38 -0
  7. data/lib/integratedscaffold.rb +289 -0
  8. data/lib/templates/actions/create.rb +8 -0
  9. data/lib/templates/actions/destroy.rb +5 -0
  10. data/lib/templates/actions/edit.rb +4 -0
  11. data/lib/templates/actions/index.rb +5 -0
  12. data/lib/templates/actions/new.rb +4 -0
  13. data/lib/templates/actions/parse_save_from_excel.rb +45 -0
  14. data/lib/templates/actions/show.rb +5 -0
  15. data/lib/templates/actions/update.rb +8 -0
  16. data/lib/templates/assets/images/background.jpg +0 -0
  17. data/lib/templates/assets/images/download.png +0 -0
  18. data/lib/templates/assets/images/inner_texture.jpeg +0 -0
  19. data/lib/templates/assets/images/logo.png +0 -0
  20. data/lib/templates/assets/images/new.png +0 -0
  21. data/lib/templates/assets/images/upload.png +0 -0
  22. data/lib/templates/assets/images/welcome_icon_1.png +0 -0
  23. data/lib/templates/assets/images/welcome_icon_2.png +0 -0
  24. data/lib/templates/assets/images/welcome_icon_3.png +0 -0
  25. data/lib/templates/assets/images/welcome_icon_4.png +0 -0
  26. data/lib/templates/assets/images/welcome_image.png +0 -0
  27. data/lib/templates/assets/javascripts/exclusions/fiddletabs.js +233 -0
  28. data/lib/templates/assets/javascripts/exclusions/jquery.mousewheel.min.js +12 -0
  29. data/lib/templates/assets/javascripts/exclusions/jquery.pageslide.js +202 -0
  30. data/lib/templates/assets/javascripts/jquery.dataTables.min.js +2475 -0
  31. data/lib/templates/assets/stylesheets/base_classes.css.scss +107 -0
  32. data/lib/templates/assets/stylesheets/exclusions/fiddletabs.css +77 -0
  33. data/lib/templates/assets/stylesheets/exclusions/images/Sorting icons.psd +0 -0
  34. data/lib/templates/assets/stylesheets/exclusions/images/back_disabled.jpg +0 -0
  35. data/lib/templates/assets/stylesheets/exclusions/images/back_enabled.jpg +0 -0
  36. data/lib/templates/assets/stylesheets/exclusions/images/favicon.ico +0 -0
  37. data/lib/templates/assets/stylesheets/exclusions/images/forward_disabled.jpg +0 -0
  38. data/lib/templates/assets/stylesheets/exclusions/images/forward_enabled.jpg +0 -0
  39. data/lib/templates/assets/stylesheets/exclusions/images/sort_asc.png +0 -0
  40. data/lib/templates/assets/stylesheets/exclusions/images/sort_asc_disabled.png +0 -0
  41. data/lib/templates/assets/stylesheets/exclusions/images/sort_both.png +0 -0
  42. data/lib/templates/assets/stylesheets/exclusions/images/sort_desc.png +0 -0
  43. data/lib/templates/assets/stylesheets/exclusions/images/sort_desc_disabled.png +0 -0
  44. data/lib/templates/assets/stylesheets/exclusions/jquery_data_table.css +513 -0
  45. data/lib/templates/assets/stylesheets/images/Sorting icons.psd +0 -0
  46. data/lib/templates/assets/stylesheets/images/back_disabled.jpg +0 -0
  47. data/lib/templates/assets/stylesheets/images/back_enabled.jpg +0 -0
  48. data/lib/templates/assets/stylesheets/images/favicon.ico +0 -0
  49. data/lib/templates/assets/stylesheets/images/forward_disabled.jpg +0 -0
  50. data/lib/templates/assets/stylesheets/images/forward_enabled.jpg +0 -0
  51. data/lib/templates/assets/stylesheets/images/sort_asc.png +0 -0
  52. data/lib/templates/assets/stylesheets/images/sort_asc_disabled.png +0 -0
  53. data/lib/templates/assets/stylesheets/images/sort_both.png +0 -0
  54. data/lib/templates/assets/stylesheets/images/sort_desc.png +0 -0
  55. data/lib/templates/assets/stylesheets/images/sort_desc_disabled.png +0 -0
  56. data/lib/templates/assets/stylesheets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  57. data/lib/templates/assets/stylesheets/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  58. data/lib/templates/assets/stylesheets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  59. data/lib/templates/assets/stylesheets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  60. data/lib/templates/assets/stylesheets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  61. data/lib/templates/assets/stylesheets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  62. data/lib/templates/assets/stylesheets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  63. data/lib/templates/assets/stylesheets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  64. data/lib/templates/assets/stylesheets/images/ui-icons_222222_256x240.png +0 -0
  65. data/lib/templates/assets/stylesheets/images/ui-icons_2e83ff_256x240.png +0 -0
  66. data/lib/templates/assets/stylesheets/images/ui-icons_454545_256x240.png +0 -0
  67. data/lib/templates/assets/stylesheets/images/ui-icons_888888_256x240.png +0 -0
  68. data/lib/templates/assets/stylesheets/images/ui-icons_cd0a0a_256x240.png +0 -0
  69. data/lib/templates/assets/stylesheets/information_page.css.scss +3 -0
  70. data/lib/templates/assets/stylesheets/jquery_data_table.css +513 -0
  71. data/lib/templates/controller.rb +4 -0
  72. data/lib/templates/file_uploader.rb +48 -0
  73. data/lib/templates/helper.rb +2 -0
  74. data/lib/templates/layouts/application.html.erb +69 -0
  75. data/lib/templates/layouts/dummy_data.html.erb +80 -0
  76. data/lib/templates/layouts/information_page.html.erb +81 -0
  77. data/lib/templates/layouts/pageslide_form_at.html.erb +2 -0
  78. data/lib/templates/layouts/welcome.html.erb +71 -0
  79. data/lib/templates/migration.rb +18 -0
  80. data/lib/templates/model.rb +7 -0
  81. data/lib/templates/views/erb/_form.html.erb +32 -0
  82. data/lib/templates/views/erb/edit.html.erb +11 -0
  83. data/lib/templates/views/erb/index.html.erb +216 -0
  84. data/lib/templates/views/erb/new.html.erb +11 -0
  85. data/lib/templates/views/erb/show.html.erb +0 -0
  86. metadata +271 -0
@@ -0,0 +1,5 @@
1
+ def destroy
2
+ @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
+ @<%= instance_name %>.destroy
4
+ redirect_to <%= items_url %>, :notice => "Successfully destroyed <%= class_name.underscore.humanize.downcase %>."
5
+ end
@@ -0,0 +1,4 @@
1
+ def edit
2
+ @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
+ render :layout=>"pageslide_form_at"
4
+ end
@@ -0,0 +1,5 @@
1
+ def index
2
+ @<%= instances_name %> = <%= class_name %>.all
3
+ @<%= instance_name %> = <%= class_name %>.new
4
+
5
+ end
@@ -0,0 +1,4 @@
1
+ def new
2
+ @<%= instance_name %> = <%= class_name %>.new
3
+ render :layout=>"pageslide_form_at"
4
+ end
@@ -0,0 +1,45 @@
1
+ def parse_save_from_excel
2
+ test_file = params[:excel_file]
3
+ file = FileUploader.new
4
+ if file.store!(test_file)
5
+ book = Spreadsheet.open "#{file.store_path}"
6
+ sheet1 = book.worksheet 0
7
+
8
+ @<%= instance_name %> = []
9
+ @errors = Hash.new
10
+ @counter = 0
11
+
12
+ sheet1.each 1 do |row|
13
+ @counter+=1
14
+ <%- final_query="find_by_" -%>
15
+ <%- final_arguments="" -%>
16
+ <%- a="_and_" -%>
17
+ p = <%= class_name %>.new
18
+ <%- model_attributes.each_with_index do |attribute,index| -%>
19
+ <%- final_query=final_query+ attribute.name %>
20
+ <%- final_arguments=final_arguments+"p."+attribute.name -%>
21
+ <%-if index < model_attributes.length-1 -%>
22
+ <%- final_query=final_query+ a %>
23
+ <%- final_arguments=final_arguments+ "," %>
24
+ <%- end -%>
25
+ p.<%=attribute.name %> = row[<%=index%>]
26
+ <%- end -%>
27
+ unless <%= class_name %>.<%=final_query%>(<%= final_arguments %>)
28
+ if p.valid?
29
+ p.save
30
+ else
31
+ @errors["#{@counter+1}"] = p.errors
32
+ end
33
+ end
34
+ end
35
+ file.remove!
36
+ if @errors.empty?
37
+ redirect_to <%= item_path %>, notice: 'All Dummy data were successfully uploaded.'
38
+ else
39
+ redirect_to <%= item_path %>, notice: 'There were some errors in your upload'
40
+ end
41
+
42
+ else
43
+ redirect_to <%= item_path %>, notice: 'Dummy datum could not be successfully uploaded.'
44
+ end
45
+ end
@@ -0,0 +1,5 @@
1
+ def show
2
+
3
+ @<%= instance_name %> = <%= class_name %>.find(params[:id])
4
+
5
+ end
@@ -0,0 +1,8 @@
1
+ def update
2
+ @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
+ if @<%= instance_name %>.update_attributes(params[:<%= instance_name %>])
4
+ redirect_to <%= items_url %>, :notice => "Successfully updated <%= class_name.underscore.humanize.downcase %>."
5
+ else
6
+ render :edit
7
+ end
8
+ end
Binary file
@@ -0,0 +1,233 @@
1
+ /**
2
+ * Created by JetBrains RubyMine.
3
+ * User: arijit
4
+ * Date: 18/1/12
5
+ * Time: 1:09 PM
6
+ * To change this template use File | Settings | File Templates.
7
+ */
8
+
9
+ $(function() {
10
+ (function($) {
11
+ $.fn.extend({
12
+ oldAnimate: $.fn.animate,
13
+ animate: function(props, speed, easing, callback) {
14
+ var camelToHyphen = function(camel) {
15
+ return camel.replace(/([A-Z])/g, "-$1").toLowerCase();
16
+ }, prefixes = [
17
+ "Moz", "Webkit",
18
+ "O", "Ms", "Khtml"
19
+ ], transitionProp = false,
20
+ $this = $(this);
21
+ callback = (typeof easing === "function") ? easing : (callback) ? callback : function() {
22
+ };
23
+ easing = (easing && typeof easing === "string") ? easing : "ease-in-out";
24
+ for (var i = 0; i < prefixes.length; i++) {
25
+ if (prefixes[i] + "Transition" in $this.get(0).style) {
26
+ transitionProp = "-" + prefixes[i].toLowerCase() + "-transition";
27
+ break;
28
+ }
29
+ }
30
+ return $this.each(function() {
31
+ var $$this = $(this);
32
+ var transitionString;
33
+ if (transitionProp) {
34
+ var oldTransition = $$this.css(transitionProp);
35
+ transitionString = (oldTransition) ? oldTransition + ", " : "";
36
+ for (prop in props) {
37
+ transitionString += camelToHyphen(prop) + " " + speed + "ms " + easing + ", ";
38
+ }
39
+ transitionString = transitionString.replace(/\, $/, "");
40
+ $$this.css(transitionProp, transitionString).css(props);
41
+ setTimeout(function() {
42
+ $$this.css(transitionProp, oldTransition);
43
+ callback();
44
+ }, speed);
45
+ }
46
+ else {
47
+ $$this.oldAnimate(props, speed, callback);
48
+ }
49
+ });
50
+ }
51
+ });
52
+ })(jQuery);
53
+
54
+ (function($) {
55
+ $.fn.extend({
56
+ danceSwitcher: function(options) {
57
+ var defaults = {
58
+ speed: 1,
59
+ collapsedWidth: 230,
60
+ collapsedHeight: 80,
61
+ collapsedMPB: [10, 10, 10, 10],
62
+ collapsedLineHeight: '80px',
63
+ activeLineHeight: '48px',
64
+ animationSequence: 'prev/next'
65
+ };
66
+ options = $.extend(defaults, options);
67
+ return $(this).each(function() {
68
+ var $this = $(this),
69
+ speed = options.speed,
70
+ first = $(this).children('div').eq(0), // the first child of the switcher, so that it is open by default
71
+ i;
72
+ $this.css('height', ($this.children('div').length - 1) * (options.collapsedHeight + options.collapsedMPB[0] + options.collapsedMPB[2]) + 'px'); // set the height of the switcher to the appropriate value
73
+ first.addClass('active'); // make the first box active
74
+ for (i = 1; i < $this.children('div').length; i++) { // position all of the boxes appropriately
75
+ $this.children('div').eq(i).css('top', (i - 1) * (options.collapsedHeight + options.collapsedMPB[0] + options.collapsedMPB[2]) + 'px');
76
+ }
77
+ if (options.animationSequence === 'prev/next') { // using the default animation
78
+ $this.children('div').click(function() { // bind aclick event to all the boxes
79
+ var $$this = $(this);
80
+ if (!$$this.hasClass('active') && !$this.hasClass('inprogress')) { // if the box clicked isn't already active and there isn't already animation going on
81
+ var next, prev;
82
+ $this.addClass('inprogress'); // make sure 2 animations don't happen at once
83
+ $this.children('.active').children('.content').animate({ // fade out the content of the active box
84
+ opacity: 0
85
+ }, 750 / speed);
86
+ $this.children('.active').children('h3').animate({ // animate the active header line height
87
+ lineHeight: options.collapsedLineHeight
88
+ }, 750 / speed);
89
+ if ($$this.next(':not(.active)').get(0)) { // if the clicked box isn't last
90
+ next = $(this).next();
91
+ prev = false;
92
+ }
93
+ else {
94
+ next = $$this.prev();
95
+ prev = true;
96
+ }
97
+ $$this.css({ // convert the height property of the clicked box to the bottom property
98
+ bottom: $this.height() - $$this.position().top - (options.collapsedHeight + options.collapsedMPB[0] + options.collapsedMPB[2]),
99
+ height: 'auto'
100
+ });
101
+ $this.children('.active').css('height', $this.children('.active').height()).animate({
102
+ top: next.css('top'), // move the active box to the vertical position of its final destination
103
+ height: options.collapsedHeight // make its height the height of a collapsed box
104
+ }, 750 / speed, function() {
105
+ $$this.animate({ // move the clicked box out untill it's the same dimensions as the previously active box
106
+ left: 0,
107
+ right: (options.collapsedWidth + options.collapsedMPB[1] + options.collapsedMPB[3])
108
+ }, 500 / speed, function() {
109
+ next.animate({ // move the box next to the previously active box (to the right) to the place where the clicked box used to be
110
+ top: $$this.css('top')
111
+ }, 750 / speed, function() {
112
+ $this.children('.active').animate({ // move the previously active box to where the last animated box just was
113
+ left: next.position().left,
114
+ right: 0
115
+ }, 750 / speed, function() {
116
+ $$this.children('h3').animate({ // animate the line height of the clicked box to the height of an active box
117
+ lineHeight: options.activeLineHeight
118
+ }, 750 / speed);
119
+ $$this.children('.content').animate({ // and make its content opaque
120
+ opacity: 1
121
+ }, 750 / speed);
122
+ $$this.animate({ // and give it the dimensions of an active box
123
+ top: 0,
124
+ bottom: 0
125
+ }, 750 / speed, function() {
126
+ if (!prev) {
127
+ $this.children('.active').insertAfter(next); // if the "next" box was the box underneath the now active box, mave its position in the DOM to where it now is visually on the page
128
+ }
129
+ else if (prev) {
130
+ $this.children('.active').insertBefore(next); // same thing but if it was above the now active box
131
+ }
132
+ $this.children('.active').removeClass('active'); // remove the active class from the box that is no longer active
133
+ $$this.addClass('active'); // and add it to the now active box
134
+
135
+ $$this.prependTo($$this.parent()); // move the now active box to the top of the switcher DOM tree
136
+ $this.removeClass('inprogress'); // and set the switcher to not animating
137
+ });
138
+ });
139
+ });
140
+ });
141
+ });
142
+ }
143
+ });
144
+ }
145
+ else if (options.animationSequence === 'first/last') {
146
+ $this.children('div').click(function() {
147
+ var $$this = $(this), active = $this.children('.active'), last = !$$this.next().get(0), alreadyCalled = false,
148
+ callback = function() {
149
+ console.log($this.width() - (options.collapsedWidth + options.collapsedMPB[1] + options.collapsedMPB[3]));
150
+ active.css('bottom', 'auto').animate({
151
+ right: 0,
152
+ left: $this.width() - (options.collapsedWidth + options.collapsedMPB[1] + options.collapsedMPB[3])
153
+ }, 750 / speed, function() {
154
+ $$this.animate({
155
+ top: 0,
156
+ bottom: 0
157
+ }, 750 / speed).children('h3').animate({
158
+ lineHeight: options.activeLineHeight
159
+ }, 750 / speed);
160
+ $$this.children('.content').animate({
161
+ opacity: 1
162
+ }, 750 / speed, function() {
163
+ if (!last) {
164
+ active.appendTo($this).removeClass('active');
165
+ }
166
+ else {
167
+ active.prependTo($this).removeClass('active');
168
+ }
169
+ $$this.prependTo($this).addClass('active');
170
+ $this.removeClass('inprogress');
171
+ });
172
+ });
173
+ };
174
+ if (!$$this.hasClass('active') && !$this.hasClass('inprogress')) {
175
+ $this.addClass('inprogress');
176
+ active.children('h3').animate({
177
+ lineHeight: options.collapsedLineHeight
178
+ }, 750 / speed);
179
+ active.children('.content').animate({
180
+ opacity: 0
181
+ }, 750 / speed);
182
+ active.animate({
183
+ top: (!last) ? $this.height() - options.collapsedHeight - options.collapsedMPB[0] - options.collapsedMPB[2] : 0,
184
+ bottom: (!last) ? 0 : $this.height() - options.collapsedHeight - options.collapsedMPB[0] - options.collapsedMPB[2]
185
+ }, 750 / speed, function() {
186
+ active.css({
187
+ top: (!last) ? $this.height() - active.height() - options.collapsedMPB[0] - options.collapsedMPB[2] : 0,
188
+ height: active.height()
189
+ });
190
+ $$this.css({
191
+ bottom: $this.height() - $$this.position().top - (options.collapsedHeight + options.collapsedMPB[0] + options.collapsedMPB[2]),
192
+ height: 'auto'
193
+ });
194
+ $$this.animate({
195
+ left: 0,
196
+ right: (options.collapsedWidth + options.collapsedMPB[1] + options.collapsedMPB[3])
197
+ }, 500 / speed, function() {
198
+ if (!last) {
199
+ $$this.nextAll('div').each(function() {
200
+ var $$$this = $(this);
201
+ $$$this.animate({
202
+ top: $$$this.position().top - (options.collapsedHeight + options.collapsedMPB[0] + options.collapsedMPB[2])
203
+ }, 750 / speed, function() {
204
+ if (!alreadyCalled) {
205
+ callback();
206
+ }
207
+ alreadyCalled = true;
208
+ });
209
+ });
210
+ }
211
+ else {
212
+ $$this.prevAll('div:not(.active)').each(function() {
213
+ var $$$this = $(this);
214
+ $$$this.animate({
215
+ top: $$$this.position().top + (options.collapsedHeight + options.collapsedMPB[0] + options.collapsedMPB[2])
216
+ }, 750 / speed, function() {
217
+ if (!alreadyCalled) {
218
+ callback();
219
+ }
220
+ alreadyCalled = true;
221
+ });
222
+ });
223
+ }
224
+ });
225
+ });
226
+ }
227
+ });
228
+ }
229
+ });
230
+ }
231
+ });
232
+ }(jQuery));
233
+ })
@@ -0,0 +1,12 @@
1
+ /*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
2
+ * Licensed under the MIT License (LICENSE.txt).
3
+ *
4
+ * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
5
+ * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
6
+ * Thanks to: Seamus Leahy for adding deltaX and deltaY
7
+ *
8
+ * Version: 3.0.6
9
+ *
10
+ * Requires: 1.2.2+
11
+ */
12
+ (function(a){function d(b){var c=b||window.event,d=[].slice.call(arguments,1),e=0,f=!0,g=0,h=0;return b=a.event.fix(c),b.type="mousewheel",c.wheelDelta&&(e=c.wheelDelta/120),c.detail&&(e=-c.detail/3),h=e,c.axis!==undefined&&c.axis===c.HORIZONTAL_AXIS&&(h=0,g=-1*e),c.wheelDeltaY!==undefined&&(h=c.wheelDeltaY/120),c.wheelDeltaX!==undefined&&(g=-1*c.wheelDeltaX/120),d.unshift(b,e,g,h),(a.event.dispatch||a.event.handle).apply(this,d)}var b=["DOMMouseScroll","mousewheel"];if(a.event.fixHooks)for(var c=b.length;c;)a.event.fixHooks[b[--c]]=a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=b.length;a;)this.addEventListener(b[--a],d,!1);else this.onmousewheel=d},teardown:function(){if(this.removeEventListener)for(var a=b.length;a;)this.removeEventListener(b[--a],d,!1);else this.onmousewheel=null}},a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery)
@@ -0,0 +1,202 @@
1
+ /*
2
+ * jQuery pageSlide
3
+ * Version 2.0
4
+ * http://srobbin.com/jquery-pageslide/
5
+ *
6
+ * jQuery Javascript plugin which slides a webpage over to reveal an additional interaction pane.
7
+ *
8
+ * Copyright (c) 2011 Scott Robbin (srobbin.com)
9
+ * Dual licensed under the MIT and GPL licenses.
10
+ */
11
+
12
+ ;(function($){
13
+ // Convenience vars for accessing elements
14
+ var $body_ps = $('body'),
15
+ $page_slide = $('#pageslide');
16
+
17
+ var _sliding_ps = false, // Mutex to assist closing only once
18
+ _lastCaller_ps; // Used to keep track of last element to trigger pageslide
19
+
20
+ // If the pageslide element doesn't exist, create it
21
+ if( $page_slide.length == 0 ) {
22
+ $page_slide = $('<div />').attr( 'id', 'pageslide' )
23
+ .css( 'display', 'none' )
24
+ .appendTo( $('body') );
25
+ }
26
+
27
+ /*
28
+ * Private methods
29
+ */
30
+ function _load( url, useIframe ) {
31
+ // Are we loading an element from the page or a URL?
32
+ if ( url.indexOf("#") === 0 ) {
33
+ // Load a page element
34
+ $(url).clone(true).appendTo( $page_slide.empty() ).show();
35
+ } else {
36
+ // Load a URL. Into an iframe?
37
+ if( useIframe ) {
38
+ var iframe = $("<iframe />").attr({
39
+ src: url,
40
+ frameborder: 0,
41
+ hspace: 0
42
+ })
43
+ .css({
44
+ width: "100%",
45
+ height: "100%"
46
+ });
47
+
48
+ $page_slide.html( iframe );
49
+ } else {
50
+ $page_slide.load( url );
51
+ }
52
+
53
+ $page_slide.data( 'localEl', false );
54
+
55
+ }
56
+ }
57
+
58
+ // Function that controls opening of the pageslide
59
+ function _start( direction, speed ) {
60
+ var slideWidth = $page_slide.outerWidth( true ),
61
+ bodyAnimateIn = {},
62
+ slideAnimateIn = {};
63
+
64
+ // If the slide is open or opening, just ignore the call
65
+ if( $page_slide.is(':visible') || _sliding_ps ) return;
66
+ _sliding_ps = true;
67
+
68
+ switch( direction ) {
69
+ case 'left':
70
+ $page_slide.css({ left: 'auto', right: '-' + slideWidth + 'px' });
71
+ bodyAnimateIn['margin-left'] = '-=' + slideWidth;
72
+ slideAnimateIn['right'] = '+=' + slideWidth;
73
+ break;
74
+ default:
75
+ $page_slide.css({ left: '-' + slideWidth + 'px', right: 'auto' });
76
+ bodyAnimateIn['margin-left'] = '+=' + slideWidth;
77
+ slideAnimateIn['left'] = '+=' + slideWidth;
78
+ break;
79
+ }
80
+
81
+ // Animate the slide, and attach this slide's settings to the element
82
+ $body_ps.animate(bodyAnimateIn, speed);
83
+ $page_slide.show()
84
+ .animate(slideAnimateIn, speed, function() {
85
+ _sliding_ps = false;
86
+ });
87
+ }
88
+
89
+ /*
90
+ * Declaration
91
+ */
92
+ $.fn.pageslide = function(options) {
93
+ var $elements = this;
94
+
95
+ // On click
96
+ $elements.click( function(e) {
97
+ var $self = $(this),
98
+ settings = $.extend({ href: $self.attr('href') }, options);
99
+
100
+ // Prevent the default behavior and stop propagation
101
+ e.preventDefault();
102
+ e.stopPropagation();
103
+
104
+ if ( $page_slide.is(':visible') && $self[0] == _lastCaller_ps ) {
105
+ // If we clicked the same element twice, toggle closed
106
+ $.pageslide.close();
107
+ } else {
108
+ // Open
109
+ $.pageslide( settings );
110
+
111
+ // Record the last element to trigger pageslide
112
+ _lastCaller_ps = $self[0];
113
+ }
114
+ });
115
+ };
116
+
117
+ /*
118
+ * Default settings
119
+ */
120
+ $.fn.pageslide.defaults = {
121
+ speed: 200, // Accepts standard jQuery effects speeds (i.e. fast, normal or milliseconds)
122
+ direction: 'right', // Accepts 'left' or 'right'
123
+ modal: false, // If set to true, you must explicitly close pageslide using $.pageslide.close();
124
+ iframe: true, // By default, linked pages are loaded into an iframe. Set this to false if you don't want an iframe.
125
+ href: null // Override the source of the content. Optional in most cases, but required when opening pageslide programmatically.
126
+ };
127
+
128
+ /*
129
+ * Public methods
130
+ */
131
+
132
+ // Open the pageslide
133
+ $.pageslide = function(options) {
134
+ // Extend the settings with those the user has provided
135
+ var settings = $.extend({}, $.fn.pageslide.defaults, options);
136
+
137
+ // Are we trying to open in different direction?
138
+ if ($page_slide.is(':visible') && $page_slide.data('direction') != settings.direction) {
139
+ $.pageslide.close(function() {
140
+ _load(settings.href, settings.iframe);
141
+ _start(settings.direction, settings.speed);
142
+ });
143
+ } else {
144
+ _load(settings.href, settings.iframe);
145
+ if ($page_slide.is(':hidden')) {
146
+ _start(settings.direction, settings.speed);
147
+ }
148
+ }
149
+
150
+ $page_slide.data(settings);
151
+ };
152
+
153
+ // Close the pageslide
154
+ $.pageslide.close = function(callback) {
155
+ var $page_slide = $('#pageslide'),
156
+ slideWidth = $page_slide.outerWidth(true),
157
+ speed = $page_slide.data('speed'),
158
+ bodyAnimateIn = {},
159
+ slideAnimateIn = {};
160
+
161
+ // If the slide isn't open, just ignore the call
162
+ if ($page_slide.is(':hidden') || _sliding_ps) return;
163
+ _sliding_ps = true;
164
+
165
+ switch ($page_slide.data('direction')) {
166
+ case 'left':
167
+ bodyAnimateIn['margin-left'] = '+=' + slideWidth;
168
+ slideAnimateIn['right'] = '-=' + slideWidth;
169
+ break;
170
+ default:
171
+ bodyAnimateIn['margin-left'] = '-=' + slideWidth;
172
+ slideAnimateIn['left'] = '-=' + slideWidth;
173
+ break;
174
+ }
175
+
176
+ $page_slide.animate(slideAnimateIn, speed);
177
+ $body_ps.animate(bodyAnimateIn, speed, function() {
178
+ $page_slide.hide();
179
+ _sliding_ps = false;
180
+ if (typeof callback != 'undefined') callback();
181
+ });
182
+ };
183
+
184
+ /* Events */
185
+
186
+ // Don't let clicks to the pageslide close the window
187
+ $page_slide.click(function(e) {
188
+ e.stopPropagation();
189
+ });
190
+
191
+ // Close the pageslide if the document is clicked or the users presses the ESC key, unless the pageslide is modal
192
+ $(document).bind('click keyup', function(e) {
193
+ // If this is a keyup event, let's see if it's an ESC key
194
+ if( e.type == "keyup" && e.keyCode != 27) return;
195
+
196
+ // Make sure it's visible, and we're not modal
197
+ if( $page_slide.is( ':visible' ) && !$page_slide.data( 'modal' ) ) {
198
+ $.pageslide.close();
199
+ }
200
+ });
201
+
202
+ })(jQuery);