Permalink
Browse files

new client comman - netmount

  • Loading branch information...
1 parent 227c69d commit bc00e41419b996736ba1383590675086e719315b @dio-el-claire dio-el-claire committed Apr 18, 2012
Showing with 98 additions and 1 deletion.
  1. +2 −1 elfinder.src.html
  2. +96 −0 js/commands/netmount.js
View
@@ -81,6 +81,7 @@
<script src="js/commands/view.js" type="text/javascript" charset="utf-8"></script>
<script src="js/commands/resize.js" type="text/javascript" charset="utf-8"></script>
<script src="js/commands/sort.js" type="text/javascript" charset="utf-8"></script>
+ <script src="js/commands/netmount.js" type="text/javascript" charset="utf-8"></script>
<!-- elfinder languages -->
<script src="js/i18n/elfinder.ar.js" type="text/javascript" charset="utf-8"></script>
@@ -236,7 +237,7 @@
}
}
}).dialogelfinder('instance')
- console.log(fm)
+
})
})
View
@@ -0,0 +1,96 @@
+"use strict"
+
+elFinder.prototype.commands.netmount = function() {
+ var self = this;
+
+ this.alwaysEnabled = true;
+ this.updateOnSelect = false;
+
+ this.netDrivers = [];
+
+ this.handlers = {
+ load : function() {
+ this.netDrivers = this.fm.netDrivers;
+ }
+ }
+
+ this.inputs = {
+ protocol : $('<select/>'),
+ host : $('<input type="text"/>'),
+ port : $('<input type="text"/>'),
+ path : $('<input type="text"/>'),
+ user : $('<input type="text"/>'),
+ pass : $('<input type="password"/>'),
+ }
+
+ this.getstate = function() {
+ return this.netDrivers.length ? 0 : -1;
+ }
+
+
+ this._dialog = function() {
+ var fm = self.fm,
+ opts = {
+ title : fm.i18n('netMountDialogTitle'),
+ resizable : false,
+ modal : true,
+ buttons : {}
+ },
+ content = $('<table class="elfinder-info-tb elfinder-netmount-tb"/>')
+ ;
+
+ opts.buttons[fm.i18n('btnMount')] = $.proxy(self._onsubmit, self);
+
+ opts.buttons[fm.i18n('btnCancel')] = function() {
+ self.dialog.elfinderdialog('close');
+ }
+
+ $.each(self.netDrivers, function(i, protocol) {
+ self.inputs.protocol.append('<option value="'+protocol+'">'+fm.i18n(protocol)+'</option>');
+ });
+
+
+ $.each(self.inputs, function(name, input) {
+ name != 'protocol' && input.addClass('ui-corner-all');
+ content.append($('<tr/>').append($('<td>'+fm.i18n(name)+'</td>')).append($('<td/>').append(input)));
+ });
+
+ self.dialog = fm.dialog(content, opts);
+
+ }
+
+ this._onsubmit = function() {
+ var data = {};
+
+ $.each(self.inputs, function(name, input) {
+ var val = input.val();
+
+ if (val) {
+ data[name] = val;
+ }
+ });
+
+ if (!data.host) {
+ self.fm.trigger('error', {error : 'errNetMountHostReq'});
+ }
+
+ }
+
+ this.exec = function() {
+
+ if (!self.dialog) {
+ self._dialog();
+ self.dfrd = $.Deferred();
+ } else if (self.dialog.is(':hidden')) {
+ $.each(self.inputs, function(i, input) {
+ input.val('');
+ })
+ }
+
+ self.dialog.elfinderdialog('open')
+
+ return self.dfrd.promise();
+ }
+
+
+}

0 comments on commit bc00e41

Please sign in to comment.