Skip to content

Commit

Permalink
Fixed tabs and spaces intermittently changing -- most of the app is s…
Browse files Browse the repository at this point in the history
…paces, lets keep it consistent
  • Loading branch information
scouttyg committed Dec 2, 2014
1 parent fe0d0b1 commit 3e8684c
Show file tree
Hide file tree
Showing 16 changed files with 259 additions and 256 deletions.
14 changes: 7 additions & 7 deletions app/assets/javascripts/lib/jquery.filedrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,13 @@
upload.startData = 0;
upload.addEventListener("progress", progress, false);

// Allow url to be a method
if (jQuery.isFunction(opts.url)) {
xhr.open("POST", opts.url(), true);
} else {
xhr.open("POST", opts.url, true);
}
// Allow url to be a method
if (jQuery.isFunction(opts.url)) {
xhr.open("POST", opts.url(), true);
} else {
xhr.open("POST", opts.url, true);
}
xhr.setRequestHeader('content-type', 'multipart/form-data; boundary=' + boundary);

// Add headers
Expand Down
233 changes: 119 additions & 114 deletions app/assets/javascripts/lib/jquery.inputHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,119 +37,124 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
(function() {

(function($) {
var InputHistory, normalizeKeyHandler;
InputHistory = (function() {

InputHistory.name = 'InputHistory';

function InputHistory(options) {
this.size = options.size || 50;
this.record = [];
this.values = [];
this.index = 0;
}

InputHistory.prototype.push = function(message) {
/* only add to the history if the first item in the
history isn't the same */
if ( message != this.record[0] ) {
this.record.unshift(message);
}
return this.record.splice(this.size);
};

InputHistory.prototype.prev = function(val) {
this.index += 1;
return this.values[this.index];
};

InputHistory.prototype.next = function() {
this.index -= 1;
return this.values[this.index];
};

InputHistory.prototype.reset = function() {
this.index = 0;
this.values = this.record.slice(0);
this.values.unshift("");
}

InputHistory.prototype.hasNext = function() {
return this.index != 0;
}

InputHistory.prototype.hasPrev = function() {
return this.index < this.values.length - 1;
}

InputHistory.prototype.currentize = function(val) {
this.values[this.index] = val;
}

return InputHistory;

})();
normalizeKeyHandler = function(raw, elseHandler) {
elseHandler || (elseHandler = function(e) {});
switch (typeof raw) {
case 'number':
return function(e) {
return e.keyCode === raw;
};
case 'string':
return function(e) {
return "" + e.keyCode === raw;
};
case 'function':
return raw;
default:
return elseHandler;
}
};
return $.fn.inputHistory = function(options) {
var history,
_this = this;
options || (options = {});
options.data || (options.data = 'inputHistory');
options.store = normalizeKeyHandler(options.store, function(e) {
return e.keyCode === 13 && !e.shiftKey && !e.metaKey && !e.ctrlKey && !e.altKey;
});
options.prev = normalizeKeyHandler(options.prev, function(e) {
return (e.keyCode === 38 && e.altKey) || (e.ctrlKey && e.keyCode === 80);
});
options.next = normalizeKeyHandler(options.next, function(e) {
return (e.keyCode === 40 && e.altKey) || (e.ctrlKey && e.keyCode === 78);
});
options.reset = normalizeKeyHandler(options.reset, function(e) {
return e.keyCode === 27;
});
history = this.data(options.data) || new InputHistory(options);
this.data(options.data, history);
this.bind('keydown', function(e) {
history.currentize(_this.val());
if (options.store(e) && _this.val() != '') {
history.push(_this.val());
history.reset();
} else if (options.prev(e)) {
if (history.hasPrev()) {
_this.val(history.prev());
}
e.preventDefault();
} else if (options.next(e)) {
if (history.hasNext()) {
_this.val(history.next())
}
e.preventDefault();
} else if (options.reset(e)) {
_this.val("");
history.reset();
e.preventDefault();
}
});
return this;
};
})(jQuery);
(function($) {
var InputHistory, normalizeKeyHandler;

InputHistory = (function() {
InputHistory.name = 'InputHistory';

function InputHistory(options) {
this.size = options.size || 50;
this.record = [];
this.values = [];
this.index = 0;
}

InputHistory.prototype.push = function(message) {
/* only add to the history if the first item in the history isn't the same */
if ( message != this.record[0] ) {
this.record.unshift(message);
}
return this.record.splice(this.size);
};

InputHistory.prototype.prev = function(val) {
this.index += 1;
return this.values[this.index];
};

InputHistory.prototype.next = function() {
this.index -= 1;
return this.values[this.index];
};

InputHistory.prototype.reset = function() {
this.index = 0;
this.values = this.record.slice(0);
this.values.unshift("");
}

InputHistory.prototype.hasNext = function() {
return this.index != 0;
}

InputHistory.prototype.hasPrev = function() {
return this.index < this.values.length - 1;
}

InputHistory.prototype.currentize = function(val) {
this.values[this.index] = val;
}

return InputHistory;
})();

normalizeKeyHandler = function(raw, elseHandler) {
elseHandler || (elseHandler = function(e) {});
switch (typeof raw) {
case 'number':
return function(e) {
return e.keyCode === raw;
};
case 'string':
return function(e) {
return "" + e.keyCode === raw;
};
case 'function':
return raw;
default:
return elseHandler;
}
};

return $.fn.inputHistory = function(options) {
var history, _this = this;
options || (options = {});
options.data || (options.data = 'inputHistory');

options.store = normalizeKeyHandler(options.store, function(e) {
return e.keyCode === 13 && !e.shiftKey && !e.metaKey && !e.ctrlKey && !e.altKey;
});

options.prev = normalizeKeyHandler(options.prev, function(e) {
return (e.keyCode === 38 && e.altKey) || (e.ctrlKey && e.keyCode === 80);
});

options.next = normalizeKeyHandler(options.next, function(e) {
return (e.keyCode === 40 && e.altKey) || (e.ctrlKey && e.keyCode === 78);
});

options.reset = normalizeKeyHandler(options.reset, function(e) {
return e.keyCode === 27;
});

history = this.data(options.data) || new InputHistory(options);
this.data(options.data, history);

this.bind('keydown', function(e) {
history.currentize(_this.val());
if (options.store(e) && _this.val() != '') {
history.push(_this.val());
history.reset();
} else if (options.prev(e)) {
if (history.hasPrev()) {
_this.val(history.prev());
}
e.preventDefault();
} else if (options.next(e)) {
if (history.hasNext()) {
_this.val(history.next())
}
e.preventDefault();
} else if (options.reset(e)) {
_this.val("");
history.reset();
e.preventDefault();
}
});

return this;
};
})(jQuery);

}).call(this);
4 changes: 2 additions & 2 deletions app/assets/javascripts/lib/modernizr.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,10 @@ window.Modernizr = (function( window, document, undefined ) {
// By Theodoor van Donge

// window.webkitNotifications is only used by Chrome
// http://www.html5rocks.com/en/tutorials/notifications/quick/
// http://www.html5rocks.com/en/tutorials/notifications/quick/

// window.Notification only exist in the draft specs
// http://dev.w3.org/2006/webapi/WebNotifications/publish/Notifications.html#idl-if-Notification
// http://dev.w3.org/2006/webapi/WebNotifications/publish/Notifications.html#idl-if-Notification

Modernizr.addTest('notification', 'Notification' in window && 'permission' in window.Notification && 'requestPermission' in window.Notification);
;
66 changes: 33 additions & 33 deletions app/controllers/admin/admin_controller.rb
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
module Admin
class AdminController < BaseController

def index
@settings = Setting.my_settings
@all_users = User.find(:all, :conditions => ["id != ?", current_user.id])
def index
@settings = Setting.my_settings
@all_users = User.find(:all, :conditions => ["id != ?", current_user.id])

@waiting_for_approval_users = []
@approved_users = []
@waiting_for_approval_users = []
@approved_users = []

# Iterate over the array to get approved and non-approved users
@all_users.each{|user| user.registration_status.waiting_approval? ? @waiting_for_approval_users.push(user) : @approved_users.push(user) }
end
# Iterate over the array to get approved and non-approved users
@all_users.each{|user| user.registration_status.waiting_approval? ? @waiting_for_approval_users.push(user) : @approved_users.push(user) }
end

def update
def update

max_rooms = params[:setting][:max_rooms].to_i
max_rooms = params[:setting][:max_rooms].to_i
public_site = params[:setting][:public_site] == "1"
disable_conn_disconn_activity = params[:setting][:disable_conn_disconn_activity] == "1"
disable_conn_disconn_activity = params[:setting][:disable_conn_disconn_activity] == "1"

Setting.set_values(:max_rooms => max_rooms, :public_site => public_site, :disable_conn_disconn_activity => disable_conn_disconn_activity)
Setting.set_values(:max_rooms => max_rooms, :public_site => public_site, :disable_conn_disconn_activity => disable_conn_disconn_activity)

redirect_to :admin_root
end
redirect_to :admin_root
end

def update_user
user_id = params[:user_id]
action = params[:action_taken].to_s
def update_user
user_id = params[:user_id]
action = params[:action_taken].to_s

user = User.find(user_id)
user = User.find(user_id)

case action
when "activate", "approve"
user.activate!
when "suspend"
user.suspend!
end
case action
when "activate", "approve"
user.activate!
when "suspend"
user.suspend!
end

render :json => user, :status => 200
end
render :json => user, :status => 200
end

def toggle_admin
user_id = params[:user_id]
def toggle_admin
user_id = params[:user_id]

user = User.find(user_id)
user = User.find(user_id)

user.is_admin = !user.is_admin?
user.is_admin = !user.is_admin?

user.save!
user.save!

render :json => user, :status => 200
end
render :json => user, :status => 200
end

end
end
11 changes: 5 additions & 6 deletions app/controllers/admin/base_controller.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
module Admin
class BaseController < ApplicationController
before_filter :authenticate_admin!
before_filter :authenticate_admin!

private

def authenticate_admin!
redirect_to root_url unless current_user.try(:is_admin?)
end
private

def authenticate_admin!
redirect_to root_url unless current_user.try(:is_admin?)
end
end
end
Loading

0 comments on commit 3e8684c

Please sign in to comment.