119 lines
4.0 KiB
Plaintext
119 lines
4.0 KiB
Plaintext
<table class="table main-list">
|
|
<thead>
|
|
<tr class="sort-header">
|
|
<% @table_fields.each_with_index do |f,i| %>
|
|
<%= thead(f) %>
|
|
<% end %>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% @registered_widgets.each do |rw| %>
|
|
<tr>
|
|
<td><%= rw.name rescue "" %></td>
|
|
<td><%= rw.widget_key %></td>
|
|
<% if rw.approved %>
|
|
<td>Approved</td>
|
|
<% else %>
|
|
<td>
|
|
<% if !rw.approved && current_user.is_admin? %>
|
|
<a class="btn btn-primary approve_btn" href="/admin/register_desktop_widgets/approve_widget?id=<%= rw.id.to_s %>">Approve</a>
|
|
<% elsif !rw.approved && !current_user.is_admin? %>
|
|
Approval Pending
|
|
<% else %>
|
|
Approved
|
|
<% end %>
|
|
</td>
|
|
<% end %>
|
|
<td>
|
|
<form class="register-form inline_forms form-inline pull-right" action="/admin/register_desktop_widgets/<%= rw.id.to_s %>" method="post" enctype="multipart/form-data">
|
|
<label>Widget :
|
|
<span class="btn btn-small">
|
|
<span class="fileupload-new">
|
|
<i class="icons-upload-2"></i>
|
|
<span class="file-name"></span>
|
|
</span>
|
|
<input type="file" class="hide registered-module-upload" name="registered_widget[widget]" data-fv-validation="zipfilecheck;" data-fv-messages="Only Zip file allowed.;" />
|
|
</span>
|
|
</label>
|
|
<label>Icon :
|
|
<span class="btn btn-small">
|
|
<span class="fileupload-new">
|
|
<i class="icons-docs"></i>
|
|
<span class="file-name"></span>
|
|
</span>
|
|
<input type="file" class="hide registered-module-upload" name="registered_widget[icon]" data-fv-validation="imagefilecheck;" data-fv-messages="Only images allowed.;" />
|
|
</span>
|
|
</label>
|
|
<input type="hidden" value="patch" name="_method">
|
|
<input type="submit" disabled="disabled" value="Save" class="btn btn-small" />
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
<script type="text/javascript">
|
|
$('.registered-module-upload').on('change', function(event) {
|
|
$(this).prev('span').find('.file-name').text(event.target.files[0].name);
|
|
$(this).parents(".inline_forms").find("input[type=submit]").removeAttr("disabled");
|
|
$(this).next('.validator_error_class').remove();
|
|
})
|
|
|
|
$(".approve_btn").on("click",function(){
|
|
|
|
})
|
|
|
|
$(".inline_forms").on("submit",function(){
|
|
var form_el = $(this),
|
|
formv = new FormValidator(form_el);
|
|
formv.validate_functions.zipfilecheck = function(value,element){
|
|
if(value == "") return true;
|
|
var ext = value.split(".");
|
|
return (ext[ext.length - 1] == "zip" ? true : false);
|
|
}
|
|
formv.validate_functions.imagefilecheck = function(value,element){
|
|
if(value == "") return true;
|
|
var ext = value.split(".");
|
|
ext = ext[ext.length - 1];
|
|
return (ext == "png" || ext == "jpg" ? true : false);
|
|
}
|
|
var v = formv.isFormValidated();
|
|
if(v){
|
|
$(this).ajaxSubmit({
|
|
success : function(){
|
|
form_el.resetForm();
|
|
form_el.find(".file-name").text("");
|
|
form_el.find("input[type=submit]").attr("disabled","disabled");
|
|
}
|
|
});
|
|
}
|
|
return false;
|
|
})
|
|
</script>
|
|
<style type="text/css">
|
|
.register-form {
|
|
margin: 0 20px 0 0;
|
|
}
|
|
.register-form label {
|
|
float: left;
|
|
margin-right: 5px;
|
|
margin-bottom: 0;
|
|
}
|
|
.validator_error_class {
|
|
display: inline-block;
|
|
}
|
|
.file-name {
|
|
position: relative;
|
|
top: 4px;
|
|
left: 4px;
|
|
display: inline-block;
|
|
max-width: 120px;
|
|
line-height: 1.2;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
.fileupload-new:before {
|
|
display: inline-block;
|
|
}
|
|
</style> |