vex_rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.un~
19
+ *.DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vex_rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Robbie Marcelo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # VexRails
2
+
3
+ A ruby gem for your asset pipeline which includes hubspot's awesome [vex] library.
4
+
5
+ Vex is a modern dialog library which is highly configurable, easily stylable, and gets out of the way. You'll love vex because it's tiny (6kb minified, 2kb minifed + gzipped), has a clear and simple API, works on mobile devices, and can be customized to match your style in seconds.
6
+
7
+ ## Features
8
+
9
+ + Drop-in replacement for alert, confirm, and prompt
10
+ + Easilly configurable animations which are smooth as butter
11
+ + Tiny footprint (6kb minified) and only depends on jQuery
12
+ + Looks and behaves great on mobile devices
13
+ + Open multiple dialogs at once and close them individually or all at once
14
+ + Built in CSS spinner for asynchronous dialogs
15
+ + AMD support
16
+
17
+ ## Requirements
18
+
19
+ + jQuery
20
+
21
+ ## Browser Support
22
+
23
+ + IE8+
24
+ + Firefox 4+
25
+ + Current WebKit (Chrome, Safari)
26
+ + Opera
27
+
28
+ ## Installation
29
+
30
+ Add this line to your application's Gemfile:
31
+
32
+ gem 'vex_rails'
33
+
34
+ And then execute:
35
+
36
+ $ bundle
37
+
38
+ Or install it yourself as:
39
+
40
+ $ gem install vex_rails
41
+
42
+ ## Usage
43
+
44
+ Lets get started!
45
+
46
+ # In your application.js
47
+
48
+ //= require vex.combined.min.js
49
+
50
+ vex.defaultOptions.className = 'vex-theme-os';
51
+
52
+ # In your application.css
53
+
54
+ *= require vex.css
55
+ *= require vex-theme-os.css
56
+
57
+ That will give you all of the APIs for both Vex and Vex Dialog, and set you up with the "Operating System" theme. If you'd prefer another theme, check out [Themes].
58
+
59
+ Test it up on your browser's console:
60
+
61
+ vex.defaultOptions.className = 'vex-theme-os';
62
+ vex.dialog.alert({
63
+ message: 'Testing the wireframe theme.'
64
+ });
65
+
66
+ See Hubspot's [documentation] for more details.
67
+
68
+ ## Contributing
69
+
70
+ 1. Fork it
71
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
72
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
73
+ 4. Push to the branch (`git push origin my-new-feature`)
74
+ 5. Create new Pull Request
75
+
76
+ ## License
77
+
78
+ MIT License. Copyright (c) 2013 Robbie Marcelo, see [LICENSE] for full details.
79
+
80
+
81
+ [documentation]: http://github.hubspot.com/vex/
82
+ [vex]: https://github.com/HubSpot/vex/
83
+ [Themes]: http://github.hubspot.com/vex/api/themes/
84
+ [LICENSE]: http://github.com/rbmrclo/vex_rails/blob/master/LICENSE.txt
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ /*! vex.js, vex.dialog.js 1.3.1 */
2
+ (function(){var a;a=function(a){var b,c;return b=!1,a(function(){var d;return d=(document.body||document.documentElement).style,b=void 0!==d.animation||void 0!==d.WebkitAnimation||void 0!==d.MozAnimation||void 0!==d.MsAnimation||void 0!==d.OAnimation,a(window).bind("keyup.vex",function(a){return 27===a.keyCode?c.closeByEscape():void 0})}),c={globalID:1,animationEndEvent:"animationend webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend",baseClassNames:{vex:"vex",content:"vex-content",overlay:"vex-overlay",close:"vex-close",closing:"vex-closing"},defaultOptions:{content:"",showCloseButton:!0,escapeButtonCloses:!0,overlayClosesOnClick:!0,appendLocation:"body",className:"",css:{},overlayClassName:"",overlayCSS:{},contentClassName:"",contentCSS:{},closeClassName:"",closeCSS:{}},open:function(b){return b=a.extend({},c.defaultOptions,b),b.id=c.globalID,c.globalID+=1,b.$vex=a("<div>").addClass(c.baseClassNames.vex).addClass(b.className).css(b.css).data({vex:b}),b.$vexOverlay=a("<div>").addClass(c.baseClassNames.overlay).addClass(b.overlayClassName).css(b.overlayCSS).data({vex:b}),b.overlayClosesOnClick&&b.$vexOverlay.bind("click.vex",function(b){return b.target===this?c.close(a(this).data().vex.id):void 0}),b.$vex.append(b.$vexOverlay),b.$vexContent=a("<div>").addClass(c.baseClassNames.content).addClass(b.contentClassName).css(b.contentCSS).append(b.content).data({vex:b}),b.$vex.append(b.$vexContent),b.showCloseButton&&(b.$closeButton=a("<div>").addClass(c.baseClassNames.close).addClass(b.closeClassName).css(b.closeCSS).data({vex:b}).bind("click.vex",function(){return c.close(a(this).data().vex.id)}),b.$vexContent.append(b.$closeButton)),a(b.appendLocation).append(b.$vex),b.afterOpen&&b.afterOpen(b.$vexContent,b),setTimeout(function(){return b.$vexContent.trigger("vexOpen",b)},0),b.$vexContent},getAllVexes:function(){return a("."+c.baseClassNames.vex+':not(".'+c.baseClassNames.closing+'") .'+c.baseClassNames.content)},getVexByID:function(b){return c.getAllVexes().filter(function(){return a(this).data().vex.id===b})},close:function(a){var b;if(!a){if(b=c.getAllVexes().last(),!b.length)return!1;a=b.data().vex.id}return c.closeByID(a)},closeAll:function(){var b;return b=c.getAllVexes().map(function(){return a(this).data().vex.id}).toArray(),(null!=b?b.length:void 0)?(a.each(b.reverse(),function(a,b){return c.closeByID(b)}),!0):!1},closeByID:function(d){var e,f,g,h,i;return f=c.getVexByID(d),f.length?(e=f.data().vex.$vex,i=a.extend({},f.data().vex),g=function(){return i.beforeClose?i.beforeClose(f,i):void 0},h=function(){return f.trigger("vexClose",i),e.remove(),i.afterClose?i.afterClose(f,i):void 0},b?(g(),e.unbind(c.animationEndEvent).bind(c.animationEndEvent,function(){return h()}).addClass(c.baseClassNames.closing)):(g(),h()),!0):void 0},closeByEscape:function(){var b,d,e;return e=c.getAllVexes().map(function(){return a(this).data().vex.id}).toArray(),(null!=e?e.length:void 0)?(d=Math.max.apply(Math,e),b=c.getVexByID(d),b.data().vex.escapeButtonCloses!==!0?!1:c.closeByID(d)):!1},hideLoading:function(){return a(".vex-loading-spinner").remove()},showLoading:function(){return c.hideLoading(),a("body").append('<div class="vex-loading-spinner '+c.defaultOptions.className+'"></div>')}}},"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):window.vex=a(jQuery)}).call(this),function(){var a;a=function(a,b){var c,d;return null==b?a.error("Vex is required to use vex.dialog"):(c=function(b){var c;return c={},a.each(b.serializeArray(),function(){return c[this.name]?(c[this.name].push||(c[this.name]=[c[this.name]]),c[this.name].push(this.value||"")):c[this.name]=this.value||""}),c},d={},d.buttons={YES:{text:"OK",type:"submit",className:"vex-dialog-button-primary"},NO:{text:"Cancel",type:"button",className:"vex-dialog-button-secondary",click:function(a){return a.data().vex.value=!1,b.close(a.data().vex.id)}}},d.defaultOptions={callback:function(a){return console&&console.log?console.log("Vex dialog callback:",a):void 0},afterOpen:function(){},message:"Message",input:'<input name="vex" type="hidden" value="_vex-empty-value" />',value:!1,buttons:[d.buttons.YES,d.buttons.NO],showCloseButton:!1,onSubmit:function(e){var f,g;return f=a(this),g=f.parent(),e.preventDefault(),e.stopPropagation(),g.data().vex.value=d.getFormValueOnSubmit(c(f)),b.close(g.data().vex.id)},focusFirstInput:!0},d.defaultAlertOptions={message:"Alert",buttons:[d.buttons.YES]},d.defaultConfirmOptions={message:"Confirm"},d.open=function(c){var e;return c=a.extend({},b.defaultOptions,d.defaultOptions,c),c.content=d.buildDialogForm(c),c.beforeClose=function(a){return c.callback(a.data().vex.value)},e=b.open(c),c.focusFirstInput&&e.find('input[type="text"], input[type="submit"]').first().focus(),e},d.alert=function(b){return"string"==typeof b&&(b={message:b}),b=a.extend({},d.defaultAlertOptions,b),d.open(b)},d.confirm=function(b){return"string"==typeof b?a.error("dialog.confirm(options) requires options.callback."):(b=a.extend({},d.defaultConfirmOptions,b),d.open(b))},d.prompt=function(b){var c;return"string"==typeof b?a.error("dialog.prompt(options) requires options.callback."):(c={message:'<label for="vex">'+(b.label||"Prompt:")+"</label>",input:'<input name="vex" type="text" class="vex-dialog-prompt-input" placeholder="'+(b.placeholder||"")+'" />'},b=a.extend({},c,b),d.open(b))},d.buildDialogForm=function(b){var c,e,f;return c=a('<form class="vex-dialog-form" />'),f=a('<div class="vex-dialog-message" />'),e=a('<div class="vex-dialog-input" />'),c.append(f.append(b.message)).append(e.append(b.input)).append(d.buttonsToDOM(b.buttons)).bind("submit.vex",b.onSubmit),c},d.getFormValueOnSubmit=function(a){return a.vex?"_vex-empty-value"===a.vex?!0:a.vex:a},d.buttonsToDOM=function(c){var d;return d=a('<div class="vex-dialog-buttons" />'),a.each(c,function(e,f){return d.append(a('<input type="'+f.type+'" />').val(f.text).addClass(f.className+" vex-dialog-button "+(0===e?"vex-first ":"")+(e===c.length-1?"vex-last ":"")).bind("click.vex",function(c){return f.click?f.click(a(this).parents("."+b.baseClassNames.content),c):void 0}))}),d},d)},"function"==typeof define&&define.amd?define(["jquery","vex"],a):"object"==typeof exports?module.exports=a(require("jquery"),require("vex")):window.vex.dialog=a(window.jQuery,window.vex)}.call(this);
@@ -0,0 +1,153 @@
1
+ (function() {
2
+ var vexDialogFactory;
3
+
4
+ vexDialogFactory = function($, vex) {
5
+ var $formToObject, dialog;
6
+ if (vex == null) {
7
+ return $.error('Vex is required to use vex.dialog');
8
+ }
9
+ $formToObject = function($form) {
10
+ var object;
11
+ object = {};
12
+ $.each($form.serializeArray(), function() {
13
+ if (object[this.name]) {
14
+ if (!object[this.name].push) {
15
+ object[this.name] = [object[this.name]];
16
+ }
17
+ return object[this.name].push(this.value || '');
18
+ } else {
19
+ return object[this.name] = this.value || '';
20
+ }
21
+ });
22
+ return object;
23
+ };
24
+ dialog = {};
25
+ dialog.buttons = {
26
+ YES: {
27
+ text: 'OK',
28
+ type: 'submit',
29
+ className: 'vex-dialog-button-primary'
30
+ },
31
+ NO: {
32
+ text: 'Cancel',
33
+ type: 'button',
34
+ className: 'vex-dialog-button-secondary',
35
+ click: function($vexContent, event) {
36
+ $vexContent.data().vex.value = false;
37
+ return vex.close($vexContent.data().vex.id);
38
+ }
39
+ }
40
+ };
41
+ dialog.defaultOptions = {
42
+ callback: function(value) {
43
+ if (console && console.log) {
44
+ return console.log('Vex dialog callback:', value);
45
+ }
46
+ },
47
+ afterOpen: function() {},
48
+ message: 'Message',
49
+ input: "<input name=\"vex\" type=\"hidden\" value=\"_vex-empty-value\" />",
50
+ value: false,
51
+ buttons: [dialog.buttons.YES, dialog.buttons.NO],
52
+ showCloseButton: false,
53
+ onSubmit: function(event) {
54
+ var $form, $vexContent;
55
+ $form = $(this);
56
+ $vexContent = $form.parent();
57
+ event.preventDefault();
58
+ event.stopPropagation();
59
+ $vexContent.data().vex.value = dialog.getFormValueOnSubmit($formToObject($form));
60
+ return vex.close($vexContent.data().vex.id);
61
+ },
62
+ focusFirstInput: true
63
+ };
64
+ dialog.defaultAlertOptions = {
65
+ message: 'Alert',
66
+ buttons: [dialog.buttons.YES]
67
+ };
68
+ dialog.defaultConfirmOptions = {
69
+ message: 'Confirm'
70
+ };
71
+ dialog.open = function(options) {
72
+ var $vexContent;
73
+ options = $.extend({}, vex.defaultOptions, dialog.defaultOptions, options);
74
+ options.content = dialog.buildDialogForm(options);
75
+ options.beforeClose = function($vexContent) {
76
+ return options.callback($vexContent.data().vex.value);
77
+ };
78
+ $vexContent = vex.open(options);
79
+ if (options.focusFirstInput) {
80
+ $vexContent.find('input[type="text"], input[type="submit"]').first().focus();
81
+ }
82
+ return $vexContent;
83
+ };
84
+ dialog.alert = function(options) {
85
+ if (typeof options === 'string') {
86
+ options = {
87
+ message: options
88
+ };
89
+ }
90
+ options = $.extend({}, dialog.defaultAlertOptions, options);
91
+ return dialog.open(options);
92
+ };
93
+ dialog.confirm = function(options) {
94
+ if (typeof options === 'string') {
95
+ return $.error('dialog.confirm(options) requires options.callback.');
96
+ }
97
+ options = $.extend({}, dialog.defaultConfirmOptions, options);
98
+ return dialog.open(options);
99
+ };
100
+ dialog.prompt = function(options) {
101
+ var defaultPromptOptions;
102
+ if (typeof options === 'string') {
103
+ return $.error('dialog.prompt(options) requires options.callback.');
104
+ }
105
+ defaultPromptOptions = {
106
+ message: "<label for=\"vex\">" + (options.label || 'Prompt:') + "</label>",
107
+ input: "<input name=\"vex\" type=\"text\" class=\"vex-dialog-prompt-input\" placeholder=\"" + (options.placeholder || '') + "\" />"
108
+ };
109
+ options = $.extend({}, defaultPromptOptions, options);
110
+ return dialog.open(options);
111
+ };
112
+ dialog.buildDialogForm = function(options) {
113
+ var $form, $input, $message;
114
+ $form = $('<form class="vex-dialog-form" />');
115
+ $message = $('<div class="vex-dialog-message" />');
116
+ $input = $('<div class="vex-dialog-input" />');
117
+ $form.append($message.append(options.message)).append($input.append(options.input)).append(dialog.buttonsToDOM(options.buttons)).bind('submit.vex', options.onSubmit);
118
+ return $form;
119
+ };
120
+ dialog.getFormValueOnSubmit = function(formData) {
121
+ if (formData.vex) {
122
+ if (formData.vex === '_vex-empty-value') {
123
+ return true;
124
+ }
125
+ return formData.vex;
126
+ } else {
127
+ return formData;
128
+ }
129
+ };
130
+ dialog.buttonsToDOM = function(buttons) {
131
+ var $buttons;
132
+ $buttons = $('<div class="vex-dialog-buttons" />');
133
+ $.each(buttons, function(index, button) {
134
+ return $buttons.append($("<input type=\"" + button.type + "\" />").val(button.text).addClass(button.className + ' vex-dialog-button ' + (index === 0 ? 'vex-first ' : '') + (index === buttons.length - 1 ? 'vex-last ' : '')).bind('click.vex', function(e) {
135
+ if (button.click) {
136
+ return button.click($(this).parents("." + vex.baseClassNames.content), e);
137
+ }
138
+ }));
139
+ });
140
+ return $buttons;
141
+ };
142
+ return dialog;
143
+ };
144
+
145
+ if (typeof define === 'function' && define.amd) {
146
+ define(['jquery', 'vex'], vexDialogFactory);
147
+ } else if (typeof exports === 'object') {
148
+ module.exports = vexDialogFactory(require('jquery'), require('vex'));
149
+ } else {
150
+ window.vex.dialog = vexDialogFactory(window.jQuery, window.vex);
151
+ }
152
+
153
+ }).call(this);
@@ -0,0 +1,2 @@
1
+ /*! vex.dialog.js 1.3.1 */
2
+ (function(){var a;a=function(a,b){var c,d;return null==b?a.error("Vex is required to use vex.dialog"):(c=function(b){var c;return c={},a.each(b.serializeArray(),function(){return c[this.name]?(c[this.name].push||(c[this.name]=[c[this.name]]),c[this.name].push(this.value||"")):c[this.name]=this.value||""}),c},d={},d.buttons={YES:{text:"OK",type:"submit",className:"vex-dialog-button-primary"},NO:{text:"Cancel",type:"button",className:"vex-dialog-button-secondary",click:function(a){return a.data().vex.value=!1,b.close(a.data().vex.id)}}},d.defaultOptions={callback:function(a){return console&&console.log?console.log("Vex dialog callback:",a):void 0},afterOpen:function(){},message:"Message",input:'<input name="vex" type="hidden" value="_vex-empty-value" />',value:!1,buttons:[d.buttons.YES,d.buttons.NO],showCloseButton:!1,onSubmit:function(e){var f,g;return f=a(this),g=f.parent(),e.preventDefault(),e.stopPropagation(),g.data().vex.value=d.getFormValueOnSubmit(c(f)),b.close(g.data().vex.id)},focusFirstInput:!0},d.defaultAlertOptions={message:"Alert",buttons:[d.buttons.YES]},d.defaultConfirmOptions={message:"Confirm"},d.open=function(c){var e;return c=a.extend({},b.defaultOptions,d.defaultOptions,c),c.content=d.buildDialogForm(c),c.beforeClose=function(a){return c.callback(a.data().vex.value)},e=b.open(c),c.focusFirstInput&&e.find('input[type="text"], input[type="submit"]').first().focus(),e},d.alert=function(b){return"string"==typeof b&&(b={message:b}),b=a.extend({},d.defaultAlertOptions,b),d.open(b)},d.confirm=function(b){return"string"==typeof b?a.error("dialog.confirm(options) requires options.callback."):(b=a.extend({},d.defaultConfirmOptions,b),d.open(b))},d.prompt=function(b){var c;return"string"==typeof b?a.error("dialog.prompt(options) requires options.callback."):(c={message:'<label for="vex">'+(b.label||"Prompt:")+"</label>",input:'<input name="vex" type="text" class="vex-dialog-prompt-input" placeholder="'+(b.placeholder||"")+'" />'},b=a.extend({},c,b),d.open(b))},d.buildDialogForm=function(b){var c,e,f;return c=a('<form class="vex-dialog-form" />'),f=a('<div class="vex-dialog-message" />'),e=a('<div class="vex-dialog-input" />'),c.append(f.append(b.message)).append(e.append(b.input)).append(d.buttonsToDOM(b.buttons)).bind("submit.vex",b.onSubmit),c},d.getFormValueOnSubmit=function(a){return a.vex?"_vex-empty-value"===a.vex?!0:a.vex:a},d.buttonsToDOM=function(c){var d;return d=a('<div class="vex-dialog-buttons" />'),a.each(c,function(e,f){return d.append(a('<input type="'+f.type+'" />').val(f.text).addClass(f.className+" vex-dialog-button "+(0===e?"vex-first ":"")+(e===c.length-1?"vex-last ":"")).bind("click.vex",function(c){return f.click?f.click(a(this).parents("."+b.baseClassNames.content),c):void 0}))}),d},d)},"function"==typeof define&&define.amd?define(["jquery","vex"],a):"object"==typeof exports?module.exports=a(require("jquery"),require("vex")):window.vex.dialog=a(window.jQuery,window.vex)}).call(this);
@@ -0,0 +1,178 @@
1
+ (function() {
2
+ var vexFactory;
3
+
4
+ vexFactory = function($) {
5
+ var animationEndSupport, vex;
6
+ animationEndSupport = false;
7
+ $(function() {
8
+ var s;
9
+ s = (document.body || document.documentElement).style;
10
+ animationEndSupport = s.animation !== void 0 || s.WebkitAnimation !== void 0 || s.MozAnimation !== void 0 || s.MsAnimation !== void 0 || s.OAnimation !== void 0;
11
+ return $(window).bind('keyup.vex', function(event) {
12
+ if (event.keyCode === 27) {
13
+ return vex.closeByEscape();
14
+ }
15
+ });
16
+ });
17
+ return vex = {
18
+ globalID: 1,
19
+ animationEndEvent: 'animationend webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend',
20
+ baseClassNames: {
21
+ vex: 'vex',
22
+ content: 'vex-content',
23
+ overlay: 'vex-overlay',
24
+ close: 'vex-close',
25
+ closing: 'vex-closing'
26
+ },
27
+ defaultOptions: {
28
+ content: '',
29
+ showCloseButton: true,
30
+ escapeButtonCloses: true,
31
+ overlayClosesOnClick: true,
32
+ appendLocation: 'body',
33
+ className: '',
34
+ css: {},
35
+ overlayClassName: '',
36
+ overlayCSS: {},
37
+ contentClassName: '',
38
+ contentCSS: {},
39
+ closeClassName: '',
40
+ closeCSS: {}
41
+ },
42
+ open: function(options) {
43
+ options = $.extend({}, vex.defaultOptions, options);
44
+ options.id = vex.globalID;
45
+ vex.globalID += 1;
46
+ options.$vex = $('<div>').addClass(vex.baseClassNames.vex).addClass(options.className).css(options.css).data({
47
+ vex: options
48
+ });
49
+ options.$vexOverlay = $('<div>').addClass(vex.baseClassNames.overlay).addClass(options.overlayClassName).css(options.overlayCSS).data({
50
+ vex: options
51
+ });
52
+ if (options.overlayClosesOnClick) {
53
+ options.$vexOverlay.bind('click.vex', function(e) {
54
+ if (e.target !== this) {
55
+ return;
56
+ }
57
+ return vex.close($(this).data().vex.id);
58
+ });
59
+ }
60
+ options.$vex.append(options.$vexOverlay);
61
+ options.$vexContent = $('<div>').addClass(vex.baseClassNames.content).addClass(options.contentClassName).css(options.contentCSS).append(options.content).data({
62
+ vex: options
63
+ });
64
+ options.$vex.append(options.$vexContent);
65
+ if (options.showCloseButton) {
66
+ options.$closeButton = $('<div>').addClass(vex.baseClassNames.close).addClass(options.closeClassName).css(options.closeCSS).data({
67
+ vex: options
68
+ }).bind('click.vex', function() {
69
+ return vex.close($(this).data().vex.id);
70
+ });
71
+ options.$vexContent.append(options.$closeButton);
72
+ }
73
+ $(options.appendLocation).append(options.$vex);
74
+ if (options.afterOpen) {
75
+ options.afterOpen(options.$vexContent, options);
76
+ }
77
+ setTimeout((function() {
78
+ return options.$vexContent.trigger('vexOpen', options);
79
+ }), 0);
80
+ return options.$vexContent;
81
+ },
82
+ getAllVexes: function() {
83
+ return $("." + vex.baseClassNames.vex + ":not(\"." + vex.baseClassNames.closing + "\") ." + vex.baseClassNames.content);
84
+ },
85
+ getVexByID: function(id) {
86
+ return vex.getAllVexes().filter(function() {
87
+ return $(this).data().vex.id === id;
88
+ });
89
+ },
90
+ close: function(id) {
91
+ var $lastVex;
92
+ if (!id) {
93
+ $lastVex = vex.getAllVexes().last();
94
+ if (!$lastVex.length) {
95
+ return false;
96
+ }
97
+ id = $lastVex.data().vex.id;
98
+ }
99
+ return vex.closeByID(id);
100
+ },
101
+ closeAll: function() {
102
+ var ids;
103
+ ids = vex.getAllVexes().map(function() {
104
+ return $(this).data().vex.id;
105
+ }).toArray();
106
+ if (!(ids != null ? ids.length : void 0)) {
107
+ return false;
108
+ }
109
+ $.each(ids.reverse(), function(index, id) {
110
+ return vex.closeByID(id);
111
+ });
112
+ return true;
113
+ },
114
+ closeByID: function(id) {
115
+ var $vex, $vexContent, beforeClose, close, options;
116
+ $vexContent = vex.getVexByID(id);
117
+ if (!$vexContent.length) {
118
+ return;
119
+ }
120
+ $vex = $vexContent.data().vex.$vex;
121
+ options = $.extend({}, $vexContent.data().vex);
122
+ beforeClose = function() {
123
+ if (options.beforeClose) {
124
+ return options.beforeClose($vexContent, options);
125
+ }
126
+ };
127
+ close = function() {
128
+ $vexContent.trigger('vexClose', options);
129
+ $vex.remove();
130
+ if (options.afterClose) {
131
+ return options.afterClose($vexContent, options);
132
+ }
133
+ };
134
+ if (animationEndSupport) {
135
+ beforeClose();
136
+ $vex.unbind(vex.animationEndEvent).bind(vex.animationEndEvent, function() {
137
+ return close();
138
+ }).addClass(vex.baseClassNames.closing);
139
+ } else {
140
+ beforeClose();
141
+ close();
142
+ }
143
+ return true;
144
+ },
145
+ closeByEscape: function() {
146
+ var $lastVex, id, ids;
147
+ ids = vex.getAllVexes().map(function() {
148
+ return $(this).data().vex.id;
149
+ }).toArray();
150
+ if (!(ids != null ? ids.length : void 0)) {
151
+ return false;
152
+ }
153
+ id = Math.max.apply(Math, ids);
154
+ $lastVex = vex.getVexByID(id);
155
+ if ($lastVex.data().vex.escapeButtonCloses !== true) {
156
+ return false;
157
+ }
158
+ return vex.closeByID(id);
159
+ },
160
+ hideLoading: function() {
161
+ return $('.vex-loading-spinner').remove();
162
+ },
163
+ showLoading: function() {
164
+ vex.hideLoading();
165
+ return $('body').append("<div class=\"vex-loading-spinner " + vex.defaultOptions.className + "\"></div>");
166
+ }
167
+ };
168
+ };
169
+
170
+ if (typeof define === 'function' && define.amd) {
171
+ define(['jquery'], vexFactory);
172
+ } else if (typeof exports === 'object') {
173
+ module.exports = vexFactory(require('jquery'));
174
+ } else {
175
+ window.vex = vexFactory(jQuery);
176
+ }
177
+
178
+ }).call(this);
@@ -0,0 +1,2 @@
1
+ /*! vex.js 1.3.1 */
2
+ (function(){var a;a=function(a){var b,c;return b=!1,a(function(){var d;return d=(document.body||document.documentElement).style,b=void 0!==d.animation||void 0!==d.WebkitAnimation||void 0!==d.MozAnimation||void 0!==d.MsAnimation||void 0!==d.OAnimation,a(window).bind("keyup.vex",function(a){return 27===a.keyCode?c.closeByEscape():void 0})}),c={globalID:1,animationEndEvent:"animationend webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend",baseClassNames:{vex:"vex",content:"vex-content",overlay:"vex-overlay",close:"vex-close",closing:"vex-closing"},defaultOptions:{content:"",showCloseButton:!0,escapeButtonCloses:!0,overlayClosesOnClick:!0,appendLocation:"body",className:"",css:{},overlayClassName:"",overlayCSS:{},contentClassName:"",contentCSS:{},closeClassName:"",closeCSS:{}},open:function(b){return b=a.extend({},c.defaultOptions,b),b.id=c.globalID,c.globalID+=1,b.$vex=a("<div>").addClass(c.baseClassNames.vex).addClass(b.className).css(b.css).data({vex:b}),b.$vexOverlay=a("<div>").addClass(c.baseClassNames.overlay).addClass(b.overlayClassName).css(b.overlayCSS).data({vex:b}),b.overlayClosesOnClick&&b.$vexOverlay.bind("click.vex",function(b){return b.target===this?c.close(a(this).data().vex.id):void 0}),b.$vex.append(b.$vexOverlay),b.$vexContent=a("<div>").addClass(c.baseClassNames.content).addClass(b.contentClassName).css(b.contentCSS).append(b.content).data({vex:b}),b.$vex.append(b.$vexContent),b.showCloseButton&&(b.$closeButton=a("<div>").addClass(c.baseClassNames.close).addClass(b.closeClassName).css(b.closeCSS).data({vex:b}).bind("click.vex",function(){return c.close(a(this).data().vex.id)}),b.$vexContent.append(b.$closeButton)),a(b.appendLocation).append(b.$vex),b.afterOpen&&b.afterOpen(b.$vexContent,b),setTimeout(function(){return b.$vexContent.trigger("vexOpen",b)},0),b.$vexContent},getAllVexes:function(){return a("."+c.baseClassNames.vex+':not(".'+c.baseClassNames.closing+'") .'+c.baseClassNames.content)},getVexByID:function(b){return c.getAllVexes().filter(function(){return a(this).data().vex.id===b})},close:function(a){var b;if(!a){if(b=c.getAllVexes().last(),!b.length)return!1;a=b.data().vex.id}return c.closeByID(a)},closeAll:function(){var b;return b=c.getAllVexes().map(function(){return a(this).data().vex.id}).toArray(),(null!=b?b.length:void 0)?(a.each(b.reverse(),function(a,b){return c.closeByID(b)}),!0):!1},closeByID:function(d){var e,f,g,h,i;return f=c.getVexByID(d),f.length?(e=f.data().vex.$vex,i=a.extend({},f.data().vex),g=function(){return i.beforeClose?i.beforeClose(f,i):void 0},h=function(){return f.trigger("vexClose",i),e.remove(),i.afterClose?i.afterClose(f,i):void 0},b?(g(),e.unbind(c.animationEndEvent).bind(c.animationEndEvent,function(){return h()}).addClass(c.baseClassNames.closing)):(g(),h()),!0):void 0},closeByEscape:function(){var b,d,e;return e=c.getAllVexes().map(function(){return a(this).data().vex.id}).toArray(),(null!=e?e.length:void 0)?(d=Math.max.apply(Math,e),b=c.getVexByID(d),b.data().vex.escapeButtonCloses!==!0?!1:c.closeByID(d)):!1},hideLoading:function(){return a(".vex-loading-spinner").remove()},showLoading:function(){return c.hideLoading(),a("body").append('<div class="vex-loading-spinner '+c.defaultOptions.className+'"></div>')}}},"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):window.vex=a(jQuery)}).call(this);