humongous 0.1.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/VERSION +1 -0
- data/bin/humongous +13 -0
- data/lib/humongous/application.rb +103 -0
- data/lib/humongous/public/images/favicon.ico +0 -0
- data/lib/humongous/public/javascripts/application.js +122 -0
- data/lib/humongous/public/javascripts/bootstrap-modal.js +260 -0
- data/lib/humongous/public/javascripts/core.js +60 -0
- data/lib/humongous/public/javascripts/jquery.min.js +4 -0
- data/lib/humongous/public/javascripts/jquery.nohtml.js +111 -0
- data/lib/humongous/public/javascripts/query_browser.js +188 -0
- data/lib/humongous/public/javascripts/storage.js +28 -0
- data/lib/humongous/public/styles/application.css +73 -0
- data/lib/humongous/public/styles/bootstrap.min.css +356 -0
- data/lib/humongous/views/index.erb +164 -0
- data/lib/humongous.rb +42 -0
- metadata +132 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Bagwan Pankaj
|
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,19 @@
|
|
1
|
+
= humongous
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to humongous
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2012 bagwanpankaj. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0.pre
|
data/bin/humongous
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
5
|
+
begin
|
6
|
+
require 'vegas'
|
7
|
+
rescue LoadError
|
8
|
+
require 'rubygems'
|
9
|
+
require 'vegas'
|
10
|
+
end
|
11
|
+
require 'humongous'
|
12
|
+
|
13
|
+
Vegas::Runner.new(Humongous::Application, 'humongous')
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module Humongous
|
2
|
+
class Application < Sinatra::Base
|
3
|
+
DEFAULT_OPTIONS = {
|
4
|
+
url: "localhost",
|
5
|
+
port: "27017",
|
6
|
+
username: "",
|
7
|
+
password: ""
|
8
|
+
}
|
9
|
+
|
10
|
+
set :port, 9494
|
11
|
+
|
12
|
+
dir = File.dirname(File.expand_path(__FILE__))
|
13
|
+
|
14
|
+
set :views, "#{dir}/views"
|
15
|
+
|
16
|
+
if respond_to? :public_folder
|
17
|
+
set :public_folder, "#{dir}/public"
|
18
|
+
else
|
19
|
+
set :public, "#{dir}/public"
|
20
|
+
end
|
21
|
+
|
22
|
+
set :static, true
|
23
|
+
|
24
|
+
before do
|
25
|
+
begin
|
26
|
+
@connection = Mongo::Connection.from_uri(get_uri)
|
27
|
+
rescue Mongo::ConnectionFailure => e
|
28
|
+
@is_live = false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
get '/' do
|
33
|
+
@databases = @connection.database_info
|
34
|
+
@server_info = @connection.server_info
|
35
|
+
@header_string = "Server #{@connection.host}:#{@connection.port} stats"
|
36
|
+
erb :index
|
37
|
+
end
|
38
|
+
|
39
|
+
get "/database/:db_name" do
|
40
|
+
@database = @connection.db(params[:db_name])
|
41
|
+
@header_string = "Database #{@database.name} (#{@database.collection_names.size}) stats"
|
42
|
+
content_type :json
|
43
|
+
{ collections: @database.collection_names, stats: @database.stats, header: @header_string }.to_json
|
44
|
+
end
|
45
|
+
|
46
|
+
get "/database/:db_name/collection/:collection_name" do
|
47
|
+
@database = @connection.db(params[:db_name])
|
48
|
+
@collection = @database.collection(params[:collection_name])
|
49
|
+
content_type :json
|
50
|
+
{ stats: @collection.stats, header: "Collection #{@database.name}.#{@collection.name} (#{@collection.stats.count}) stats" }.to_json
|
51
|
+
end
|
52
|
+
|
53
|
+
post "/database/:db_name/collection/:collection_name/page/:page" do
|
54
|
+
default_options = { skip: 0, limit: 10 }
|
55
|
+
default_query_options = {}
|
56
|
+
optionss = {}
|
57
|
+
query = Crack::JSON.parse(params[:query])
|
58
|
+
query_options = default_query_options.merge(query) if !!query
|
59
|
+
optionss[:fields] = params[:fields].split(",").collect(&:strip) unless params[:fields].empty?
|
60
|
+
optionss[:skip] = params[:skip].to_i
|
61
|
+
optionss[:sort] = Crack::JSON.parse(params[:sort])
|
62
|
+
optionss[:limit] = params[:limit].to_i
|
63
|
+
optionss = default_options.merge(optionss)
|
64
|
+
@database = @connection.db(params[:db_name])
|
65
|
+
@collection = @database.collection(params[:collection_name])
|
66
|
+
@records = @collection.find(query_options,optionss).to_a
|
67
|
+
@records.each do |record|
|
68
|
+
record["_id"] = record["_id"].to_s
|
69
|
+
end
|
70
|
+
content_type :json
|
71
|
+
@records.to_json
|
72
|
+
end
|
73
|
+
|
74
|
+
get "/connection_failed" do
|
75
|
+
"<h1>Your Mongo Instance does not seems to be running</h1>"
|
76
|
+
end
|
77
|
+
|
78
|
+
post "/database/:db_name/collection/:collection_name/save" do
|
79
|
+
@database = @connection.db(params[:db_name])
|
80
|
+
@collection = @database.collection(params[:collection_name])
|
81
|
+
doc = params[:doc]
|
82
|
+
doc["_id"] = BSON::ObjectId.from_string(doc["_id"])
|
83
|
+
@collection.save(params[:doc])
|
84
|
+
{ status: "OK", saved: true }.to_json
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def load_defaults
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
def get_uri(params = {})
|
94
|
+
@options = DEFAULT_OPTIONS
|
95
|
+
@options = @options.merge(params)
|
96
|
+
unless @options[:username].empty? && @options[:password].empty?
|
97
|
+
"mongodb://#{@options[:username]}:#{@options[:password]}@#{@options[:url]}:#{@options[:port]}"
|
98
|
+
else
|
99
|
+
"mongodb://#{@options[:url]}:#{@options[:port]}"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
Binary file
|
@@ -0,0 +1,122 @@
|
|
1
|
+
$(document).ready(function(){
|
2
|
+
$('.database_list a').click( function( e ){
|
3
|
+
$.ajax({
|
4
|
+
url: e.target,
|
5
|
+
success: function( data ){
|
6
|
+
console.log(data)
|
7
|
+
if( data && data.header ) app.helpers.header( data.header, false );
|
8
|
+
app.storage.set("database", $(e.target).text());
|
9
|
+
$( app.html.collection.create( data.collections ) ).appendTo( '.collections_list' );
|
10
|
+
app.helpers.yielder( app.html.stats, data.stats );
|
11
|
+
}
|
12
|
+
})
|
13
|
+
e.preventDefault();
|
14
|
+
} );
|
15
|
+
$('.collections_list a').live( 'click', function( e ){
|
16
|
+
$.ajax({
|
17
|
+
url: e.target,
|
18
|
+
success: function( data ){
|
19
|
+
if( data && data.header ) app.helpers.header( data.header, true );
|
20
|
+
app.storage.set("collection", $(e.target).text());
|
21
|
+
app.helpers.yielder( app.html.stats, data.stats );
|
22
|
+
// $( app.html.collection.create( JSON.parse( data ) ) ).appendTo( '.collections_list' );
|
23
|
+
}
|
24
|
+
})
|
25
|
+
e.preventDefault();
|
26
|
+
} );
|
27
|
+
$( '.query_link' ).live( 'click', function( e ){
|
28
|
+
app.helpers.yielder( app.html.query_browser, {} );
|
29
|
+
e.preventDefault();
|
30
|
+
} );
|
31
|
+
$( '.yielder form' ).live( 'submit', function( e ){
|
32
|
+
var db = app.storage.get("database"), coll = app.storage.get("collection")
|
33
|
+
if(db && !coll){
|
34
|
+
alert("Please choose a collection first.")
|
35
|
+
return false;
|
36
|
+
}
|
37
|
+
e.preventDefault();
|
38
|
+
app.ax({
|
39
|
+
url: '/database/'+ db +'/collection/' + coll + '/page/' + 1,
|
40
|
+
data: $(this).serialize(),
|
41
|
+
success: function( data ){
|
42
|
+
app.storage.set("result_set", data );
|
43
|
+
$( app.html.build_results.create( data ) ).appendTo( '.query_result' );
|
44
|
+
}
|
45
|
+
})
|
46
|
+
} )
|
47
|
+
});
|
48
|
+
app.helpers.yielder = function( cb_function, arguments ){
|
49
|
+
$( cb_function.create( arguments ) ).appendTo( '.yielder' );
|
50
|
+
};
|
51
|
+
app.helpers.header = function( new_header, query ){
|
52
|
+
query = query || false
|
53
|
+
$( '.header' ).text( new_header );
|
54
|
+
if(query) $( '.query_link' ).html( '<a href="#", class="btn primary">Query</a>' );
|
55
|
+
};
|
56
|
+
app.html.collection = {
|
57
|
+
selector: '.collections_list',
|
58
|
+
clear: function(){
|
59
|
+
$( this._el() ).children().remove();
|
60
|
+
},
|
61
|
+
create: function( collections ){
|
62
|
+
this.clear();
|
63
|
+
var db = app.storage.get("database");
|
64
|
+
var get_children = function( collections ){
|
65
|
+
var res = []
|
66
|
+
$.each( collections, function( _, v ){
|
67
|
+
res.push({ tag: "TR", children: [
|
68
|
+
{ tag: "TD", children: [
|
69
|
+
{ tag: "A", href: '/database/' + db + '/collection/' + v, text: v }
|
70
|
+
] }
|
71
|
+
] });
|
72
|
+
} );
|
73
|
+
return res;
|
74
|
+
}
|
75
|
+
return(
|
76
|
+
{ tag: "TABLE", children: [
|
77
|
+
{ tag: "TBODY", children: get_children( collections ) }
|
78
|
+
] }
|
79
|
+
)
|
80
|
+
},
|
81
|
+
_el: function(){
|
82
|
+
return $(this.selector);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
app.html.stats = {
|
86
|
+
selector: '.yielder',
|
87
|
+
clear: function(){
|
88
|
+
$( this._el() ).children().remove();
|
89
|
+
},
|
90
|
+
create: function( stats_json ){
|
91
|
+
this.clear();
|
92
|
+
return(
|
93
|
+
{ tag: "TABLE", cls: 'zebra-striped', children:
|
94
|
+
[
|
95
|
+
{ tag: "TBODY", children: this._build_children( stats_json ) }
|
96
|
+
]
|
97
|
+
}
|
98
|
+
)
|
99
|
+
},
|
100
|
+
_build_children: function( stats_json ){
|
101
|
+
var chidren = [];
|
102
|
+
for( key in stats_json ){
|
103
|
+
chidren.push(
|
104
|
+
{ tag: "TR", children: [
|
105
|
+
{ tag: "TH", text: key },
|
106
|
+
{ tag: "TD", text: this._format_object( stats_json[key] ) }
|
107
|
+
] }
|
108
|
+
)
|
109
|
+
};
|
110
|
+
return chidren;
|
111
|
+
},
|
112
|
+
_el: function(){
|
113
|
+
return $(this.selector);
|
114
|
+
},
|
115
|
+
_format_object: function( value ){
|
116
|
+
if( app.isObject( value ) ){
|
117
|
+
return JSON.stringify( value );
|
118
|
+
}else{
|
119
|
+
return value.toString();
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|
@@ -0,0 +1,260 @@
|
|
1
|
+
/* =========================================================
|
2
|
+
* bootstrap-modal.js v1.4.0
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#modal
|
4
|
+
* =========================================================
|
5
|
+
* Copyright 2011 Twitter, Inc.
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
* ========================================================= */
|
19
|
+
|
20
|
+
|
21
|
+
!function( $ ){
|
22
|
+
|
23
|
+
"use strict"
|
24
|
+
|
25
|
+
/* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
|
26
|
+
* ======================================================= */
|
27
|
+
|
28
|
+
var transitionEnd
|
29
|
+
|
30
|
+
$(document).ready(function () {
|
31
|
+
|
32
|
+
$.support.transition = (function () {
|
33
|
+
var thisBody = document.body || document.documentElement
|
34
|
+
, thisStyle = thisBody.style
|
35
|
+
, support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
|
36
|
+
return support
|
37
|
+
})()
|
38
|
+
|
39
|
+
// set CSS transition event type
|
40
|
+
if ( $.support.transition ) {
|
41
|
+
transitionEnd = "TransitionEnd"
|
42
|
+
if ( $.browser.webkit ) {
|
43
|
+
transitionEnd = "webkitTransitionEnd"
|
44
|
+
} else if ( $.browser.mozilla ) {
|
45
|
+
transitionEnd = "transitionend"
|
46
|
+
} else if ( $.browser.opera ) {
|
47
|
+
transitionEnd = "oTransitionEnd"
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
})
|
52
|
+
|
53
|
+
|
54
|
+
/* MODAL PUBLIC CLASS DEFINITION
|
55
|
+
* ============================= */
|
56
|
+
|
57
|
+
var Modal = function ( content, options ) {
|
58
|
+
this.settings = $.extend({}, $.fn.modal.defaults, options)
|
59
|
+
this.$element = $(content)
|
60
|
+
.delegate('.close', 'click.modal', $.proxy(this.hide, this))
|
61
|
+
|
62
|
+
if ( this.settings.show ) {
|
63
|
+
this.show()
|
64
|
+
}
|
65
|
+
|
66
|
+
return this
|
67
|
+
}
|
68
|
+
|
69
|
+
Modal.prototype = {
|
70
|
+
|
71
|
+
toggle: function () {
|
72
|
+
return this[!this.isShown ? 'show' : 'hide']()
|
73
|
+
}
|
74
|
+
|
75
|
+
, show: function () {
|
76
|
+
var that = this
|
77
|
+
this.isShown = true
|
78
|
+
this.$element.trigger('show')
|
79
|
+
|
80
|
+
escape.call(this)
|
81
|
+
backdrop.call(this, function () {
|
82
|
+
var transition = $.support.transition && that.$element.hasClass('fade')
|
83
|
+
|
84
|
+
that.$element
|
85
|
+
.appendTo(document.body)
|
86
|
+
.show()
|
87
|
+
|
88
|
+
if (transition) {
|
89
|
+
that.$element[0].offsetWidth // force reflow
|
90
|
+
}
|
91
|
+
|
92
|
+
that.$element.addClass('in')
|
93
|
+
|
94
|
+
transition ?
|
95
|
+
that.$element.one(transitionEnd, function () { that.$element.trigger('shown') }) :
|
96
|
+
that.$element.trigger('shown')
|
97
|
+
|
98
|
+
})
|
99
|
+
|
100
|
+
return this
|
101
|
+
}
|
102
|
+
|
103
|
+
, hide: function (e) {
|
104
|
+
e && e.preventDefault()
|
105
|
+
|
106
|
+
if ( !this.isShown ) {
|
107
|
+
return this
|
108
|
+
}
|
109
|
+
|
110
|
+
var that = this
|
111
|
+
this.isShown = false
|
112
|
+
|
113
|
+
escape.call(this)
|
114
|
+
|
115
|
+
this.$element
|
116
|
+
.trigger('hide')
|
117
|
+
.removeClass('in')
|
118
|
+
|
119
|
+
$.support.transition && this.$element.hasClass('fade') ?
|
120
|
+
hideWithTransition.call(this) :
|
121
|
+
hideModal.call(this)
|
122
|
+
|
123
|
+
return this
|
124
|
+
}
|
125
|
+
|
126
|
+
}
|
127
|
+
|
128
|
+
|
129
|
+
/* MODAL PRIVATE METHODS
|
130
|
+
* ===================== */
|
131
|
+
|
132
|
+
function hideWithTransition() {
|
133
|
+
// firefox drops transitionEnd events :{o
|
134
|
+
var that = this
|
135
|
+
, timeout = setTimeout(function () {
|
136
|
+
that.$element.unbind(transitionEnd)
|
137
|
+
hideModal.call(that)
|
138
|
+
}, 500)
|
139
|
+
|
140
|
+
this.$element.one(transitionEnd, function () {
|
141
|
+
clearTimeout(timeout)
|
142
|
+
hideModal.call(that)
|
143
|
+
})
|
144
|
+
}
|
145
|
+
|
146
|
+
function hideModal (that) {
|
147
|
+
this.$element
|
148
|
+
.hide()
|
149
|
+
.trigger('hidden')
|
150
|
+
|
151
|
+
backdrop.call(this)
|
152
|
+
}
|
153
|
+
|
154
|
+
function backdrop ( callback ) {
|
155
|
+
var that = this
|
156
|
+
, animate = this.$element.hasClass('fade') ? 'fade' : ''
|
157
|
+
if ( this.isShown && this.settings.backdrop ) {
|
158
|
+
var doAnimate = $.support.transition && animate
|
159
|
+
|
160
|
+
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
|
161
|
+
.appendTo(document.body)
|
162
|
+
|
163
|
+
if ( this.settings.backdrop != 'static' ) {
|
164
|
+
this.$backdrop.click($.proxy(this.hide, this))
|
165
|
+
}
|
166
|
+
|
167
|
+
if ( doAnimate ) {
|
168
|
+
this.$backdrop[0].offsetWidth // force reflow
|
169
|
+
}
|
170
|
+
|
171
|
+
this.$backdrop.addClass('in')
|
172
|
+
|
173
|
+
doAnimate ?
|
174
|
+
this.$backdrop.one(transitionEnd, callback) :
|
175
|
+
callback()
|
176
|
+
|
177
|
+
} else if ( !this.isShown && this.$backdrop ) {
|
178
|
+
this.$backdrop.removeClass('in')
|
179
|
+
|
180
|
+
$.support.transition && this.$element.hasClass('fade')?
|
181
|
+
this.$backdrop.one(transitionEnd, $.proxy(removeBackdrop, this)) :
|
182
|
+
removeBackdrop.call(this)
|
183
|
+
|
184
|
+
} else if ( callback ) {
|
185
|
+
callback()
|
186
|
+
}
|
187
|
+
}
|
188
|
+
|
189
|
+
function removeBackdrop() {
|
190
|
+
this.$backdrop.remove()
|
191
|
+
this.$backdrop = null
|
192
|
+
}
|
193
|
+
|
194
|
+
function escape() {
|
195
|
+
var that = this
|
196
|
+
if ( this.isShown && this.settings.keyboard ) {
|
197
|
+
$(document).bind('keyup.modal', function ( e ) {
|
198
|
+
if ( e.which == 27 ) {
|
199
|
+
that.hide()
|
200
|
+
}
|
201
|
+
})
|
202
|
+
} else if ( !this.isShown ) {
|
203
|
+
$(document).unbind('keyup.modal')
|
204
|
+
}
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
/* MODAL PLUGIN DEFINITION
|
209
|
+
* ======================= */
|
210
|
+
|
211
|
+
$.fn.modal = function ( options ) {
|
212
|
+
var modal = this.data('modal')
|
213
|
+
|
214
|
+
if (!modal) {
|
215
|
+
|
216
|
+
if (typeof options == 'string') {
|
217
|
+
options = {
|
218
|
+
show: /show|toggle/.test(options)
|
219
|
+
}
|
220
|
+
}
|
221
|
+
|
222
|
+
return this.each(function () {
|
223
|
+
$(this).data('modal', new Modal(this, options))
|
224
|
+
})
|
225
|
+
}
|
226
|
+
|
227
|
+
if ( options === true ) {
|
228
|
+
return modal
|
229
|
+
}
|
230
|
+
|
231
|
+
if ( typeof options == 'string' ) {
|
232
|
+
modal[options]()
|
233
|
+
} else if ( modal ) {
|
234
|
+
modal.toggle()
|
235
|
+
}
|
236
|
+
|
237
|
+
return this
|
238
|
+
}
|
239
|
+
|
240
|
+
$.fn.modal.Modal = Modal
|
241
|
+
|
242
|
+
$.fn.modal.defaults = {
|
243
|
+
backdrop: false
|
244
|
+
, keyboard: false
|
245
|
+
, show: false
|
246
|
+
}
|
247
|
+
|
248
|
+
|
249
|
+
/* MODAL DATA- IMPLEMENTATION
|
250
|
+
* ========================== */
|
251
|
+
|
252
|
+
$(document).ready(function () {
|
253
|
+
$('body').delegate('[data-controls-modal]', 'click', function (e) {
|
254
|
+
e.preventDefault()
|
255
|
+
var $this = $(this).data('show', true)
|
256
|
+
$('#' + $this.attr('data-controls-modal')).modal( $this.data() )
|
257
|
+
})
|
258
|
+
})
|
259
|
+
|
260
|
+
}( window.jQuery || window.ender );
|
@@ -0,0 +1,60 @@
|
|
1
|
+
app = {};
|
2
|
+
app.html = {};
|
3
|
+
app.html.template = {};
|
4
|
+
app.storage = {};
|
5
|
+
app.helpers = {};
|
6
|
+
|
7
|
+
app.isObject = function (value) {
|
8
|
+
return Object.prototype.toString.call(value) == "[object Object]";
|
9
|
+
};
|
10
|
+
//adding storage event
|
11
|
+
$( document ).bind( 'storage', function( e, action, on, values ){
|
12
|
+
console.log(arguments);
|
13
|
+
$( '.expression_selector' ).trigger( e.type, [ action, on, values ] );
|
14
|
+
} );
|
15
|
+
|
16
|
+
app.remove = function( array, elem ){
|
17
|
+
for( var i = 0; i < elem.length; i++ ){
|
18
|
+
while( ( match = array.indexOf( elem[i] ) ) > -1 ){
|
19
|
+
array.splice(match, 1);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
return array;
|
23
|
+
};
|
24
|
+
app.capitalize = function( string ){
|
25
|
+
return string.replace(/^\w/, function($0) { return $0.toUpperCase(); })
|
26
|
+
};
|
27
|
+
app.compact = function( array ){
|
28
|
+
var ret = [];
|
29
|
+
for( var i = 0; i < array.length; i++ ){
|
30
|
+
if( !!array[i] )
|
31
|
+
ret.push( array[i] )
|
32
|
+
}
|
33
|
+
return ret;
|
34
|
+
};
|
35
|
+
app.contains = function( array, element ){
|
36
|
+
if( array.indexOf( element ) > -1 ) return true;
|
37
|
+
return false;
|
38
|
+
};
|
39
|
+
app.keys = function( obj ){
|
40
|
+
var ret = [];
|
41
|
+
for( var key in obj ){
|
42
|
+
ret.push( key );
|
43
|
+
}
|
44
|
+
return ret;
|
45
|
+
};
|
46
|
+
app.merge = function( base, obj ){
|
47
|
+
var res = {};
|
48
|
+
for( var attrname in base ) { res[attrname] = base[attrname]; }
|
49
|
+
for( var attrname in obj ) { res[attrname] = obj[attrname]; }
|
50
|
+
return res;
|
51
|
+
};
|
52
|
+
app.ajax = app.ax = function( options ){
|
53
|
+
var defaults = {
|
54
|
+
type: 'POST',
|
55
|
+
dataType: 'JSON',
|
56
|
+
};
|
57
|
+
options = $.extend( defaults, options );
|
58
|
+
console.log("making request with " + JSON.stringify( options, null, '\t' ) );
|
59
|
+
$.ajax( options );
|
60
|
+
};
|