Permalink
Browse files

some improvement

  • Loading branch information...
1 parent b171228 commit 93d864f83e2bb871e394295375a857d9b9b229e2 @iwyg committed May 9, 2012
@@ -993,7 +993,7 @@ input.search:focus {
background-image: linear-gradient(top, #668abe, #5c83ba 100%);
border-top: 1px solid #7492bc;
border-bottom: 1px solid #5880b8;
- margin-bottom: -1px;
+ margin-top: -1px;
}
.filemanager .file.selected .ui-icon.move {
background-position: -52px -64px;
@@ -483,7 +483,7 @@
* takes an array of pathsnames or String as commy separated list
*
* @param {Mixed} fnames string or array
- * @return {Mixed} Array (found file models) or undefined
+ * @return {Array} found file models
*/
getByFileName: function (fnames) {
var files = this.getFiles(),
@@ -501,7 +501,7 @@
});
fs && results.push(fs);
});
- return results.length ? results : undefined;
+ return results;
},
/**
@@ -19,7 +19,8 @@
], function ($, _, Backbone, Dirs, templates, SysMessage, convertBytes, helper) {
var SearchView, FileView, DirView, MetaView, TreeView, metaStates = {},
- siteRoot = Symphony.Context.get('root');
+ siteRoot = Symphony.Context.get('root'),
+ $doc = $(document);
SearchView = (function () {
var threshold = 0, trcache;
@@ -69,14 +70,22 @@
}
}
+ function _removeResultNode(model) {
+ var resultNode = $('#result-' + model.id);
+
+ if (resultNode.length) {
+ resultNode.remove();
+ }
+ }
+
function _bindEscape(event) {
this.field.parent().addClass('active');
- $(document).on('keyup.searchlist', _.bind(_clearOnEscape, this));
+ $doc.on('keyup.searchlist', _.bind(_clearOnEscape, this));
}
function _unbindEscape(event) {
this.field.parent().removeClass('active');
- $(document).off('keyup.searchlist');
+ $doc.off('keyup.searchlist');
}
return Backbone.View.extend({
@@ -92,7 +101,10 @@
this.template = templates.search_list;
this.list = this.$el.find('.results');
this.field = this.$el.find('input[type=text]');
- this.collection.on('selected', _.bind(_toggleSelected, this));
+ this.collection
+ .on('selected', _.bind(_toggleSelected, this))
+ .on('filedelete', _.bind(_removeResultNode, this));
+
//this.$el.on('keyup.searchlist input[type=text]', _.debounce(_.bind(_triggerSearch, this), 250));
},
@@ -132,12 +144,20 @@
* @private
* @api private
*/
- function _switchSelected(type) {
+ function _switchSelected(model) {
+ console.log(arguments);
+ if (model.get('selected')) {
+ this.$el.addClass('file-selected');
+ } else {
+ this.$el.removeClass('file-selected');
+ }
+ /*
if (type === 'add') {
this.$el.addClass('file-selected');
} else if (type === 'remove') {
this.$el.removeClass('file-selected');
}
+ */
}
return Backbone.View.extend({
@@ -156,9 +176,9 @@
this.$el.on('destroyed', _.bind(this.remove, this));
switchSelected = _.bind(_switchSelected, this);
- this.options.parentView
- .on('select', switchSelected)
- .on('unselect', switchSelected);
+ this.options.parentView.model
+ .on('change:selected', switchSelected);
+ //.on('unselect', switchSelected);
},
/**
@@ -200,11 +220,15 @@
!hard ? this.$el.slideDown() : this.$el.css({display: 'block'});
this._open = true;
this.trigger('open', this);
+
+ _switchSelected.call(this, this.options.parentView.model);
+ /*
if (fileNode.hasClass('selected')) {
_switchSelected.call(this, 'add');
} else if (this.options.parentView.model.get('selected')) {
_switchSelected.call(metaView, 'add');
}
+ */
return this;
},
@@ -395,7 +419,10 @@
parent && ! update && this.$el.appendTo(parent);
_setTasks.call(this);
- this.model.get('state') === 'open' && this.$el.addClass(this.model.get('state'));
+ if (this.model.get('state') === 'open') {
+ this.$el.addClass(this.model.get('state'));
+ this.$el.find('> .sub-dir').css({display: 'block'});
+ }
if (update) {
this.trigger('update', this);
@@ -686,11 +713,13 @@
}
_.each(fnames, function (path) {
- var fm = view.collection.getByFileName(path),
- fv = view.getFileViewByModel(fm[0]);
+ var fm = view.collection.getByFileName(path), fv;
+ fv = fm.length ? view.getFileViewByModel(fm[0]) : null;
if (fv) {
- fv.setMetaView();
- fv._metaView.open(true);
+ if (fv) {
+ fv.setMetaView();
+ fv._metaView.open(true);
+ }
}
});
}
@@ -938,6 +967,7 @@
if (helper.isjQueryObject(node)) {
node.find('> .sub-dir').slideDown();
node.addClass('open');
+ //node.find('> ul .sub-dir');
this.collection.get(node[0].id).set('state', 'open');
}
},
@@ -1019,7 +1019,7 @@ input[type=text], input.search {
.linear-gradient(@select_color, @select_grad_color);
.border-top(@select_border_top);
.border-bottom(@select_border_bottom);
- margin-bottom: -1px;
+ margin-top: -1px;
.ui-icon {
&.move {
.getBGPos(2, @gap, 64px);
@@ -292,26 +292,13 @@ function displaySettingsPanel(&$wrapper, $errors=NULL) {
$wrapper->appendChild($div);
}
- private function wrapContainerInError(XMLElement &$elemnt, $message = NULL) {
-
- $error_div = new XMLElement('div', null, array('class' => 'invalid'));
- $error_p = new XMLElement('p', $message);
- $error_div->appendChild($elemnt);
- $error_div->appendChild($error_p);
- return $error_div;
- }
-
// see: http://symphony-cms.com/learn/api/2.2.5/toolkit/field/#displayPublishPanel
function displayPublishPanel(&$wrapper, $data=NULL, $flagWithError=NULL, $fieldnamePrefix=NULL, $fieldnamePostfix=NULL, $entry_id=NULL, $fieldnameSuffix=NULL ) {
-
parent::displayPublishPanel($wrapper, $data, $flagWithError, $fieldnamePrefix, $fieldnamePostfix, $entry_id, $fieldnameSuffix);
$base_name = strtolower($this->_name);
- $tr = __('test124');
self::$field_instance++;
$instance = self::$field_instance;
- //$instance = $this->_i;
- //$instance = $instance++;
/* ==============================================================================================================================
* container
@@ -353,18 +340,6 @@ function displayPublishPanel(&$wrapper, $data=NULL, $flagWithError=NULL, $fieldn
'id' => $base_name . '-fileupload-' . $instance,
'class' => $base_name . '-upload-field field-container'
));
- /*
- $fieldset->appendChild($div);
- $div = new XMLElement('div', NULL, array(
- 'id' => $base_name . '-droparea',
- 'class' => $base_name . '-dropaera-field'
- ));
- $fieldset->appendChild($div);
- $div = new XMLElement('div', NULL, array(
- 'id' => $base_name . '-upload-list',
- 'class' => $base_name . '-upload-files-list field-container'
- ));
- */
$fieldset->appendChild($div);
}
@@ -398,7 +373,7 @@ function displayPublishPanel(&$wrapper, $data=NULL, $flagWithError=NULL, $fieldn
$fieldset->appendChild($script);
if (is_string($flagWithError) && strlen($flagWithError) > 0) {
- $wrapper->appendChild($this->wrapContainerInError($fieldcontainer, $flagWithError));
+ $wrapper->appendChild(Widget::wrapFormElementWithError($fieldcontainer, $flagWithError));
} else {
$wrapper->appendChild($fieldcontainer);
}

0 comments on commit 93d864f

Please sign in to comment.